/*

CUSTOM FORM ELEMENTS

Created by Ryan Fait
www.ryanfait.com

The only thing you need to change in this file is the following
variables: checkboxHeight, radioHeight and selectWidth.

Replace the first two numbers with the height of the checkbox and
radio button. The actual height of both the checkbox and radio
images should be 4 times the height of these two variables. The
selectWidth value should be the width of your select list image.

You may need to adjust your images a bit if there is a slight
vertical movement during the different stages of the button
activation.

Visit http://ryanfait.com/ for more information.

*/

var checkboxHeight = "15";
var radioHeight = "25";
var selectWidth = "97";

/* No need to change anything after this */

document.write('<style type="text/css">input.styled { display: none; } select.styled { position: relative; width: ' + selectWidth + 'px; opacity: 0; filter: alpha(opacity=0); z-index: 5; }</style>');

var Custom = {
	init: function() {
		var inputs = document.getElementsByTagName("input"), span = Array(), textnode, option, active;
		for(a = 0; a < inputs.length; a++) {
			if((inputs[a].type == "checkbox" || inputs[a].type == "radio") && inputs[a].className == "styled") {
				span[a] = document.createElement("span");
				span[a].className = inputs[a].type;

				if(inputs[a].checked == true) {
					if(inputs[a].type == "checkbox") {
						position = "0 -" + (checkboxHeight*2) + "px";
						span[a].style.backgroundPosition = position;
					} else {
						position = "0 -" + (radioHeight*2) + "px";
						span[a].style.backgroundPosition = position;
					}
				}
				inputs[a].parentNode.insertBefore(span[a], inputs[a]);
				inputs[a].onchange = Custom.clear;
				span[a].onmousedown = Custom.pushed;
				span[a].onmouseup = Custom.check;
				document.onmouseup = Custom.clear;
			}
		}
		inputs = document.getElementsByTagName("select");
		for(a = 0; a < inputs.length; a++) {
			if(inputs[a].className == "styled") {
				option = inputs[a].getElementsByTagName("option");
				active = option[0].childNodes[0].nodeValue;
				textnode = document.createTextNode(active);
				for(b = 0; b < option.length; b++) {
					if(option[b].selected == true) {
						textnode = document.createTextNode(option[b].childNodes[0].nodeValue);
					}
				}
				span[a] = document.createElement("span");
				span[a].className = "select";
				span[a].id = "select" + inputs[a].name;
				span[a].appendChild(textnode);
				inputs[a].parentNode.insertBefore(span[a], inputs[a]);
				inputs[a].onchange = Custom.choose;
			}
		}
	},
	pushed: function() {
		element = this.nextSibling;
		if(element.checked == true && element.type == "checkbox") {
			this.style.backgroundPosition = "0 -" + checkboxHeight*3 + "px";
		} else if(element.checked == true && element.type == "radio") {
			this.style.backgroundPosition = "0 -" + radioHeight*3 + "px";
		} else if(element.checked != true && element.type == "checkbox") {
			this.style.backgroundPosition = "0 -" + checkboxHeight + "px";
		} else {
			this.style.backgroundPosition = "0 -" + radioHeight + "px";
		}
	},
	check: function() {
		element = this.nextSibling;
		if(element.checked == true && element.type == "checkbox") {
			this.style.backgroundPosition = "0 0";
			element.checked = false;
		} else {
			if(element.type == "checkbox") {
				this.style.backgroundPosition = "0 -" + checkboxHeight*2 + "px";
			} else {
				this.style.backgroundPosition = "0 -" + radioHeight*2 + "px";
				group = this.nextSibling.name;
				inputs = document.getElementsByTagName("input");
				for(a = 0; a < inputs.length; a++) {
					if(inputs[a].name == group && inputs[a] != this.nextSibling) {
						inputs[a].previousSibling.style.backgroundPosition = "0 0";
					}
				}
			}
			element.checked = true;
		}
	},
	clear: function() {
		inputs = document.getElementsByTagName("input");
		for(var b = 0; b < inputs.length; b++) {
			if(inputs[b].type == "checkbox" && inputs[b].checked == true && inputs[b].className == "styled") {
				inputs[b].previousSibling.style.backgroundPosition = "0 -" + checkboxHeight*2 + "px";
			} else if(inputs[b].type == "checkbox" && inputs[b].className == "styled") {
				inputs[b].previousSibling.style.backgroundPosition = "0 0";
			} else if(inputs[b].type == "radio" && inputs[b].checked == true && inputs[b].className == "styled") {
				inputs[b].previousSibling.style.backgroundPosition = "0 -" + radioHeight*2 + "px";
			} else if(inputs[b].type == "radio" && inputs[b].className == "styled") {
				inputs[b].previousSibling.style.backgroundPosition = "0 0";
			}
		}
	},
	choose: function() {
		option = this.getElementsByTagName("option");
		for(d = 0; d < option.length; d++) {
			if(option[d].selected == true) {
				document.getElementById("select" + this.name).childNodes[0].nodeValue = option[d].childNodes[0].nodeValue;
			}
		}
	}
}
window.onload = Custom.init;













