window.addEvent('domready', function() 
{
	function checker(){
		check = new FormCheck('generalquotation', {
		display : {
			fadeDuration : 500,
			errorsLocation : 1,
			indicateErrors : 1,
			showErrors : 1
		}
	});
	};
	
	checker();
	
	new FormCheck('generalquotation');
	
	function getCookie(c_name)
	{
	if (document.cookie.length>0)
	  {
	  c_start=document.cookie.indexOf(c_name + "=");
	  if (c_start!=-1)
		{
		c_start=c_start + c_name.length+1;
		c_end=document.cookie.indexOf(";",c_start);
		if (c_end==-1) c_end=document.cookie.length;
		return unescape(document.cookie.substring(c_start,c_end));
		}
	  }
	return "";
	}
	

	var highlighter = $$('.highlighter');
	highlighter.each(function(element) {
		element.addEvent('focus', function(event) {
			element.style.backgroundColor ='#012c37';
			element.style.borderColor  ='#005266';
		});
		element.addEvent('blur', function(event) {
			element.style.backgroundColor ='#1f1f1f';
			element.style.borderColor  ='#3c3c3c';
		});		
	});		
	
	var services = $$('.services');
	services.each(function(element) {
		element.addEvent('click', function(event) {	
			if(element.checked == true)
			{
				if(element.value == "Website Design")
				{
					//ajaxCall(1);
					$('webdesignbox').style.display = 'none';
					$('design_form').value = 0;
				}	
				
				if(element.value == "SEO - Internet Marketing")
				{
					//ajaxCall(2);
					$('seobox').style.display = 'none';
					$('seo_form').value = 0;
				}
				
				
				if(element.value == "Computer Repairs")
				{
					//ajaxCall(3);
					$('repairbox').style.display = 'none';
					$('repairs_form').value = 0;
				}
						
				if(element.value == "Data Recovery")
				{
					//ajaxCall(4);
					$('recoverybox').style.display = 'none';
					$('recovery_form').value = 0;
				}		
				
						
				if(element.value == "Network Installation")
				{
					//ajaxCall(5);
					$('networkbox').style.display = 'none';
					$('network_form').value = 0;
				}				
					
						
				if(element.value == "Can't find, what I am looking for?")
				{
					//ajaxCall(6);
					$('otherbox').style.display = 'none';
					$('other_form').value = 0;
				}	
				
				
				
			}
			else
			{
				
				//alert(element.value);	
				
				if(element.value == "Website Design")
				{
					//ajaxCall(1);
					$('webdesignbox').style.display = 'block';
					$('design_form').value = 1;
				}
				
				if(element.value == "SEO - Internet Marketing")
				{
					//ajaxCall(2);
					$('seobox').style.display = 'block';
					$('seo_form').value = 1;
				}
				
				
				if(element.value == "Computer Repairs")
				{
					//ajaxCall(3);
					$('repairbox').style.display = 'block';
					$('repairs_form').value = 1;
				}
						
				if(element.value == "Data Recovery")
				{
					//ajaxCall(4);
					$('recoverybox').style.display = 'block';
					$('recovery_form').value = 1;
				}		
				
						
				if(element.value == "Network Installation")
				{
					//ajaxCall(5);
					$('networkbox').style.display = 'block';
					$('network_form').value = 1;
				}				
					
						
				if(element.value == "Can't find, what I am looking for?")
				{
					//ajaxCall(6);
					$('otherbox').style.display = 'block';
					$('other_form').value = 1;
				}			
		
			}
									
		});					   			   
	});	
	
	/*
	//var services = $('services');
	var switcher = $$('.services');
	services.addEvent('click', function(event) {
		//alert(services.value);
		
		var switcher = $$('.switcher');
		switcher.each(function(element) {
			element.style.display='none'
		});	
		//$('projectdetails').style.display = 'block';
		
		if(services.value == "Website Design")
		{
			//ajaxCall(1);
			$('webdesignbox').style.display = 'block';
		}
		
		if(services.value == "SEO - Internet Marketing")
		{
			//ajaxCall(2);
			$('seobox').style.display = 'block';
		}
		
		if(services.value == "Computer Repairs")
		{
			//ajaxCall(3);
			$('repairbox').style.display = 'block';
		}
				
		if(services.value == "Data Recovery")
		{
			//ajaxCall(4);
			$('recoverybox').style.display = 'block';
		}		
		
				
		if(services.value == "Network Installation")
		{
			//ajaxCall(5);
			$('networkbox').style.display = 'block';
		}				
			
				
		if(services.value == "Can't find, what I am looking for?")
		{
			//ajaxCall(6);
			$('otherbox').style.display = 'block';
		}			
								  
	});
	*/
	
	$('security_code').addEvent('keyup', function(event) {	
		
		/*
			var req = new Request.HTML({
				method: 'get',
				url: 'getCode.php',
				//data: { 'do' : '1' }, // <- QUERY : ?do=1
				onRequest: function() {						
				},
				onSuccess: function(nodes, els, response) { 
					session = response;
					//alert(response);
				}
			}).send();
			*/
			
			//This code will send a data object via a GET request and alert the retrieved data.
			var jsonRequest = new Request.JSON({async: false, url: "getCode.php", onSuccess: function(response){
				//alert(response.security_code);    //Alerts "25 years".
				session = response.security_code;
			}}).get();



		//alert(session + " == " + $('security_code').value);
		//alert(session)
		if(session == $('security_code').value)
		{
			//alert("match");
			$('capthca_response').style.display = 'none';
		}
		else
		{
			//alert("unmatch");
			$('capthca_response').style.display = 'block';
		}
	});	
	

	
});	

function getCode()
{
	var req = new Request.HTML({
		method: 'get',
		url: 'getCode.php',
		//data: { 'do' : '1' }, // <- QUERY : ?do=1
		onRequest: function() {						
		},
		onComplete: function(nodes, els, response) { 
		alert(response);
			return response;
		}
	}).send();
}


function popitup(url,width,height) {
	newwindow=window.open(url,'name','height='+height+',width='+width);
	if (window.focus) {newwindow.focus()}
	return false;
}
