function showhide(block_to_show,block_to_hide) {		
	var targetDiv = document.getElementById(block_to_show);
	targetDiv.style.display="block";
	var targetDiv2 = document.getElementById(block_to_hide);
	targetDiv2.style.display="none";
}

function check_anketa_form(form) 
{	
	var letters = /^[a-zA-Z ]+$/;	
	var digits = /^[0-9 +]+$/;			
						
	if (document.forms[form].name.value==""){
	alert('Įveskite vardą ir pavardę');document.forms[form].name.focus();return false}
			
	if(!document.forms[form].name.value.match(letters)){
	alert('Vardą ir pavardę gali sudaryti tik raidės');document.forms[form].name.focus();return false}
	
	if (document.forms[form].phone.value==""){
	alert('Įveskite telefoną');document.forms[form].phone.focus();return false}
	
	if(!document.forms[form].phone.value.match(digits)){
	alert('Telefoną gali sudaryti tik skaičiai, tarpai ir + simbolis');document.forms[form].phone.focus();return false}
	
	if (document.forms[form].email.value==""){
	alert("Įveskite elektroninį pašto adresą");document.forms[form].email.focus();return false}
			
	if(document.forms[form].email.value.indexOf('@', 0) == -1){
	alert("El. pašto adresas neteisingas");document.forms[form].email.focus();return false}

	if(document.forms[form].email.value.indexOf('.', 0) == -1){
	alert("El. pašto adresas neteisingas");document.forms[form].email.focus();return false}
	
	//Failo tipo vadilavimas
	var OK = new Array ('doc', 'html', 'htm', 'rtf', 'txt', 'odt','pdf');
	var filename =document.forms[form].cv.value;				
	var dot_pos = filename.lastIndexOf(".");
	if(dot_pos == -1)  {alert("Neteisingas CV failo tipas , CV gali būti doc,htm,html,rtf,txt,pdf ir odt formate");document.forms[form].cv.focus();return false}
	var ext = filename.substr(dot_pos+1).toLowerCase();			
	var fileOK = 0;
	 
	for (i = 0; i < OK.length; i++) {
	   if (OK[i] == ext) {
		 fileOK = 1; 
		} 
	}
	 
	if (fileOK == 0) {alert("Neteisingas CV failo tipas , CV gali būti doc,htm,html,rtf,txt ir odt formate");document.forms[form].cv.focus();return false}
											
}




function calculate(val,checked){		
	var priceval = document.getElementById('price').innerHTML * 1;
	if  (checked == true) {
		var priceval=Math.round((priceval + parseFloat(val))*100)/100;
		document.getElementById('price').innerHTML = priceval;
		
		var pvmval=Math.round((priceval*0.18)*100)/100;
		document.getElementById('pvm').innerHTML = pvmval;
		
		var totalval=Math.round((priceval+pvmval)*100)/100;
		document.getElementById('total').innerHTML = totalval;
		
	} else {		
		var priceval=Math.round((priceval - parseFloat(val))*100)/100;
		document.getElementById('price').innerHTML = priceval;	
		
		var pvmval=Math.round((priceval*0.18)*100)/100;
		document.getElementById('pvm').innerHTML = pvmval;
		
		var totalval=Math.round((priceval+pvmval)*100)/100;
		document.getElementById('total').innerHTML = totalval;
	}
}


function check_agreement() 
{	
	if (document.repair_form.agreement.checked == false) { alert ('Jūs turite sutikti su sąlygomis norint patvirtinti gedimų taisymą'); document.repair_form.agreement.focus(); return false; }
}	

function changeCarValues(part,value) {
	var part='part' + part;	
	var listenersDiv = document.getElementById(part);
	listenersDiv.value=value;
}



var xmlHttp // xmlHttp variable

function GetXmlHttpObject(){ // This function we will use to call our xmlhttpobject.
	var objXMLHttp=null // Sets objXMLHttp to null as default.
	if (window.XMLHttpRequest){ // If we are using Netscape or any other browser than IE lets use xmlhttp.
		objXMLHttp=new XMLHttpRequest() // Creates a xmlhttp request.
	}else if (window.ActiveXObject){ // ElseIf we are using IE lets use Active X.
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP") // Creates a new Active X Object.
	} // End ElseIf.
	return objXMLHttp // Returns the xhttp object.
} // Close Function

function CheckTimes(selected_date){ // This function we will use to check to see if a username is taken or not.
	xmlHttp=GetXmlHttpObject() // Creates a new Xmlhttp object.
	if (xmlHttp==null){ // If it cannot create a new Xmlhttp object.
		return // Returns.
	} // End If.	
	var url="src/calendar/get_times.php?selected_date="+selected_date // Url that we will use to check the username.
	xmlHttp.open("GET",url,true) // Opens the URL using GET
	xmlHttp.onreadystatechange = function () { // This is the most important piece of the puzzle, if onreadystatechange is equal to 4 than that means the request is done.
		if (xmlHttp.readyState == 4) { // If the onreadystatechange is equal to 4 lets show the response text.			
			document.getElementById("times").innerHTML = xmlHttp.responseText; // Updates the div with the response text from check.php
		} // End If.
	}; // Close Function
	xmlHttp.send(null); // Sends NULL instead of sending data.
} // Close Function.


function togglePick(div_id)
{					
	document.getElementById(div_id).click();	
}