/*-----------*/
	var is_top_select = false;
	function showTopSelect(){
		if(!is_top_select){
			document.getElementById('expander').style.display = 'block';
			is_top_select = true;
		} else {
			document.getElementById('expander').style.display = 'none';
			is_top_select = false;
		}
	}
	
	
	function searchTypeClick(id){
		document.getElementById('top_select_txt').innerHTML = id.innerHTML;
		document.getElementById('expander').style.display = 'none';
		is_top_select = false;
	}
	
	
	var is_bottom_select = false;
	function showSelect_bottom(){
		if(!is_bottom_select){
			document.getElementById('expander_bottom').style.display = 'block';
			is_bottom_select = true;
		} else {
			document.getElementById('expander_bottom').style.display = 'none';
			is_bottom_select = false;
		}
	}
	
	
	function searchTypeClick_bottom(id){
		document.getElementById('top_select_txt_bottom').innerHTML = id.innerHTML;
		document.getElementById('expander_bottom').style.display = 'none';
		is_bottom_select = false;
	}
	
	function showCalendar(id){
		document.getElementById('calendar_popup_'+id).style.display = 'block';
	}
	function closeCalendar(id){
		document.getElementById('calendar_popup_'+id).style.display = 'none';
	}
	
	function showSavePopup(){
		document.getElementById('pop_up_save').style.display = 'block';
	}
	function closeSavePopup(){
		document.getElementById('pop_up_save').style.display = 'none';
	}
	
	
	var days = Array();
	days[1] = 1;
	days[2] = 2;
	days[3] = 3;
	days[4] = 4;
	days[5] = 5;
	days[6] = 6;
	days[7] = 7;
	days[8] = 8;
	days[9] = 9;
	days[10] = 10;
	days[11] = 11;
	days[12] = 12;
	days[13] = 13;
	days[14] = 14;
	days[15] = 15;
	days[16] = 16;
	days[17] = 17;
	days[18] = 18;
	days[19] = 19;
	days[20] = 20;
	days[21] = 21;
	days[22] = 22;
	days[23] = 23;
	days[24] = 24;
	days[25] = 25;
	days[26] = 26;
	days[27] = 27;
	days[28] = 28;
	days[29] = 29;
	days[30] = 30;
	days[31] = 31;
	
	var month = Array();
	month[1] = 'января';
	month[2] = 'февраля';
	month[3] = 'марта';
	month[4] = 'апреля';
	month[5] = 'мая';
	month[6] = 'июня';
	month[7] = 'июля';
	month[8] = 'августа';
	month[9] = 'сентября';
	month[10] = 'октября';
	month[11] = 'ноября';
	month[12] = 'декабря';
	
	
	var years = Array();
	years[1] = '2005';
	years[2] = '2006';
	years[3] = '2007';
	years[4] = '2008';
	years[5] = '2009';
	
	function day_plus(id){
		if((days[parseInt(document.getElementById("day_"+id).innerHTML)+1])<=31){
			document.getElementById("day_"+id).innerHTML = days[parseInt(document.getElementById("day_"+id).innerHTML)+1];
		} else {
			document.getElementById("day_"+id).innerHTML = days[1];
		}
	}
	function day_minus(id){
		if((days[parseInt(document.getElementById("day_"+id).innerHTML)-1])>=1){
			document.getElementById("day_"+id).innerHTML = days[parseInt(document.getElementById("day_"+id).innerHTML)-1];
		} else {
			document.getElementById("day_"+id).innerHTML = days[31];
		}
	}
	function month_plus(id){
		for(i=1; i<=(month.length); i++){
			if(month[i]==document.getElementById("month_"+id).innerHTML){
				break;
			}
		}
		if(i<12){
			document.getElementById("month_"+id).innerHTML = month[i+1];
		} else {
			document.getElementById("month_"+id).innerHTML = month[1];
		}
	}
	function month_minus(id){
		for(i=1; i<=(month.length); i++){
			if(month[i]==document.getElementById("month_"+id).innerHTML){
				break;
			}
		}
		if(i>1){
			document.getElementById("month_"+id).innerHTML = month[i-1];
		} else {
			document.getElementById("month_"+id).innerHTML = month[12];
		}
	}
	function year_plus(id){
		for(i=1; i<=(years.length); i++){
			if(years[i]==document.getElementById("year_"+id).innerHTML){
				break;
			}
		}
		if(i<((years.length)-1)){
			document.getElementById("year_"+id).innerHTML = years[i+1];
		} else {
			document.getElementById("year_"+id).innerHTML = years[1];
		}
	}
	function year_minus(id){
		for(i=1; i<=(years.length); i++){
			if(years[i]==document.getElementById("year_"+id).innerHTML){
				break;
			}
		}
		if(i>1){
			document.getElementById("year_"+id).innerHTML = years[i-1];
		} else {
			document.getElementById("year_"+id).innerHTML = years[(years.length)-1];
		}
	}
	
	
	var srok = Array();
	srok[1] = '13 недель';
	srok[2] = '14 недель';
	srok[3] = '15 недель';
	srok[4] = '16 недель';
	srok[5] = '15 лет';
	
	function srok_plus(id){
		for(i=1; i<=(years.length); i++){
			if(srok[i]==document.getElementById("srok_"+id).innerHTML){
				break;
			}
		}
		if(i<((srok.length)-1)){
			document.getElementById("srok_"+id).innerHTML = srok[i+1];
		} else {
			document.getElementById("srok_"+id).innerHTML = srok[1];
		}
	}
	function srok_minus(id){
		for(i=1; i<=(srok.length); i++){
			if(srok[i]==document.getElementById("srok_"+id).innerHTML){
				break;
			}
		}
		if(i>1){
			document.getElementById("srok_"+id).innerHTML = srok[i-1];
		} else {
			document.getElementById("srok_"+id).innerHTML = srok[(srok.length)-1];
		}
	}
	
	
	function liOpen(id, status){
		if(status){
			document.getElementById('li_ul_'+id).style.display = 'block';
			document.getElementById('li_'+id).style.background = 'url(images/center1_green_table7_li_2.gif) left 2px no-repeat';
			document.getElementById('li_'+id).onclick= function () {
				liOpen(id, false);
				return false;
			}
			document.getElementById('li_a_'+id).onclick= function () {
				liOpen(id, false);
				return false;
			}
		} else {
			document.getElementById('li_ul_'+id).style.display = 'none';
			document.getElementById('li_'+id).style.background = 'url(images/center1_green_table7_li.gif) left 2px no-repeat';
			document.getElementById('li_'+id).onclick= function () {
				liOpen(id, true);
				return false;
			}
			document.getElementById('li_a_'+id).onclick= function () {
				liOpen(id, true);
				return false;
			}
		}
	}	
	
