dojo.addOnLoad(function() {
	dojo.query('#searchField').connect('onfocus', function() {
		this.value = '';
	});
	
	dojo.query('#searchField').connect('onfocus', function() {
		this.style.color = '#999';
	});
	
	dojo.query('#searchField').connect('onblur', function() {
		this.style.color = '#ccc';
	});

	dojo.query('a').connect('onclick', function() {
		this.blur();
	});
	
	
});

//Zomm text of page

dojo.require("dojo.NodeList-fx");

var Zoom = {

	max: 16,
	min: 7,
	current: 11,

	zoom_out: function() {
		this.current -= 2;
		if (this.current < this.min) {
			this.current = this.min;
		}
		this.resize();
	},

	zoom_in: function() {
		this.current += 2;
		if (this.current > this.max) {
			this.current = this.max;
		}
		this.resize();
	},

	resize: function() {
		dojo.animateProperty({
			node: "text_center_content", duration: 500,
			properties: {
				fontSize: { end: this.current, unit: "px" }
			}
		}).play();
	}
}


	function check_email(form_id,email) {
	   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	   var address = document.forms[form_id].elements[email].value;
	   if(reg.test(address) == false) {
	      return false;
		}
	}

	
		function validate_employer_login(){
	
			document.getElementById("message_employers").style.display = "none";
			
	
			with (document.employer_login){
				
				 if (euser.value == "" || epsw.value == ""){
					document.getElementById("message_employers").style.display = "inline";
					euser.select();
					
					
				} else {
					document.employer_login.submit();
				}
			}
		}
	
	
		function validate(){

			document.getElementById("first_name_id").style.display = "none";
			document.getElementById("second_name_id").style.display = "none";
			document.getElementById("family_id").style.display = "none";
			document.getElementById("phone_id").style.display = "none";
			document.getElementById("email_id").style.display = "none";
			document.getElementById("check_email_id").style.display = "none";
			document.getElementById("education_id").style.display = "none";
			document.getElementById("cource_date_id").style.display = "none";
			document.getElementById("factura_id").style.display = "none";
					
			with (document.cources_submit){
				 
				 var all_textbox_factura = 0;
				 
				 if(company.value!="" || city.value!="" || address.value!="" || EIK.value!="" || MOL.value!=""){
					all_textbox_factura = 1;		
				}
				
				
				 if (cource_date.value == ""){
					document.getElementById("cource_date_id").style.display = "block";
					return false;

				} else if (first_name.value == ""){
					document.getElementById("first_name_id").style.display = "block";
					first_name.select();
					return false;

				} else if (second_name.value == ""){
					document.getElementById("second_name_id").style.display = "block";
					second_name.select();
					return false;

				} else if (family.value == ""){
					document.getElementById("family_id").style.display = "block";
					family.select();
					return false;

				} else if (phone.value == ""){
					document.getElementById("phone_id").style.display = "block";
					phone.select();
					return false;

				/*} else if (email.value == ""){
					document.getElementById("email_id").style.display = "block";
					email.select();
					return false;  */
				
				} else if (check_email('cources_submit','email') == false && email.value!=""){
					document.getElementById("check_email_id").style.display = "block";
					email.select();
					return false;
				
				} else if (education.value == ""){
					document.getElementById("education_id").style.display = "block";
					return false;	
				
				//Данни за фактура
				} else if (company.value == "" && all_textbox_factura == 1){
					document.getElementById("factura_id").style.display = "inline";
					return false;
				
				} else if (city.value == "" && all_textbox_factura == 1){
					document.getElementById("factura_id").style.display = "inline";
					return false;
				
				} else if (address.value == "" && all_textbox_factura == 1){
					document.getElementById("factura_id").style.display = "inline";
					return false;
				
				} else if (EIK.value == "" && all_textbox_factura == 1){
					document.getElementById("factura_id").style.display = "inline";
					return false;
				
				} else if (MOL.value == "" && all_textbox_factura == 1){
					document.getElementById("factura_id").style.display = "inline";
					return false;
			
				} else {
					return true;

			}
		}
	}
	
	function change_password(){

			document.getElementById("nopassword").style.display = "none";
			
			with (document.changepassword){
				 
				
				 if (first_password.value == "" || second_password.value == ""){
					document.getElementById("nopassword").style.display = "block";
					first_password.select();
					return false;

				} else if (first_password.value != second_password.value){
					document.getElementById("nopassword").style.display = "block";
					first_password.select();
					return false;

			
				} else {
					return true;

			}
		}
	}
	
	//появяване на формата за login
	var Login = {
	show: function() {
		dojo.query('#login').style('display', 'block').style('opacity', '0').fadeIn().play();
	},

	hide: function() {
		dojo.query("#login").fadeOut().play();
	}
}

	//появяване на формата за смяна на паролата
var cgpsw = {
	show: function() {
		dojo.query('#change_password').style('display', 'block').style('opacity', '0').fadeIn().play();
	},

	hide: function() {
		dojo.query('#change_password').fadeOut().play();
	}
}

dojo.addOnLoad(function() {
	dojo.query('#login .input').connect('onfocus', function() {
		this.value = '';
	});
});