/*-----------*/
	var is_top_select1 = Array();
	is_top_select1[1] = false;



	function showTopSelect1(id){
		if(!is_top_select1[id]){
			document.getElementById('expander_'+id).style.display = 'block';
			document.getElementById('selector_'+id).style.zIndex = '1000';
			is_top_select1[id] = true;
		} else {
			document.getElementById('expander_'+id).style.display = 'none';
			document.getElementById('selector_'+id).style.zIndex = '1';
			is_top_select1[id] = false;
		}
	}
	
	
	function searchTypeClick(li, id){
		document.getElementById('top_select_txt_'+id).innerHTML = li.innerHTML;
		document.getElementById('expander_'+id).style.display = 'none';
		is_top_select[id] = false;
	}
	
	var is_showAllService = false;
	function showAllService(){
		if(!is_showAllService){
			document.getElementById('top_nav_right2').style.height = 'auto';
			is_showAllService = true;
			document.getElementById('top_nav_right1').style.background = 'url(images/header_service_bg_1.gif) left bottom no-repeat';
		} else{
			document.getElementById('top_nav_right2').style.height = '86px';
			document.getElementById('top_nav_right1').style.background = 'url(images/header_service_bottom.jpg) left bottom no-repeat';
			is_showAllService = false;
		}
	}
	
	function showVibirai(){
		document.getElementById('vibirai').style.background = 'url(images/top_menu_bg_v.jpg) left top repeat-x';
		document.getElementById('vibirai_span').style.background = 'url(images/top_menu_left_v.jpg) left top no-repeat';
		document.getElementById('vibirai_a').style.background = 'url(images/top_menu_right_v.jpg) right top no-repeat';

		document.getElementById('vibirai_div').style.display = 'block';
	}
	function hideVibirai(){
		document.getElementById('vibirai_div').style.display = 'none';

		document.getElementById('vibirai').style.background = 'url(images/top_menu_bg.jpg) left top repeat-x';
		document.getElementById('vibirai_span').style.background = 'url(images/top_menu_left.jpg) left top no-repeat';
		document.getElementById('vibirai_a').style.background = 'url(images/top_menu_right.jpg) right top no-repeat';

	}

	function show_smile(){
		if(document.getElementById('my_mail_show_smile_block').style.display=='none'){
			document.getElementById('my_mail_show_smile').style.background='url(images/my_mail_smile_bg.jpg) left top no-repeat';
			document.getElementById('my_mail_show_smile_block').style.display='block';
		} else {
			document.getElementById('my_mail_show_smile').style.background='none';
			document.getElementById('my_mail_show_smile_block').style.display='none';
		}
	}

		
