// JavaScript Document
var year_values = new Array();
year_values[2009] = 0; 
year_values[2010] = 1; 
year_values[2011] = 2; 
year_values[2012] = 3; 
var airport_locations = new Array();
airport_locations[0]=0;
airport_locations[1]=0;
airport_locations[2]=0;
airport_locations[3]=0;
airport_locations[4]=1;
airport_locations[5]=1;
airport_locations[6]=0;
airport_locations[7]=0;
airport_locations[8]=0;
airport_locations[9]=0;
airport_locations[10]=0;
airport_locations[11]=0;
airport_locations[12]=0;
airport_locations[13]=1;
airport_locations[14]=1;
airport_locations[15]=0;
airport_locations[16]=0;
airport_locations[17]=0;
airport_locations[18]=0;
airport_locations[19]=0;
airport_locations[20]=0;
airport_locations[21]=0;
airport_locations[22]=0;
airport_locations[23]=0;
airport_locations[24]=0;
airport_locations[25]=1;
airport_locations[26]=1;
airport_locations[27]=1;
airport_locations[28]=0;
airport_locations[29]=0;
airport_locations[30]=0;
airport_locations[31]=0;
airport_locations[32]=0;
airport_locations[33]=0;
airport_locations[34]=0;
airport_locations[35]=0;
airport_locations[36]=0;
airport_locations[37]=0;
airport_locations[38]=0;
airport_locations[39]=0;
airport_locations[40]=0;
airport_locations[41]=0;
airport_locations[42]=1;
airport_locations[43]=0;
airport_locations[44]=0;
airport_locations[45]=0;
airport_locations[46]=0;
airport_locations[47]=0;
airport_locations[48]=0; 
airport_locations[49]=0;
airport_locations[50]=0;
airport_locations[51]=1;
airport_locations[52]=0;
airport_locations[53]=0;
airport_locations[54]=0;
airport_locations[55]=0;
airport_locations[56]=0;
airport_locations[57]=0;
airport_locations[58]=0;
airport_locations[59]=0;
airport_locations[60]=0;
airport_locations[61]=0;
airport_locations[62]=0;
airport_locations[63]=0;
airport_locations[64]=0;
airport_locations[65]=0;
airport_locations[66]=0;
airport_locations[67]=1;
airport_locations[68]=0;
airport_locations[69]=0;
airport_locations[70]=0;
airport_locations[71]=0;
airport_locations[72]=0;
airport_locations[73]=0;
airport_locations[74]=0;
airport_locations[75]=1;
airport_locations[76]=0;
airport_locations[77]=0;
airport_locations[78]=1;
airport_locations[79]=0;
airport_locations[80]=0;
airport_locations[81]=0;
airport_locations[82]=0;
airport_locations[83]=0;
airport_locations[84]=0;
//eliminates white spaces from a string
function trim(str)
{  
	while(str.charAt(0) == (" ") )
		str = str.substring(1);
  	while(str.charAt(str.length-1) == " " )
		str = str.substring(0,str.length-1);
  return str;
}

//submit form for admin adding
function submitAddForm()
{
	if(validate_form()==true)
		document.getElementById('add_form').submit();
}

function conf(strAlert)
{
	return confirm(strAlert);
}

//checks if a field is not empty
function field_required(input,err_msg,isFocus)
{
	if(isFocus==1)
		document.getElementById(input).value=trim(document.getElementById(input).value);	
	if(document.getElementById(input).value=="")
	{
		alert(err_msg);
		if(isFocus==1)
			document.getElementById(input).focus();
		return false;
	}
	return true;
}
//checks if a field is valid calling the specific function
function field_validate(input,err_msg,isFocus,checkFunction)
{
	if(isFocus==1)
		document.getElementById(input).value=trim(document.getElementById(input).value);	
	if(document.getElementById(input).value!="")
	{
		checkValue = eval(checkFunction+'(document.getElementById("'+input+'").value)');
		if(checkValue==false)
		{
			alert(err_msg);
			if(isFocus==1)
				document.getElementById(input).focus();
			return false;
		}
	}
	return true;
}
//sets composed phone value 
function composePhone(input)
{
	document.getElementById(input).value = document.getElementById(input+'_prefix').value+" "+trim(document.getElementById(input+'_provider').value)+" "+trim(document.getElementById(input+'_number').value);
}
//checks if phone number is valid
function check_phoneNo(str)
{
	str=str.replace(" ","");
	str=str.replace(" ","");
	if (!IsNumeric(str))
		return false;
	else
		return true;
}
//checks if string is number
function IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
}
//validates an email address
function check_mail(str) 
{
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1)
	   return false
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
	   return false
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
		return false
	 if (str.indexOf(at,(lat+1))!=-1)
		return false
	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
		return false
	 if (str.indexOf(dot,(lat+2))==-1)
		return false
	 if (str.indexOf(" ")!=-1)
		return false
	 return true					
}
//checks if file extention is valid as photo
function check_photoExtension(con)
{
    if(con.length >0)
    {
        var fileExtension = con.substring(con.lastIndexOf('.')+1,con.length);
        extensionValid =true;
        fileExtension = fileExtension.toUpperCase();
        if( fileExtension != "PNG" && fileExtension != "GIF" && fileExtension != "JPEG" && fileExtension != "JPG" )
            return false;	         				
   	}
	return true;
}
//checks if file extention is valid as file:doc,docx,xls,xlsx,ppt,pptx,txt,jpg,jpeg,pdf
function check_fileExtension(con)
{
    if(con.length >0)
    {
        var fileExtension = con.substring(con.lastIndexOf('.')+1,con.length);
        extensionValid =true;
        fileExtension = fileExtension.toUpperCase();
        if( fileExtension != "DOC" && fileExtension != "DOCX"  && fileExtension != "PDF")
            return false;	         				
   	}
	return true;
}
//Add photos to form
var max_photos = 3;
var cnt_photos = 0;
var no_photos = 0;
function addPhoto(err_msg,text_title,text_file,bt_del)
{
	if(cnt_photos<max_photos)
	{
		var parentDiv = document.getElementById("div_photos");
		var newDivId = "div_photo"+no_photos;
		var newdiv = document.createElement("div_photo"+no_photos);
		newdiv.setAttribute("id",newDivId);
		newdiv.innerHTML='<table>'+
							'<tr>'+
								'<td>'+text_file+'</td><td><input type="file" id="input_photo'+no_photos+'" name="input_photo[]"/></td>'+
							'</tr>'+
							'<tr>'+
								'<td>'+text_title+'</td><td><input type="text" id="input_photo_title'+no_photos+'" name="input_photo_title[]" style="width:200px" maxlength="50"/></td>'+
							'</tr>'+
							'<tr><td colspan="2"><a href="javascript:removePhoto('+no_photos+');">'+bt_del+'</a></td></tr>'+
							'<tr><td colspan="2" style="border-bottom:1px solid #CCCCCC; line-height:2px;">&nbsp;</td></tr>'+
						 '</table>';
		parentDiv.appendChild(newdiv);
		cnt_photos++;
		no_photos++;
	}
	else
		alert(err_msg+max_photos+"!");
}
function removePhoto(no)
{
	var parentDiv = document.getElementById("div_photos");
	var divId = "div_photo"+no;
	var removeDiv = document.getElementById(divId);
	parentDiv.removeChild(removeDiv);
	cnt_photos--;
}
function changePhoto(filename)
{
	var imgLarge = document.getElementById('img_large');
	var aLarge = document.getElementById('a_large');
	imgLarge.src = "upload/photos/"+filename;
	aLarge.href = "upload/photos/large/"+filename;
}
//Hide CNP for countries diferent from Romania
function change_country(ind)
{
	if(ind!=201)
		document.getElementById('tr_cnp').style.display = 'none';
	else
	{
		if(testIE6())
			document.getElementById('tr_cnp').style.display = 'block';
		else
			document.getElementById('tr_cnp').style.display = 'table-row';
	}
}
//Check if browser is IE -> no shadow(png)
function testIE6()
{
	var browserName=navigator.appName; 
	var agt=navigator.userAgent.toLowerCase();
	if (browserName=="Microsoft Internet Explorer")
	{
	  if((agt.indexOf("msie 6.")!=-1))
	  {
	  	return true;
	  }
	}
	return false;
}

//validate CNP
function check_CNP(str)
{
	if(str.lenght<13)	
		return false;
	if((str[0]!=1)&&(str[0]!=2))
		return false;
	if(!IsNumeric(str))
		return false;
	var date = str[5]+str[6]+"/"+str[3]+str[4]+"/"+str[1]+str[2];
	if(!check_date_str(date))
		return false;
	return true;
}
//Check if date is valid - input as string
function check_date_str(inputStr)
{
	ok = 1;
   	if(inputStr != "")
	{
		var testString = inputStr.split("/");
  		var dayfield=inputStr.split("/")[0];
		var monthfield= inputStr.split("/")[1];   
	 	var yearfield= inputStr.split("/")[2];
		if(testString.length > 1)
		{
			if (monthfield.length <1 || monthfield.length >2 || dayfield.length < 1 || dayfield.length >2 || yearfield.length > 4  || yearfield.length < 2)
			{
			   ok = 2;
			}
			else
			{ 
			 	//Detailed check for valid date ranges
				var dayobj = new Date(yearfield, monthfield-1, dayfield)
				if ((dayobj.getMonth()+1!=monthfield)||(dayobj.getDate()!=dayfield)||(dayobj.getYear()!=yearfield && dayobj.getFullYear() !=yearfield))
				{
				   ok = 2;
				}
			}
		}
		else
		   ok = 2;
   }
	if (ok ==2) 
		validation=false;
	else
		validation = true;
	return validation;
}
//Submit login form
function submit_login()
{
	var ok=1;
	var dvError = document.getElementById('div_error_login');
	var iUser = document.getElementById('input_user');
	var iPass = document.getElementById('input_pass');
	iUser.value=trim(iUser.value);
	iPass.value=trim(iPass.value);
	if(iUser.value=="")
	{
		ok=0;
		iUser.style.border="2px solid #E82C2E";
	}
	else
	{
		iUser.style.border="1px solid #9B9B9B";
		if(iPass.value=="")
		{
			ok=0;
			iPass.style.border="2px solid #E82C2E";
		}
	}
	if(ok==1)
		document.getElementById('form_login').submit();
}
//Create js date object from date,time string
function formatDateJS(strInput,strTime)
{
	var myDate = new Date;
	myDate = Date.UTC(strInput.split("/")[2]*1,strInput.split("/")[1]*1,strInput.split("/")[0]*1,strTime*1,0,0);
	return myDate;
}
//Car details page - Calculate price for selected days
function calculate(sel)
{
	var totalDiv = document.getElementById('div_total_calc');
	var prices = document.getElementById('hidden_calc').value.split(";");
	if((sel>=1)&&(sel<=4))	
		totalDiv.innerHTML = prices[0]*sel;
	if((sel>=5)&&(sel<=7))	
		totalDiv.innerHTML = prices[1]*sel;
	if((sel>=8)&&(sel<=14))	
		totalDiv.innerHTML = prices[2]*sel;
	if((sel>=15)&&(sel<=30))	
		totalDiv.innerHTML = prices[3]*sel;
	if(sel==0)
		totalDiv.innerHTML = "---";
}

//Reservation form - display price list when car type is selected
function displayPrice(carId)
{
	if(carId!=0)
	{
		price_values = document.getElementById('hidden_prices'+carId).value.split(";");
		document.getElementById('div_price1').innerHTML = '<strong>'+price_values[0]+'</strong>';
		document.getElementById('div_price2').innerHTML = '<strong>'+price_values[1]+'</strong>';
		document.getElementById('div_price3').innerHTML = '<strong>'+price_values[2]+'</strong>';
		document.getElementById('div_price4').innerHTML = '<strong>'+price_values[3]+'</strong>';
		document.getElementById('div_price5').innerHTML = '<strong>'+price_values[4]+'</strong>';
		document.getElementById('div_price6').innerHTML = '<strong>'+price_values[5]+'</strong>';
		document.getElementById('div_price7').innerHTML = '<strong>'+price_values[6]+'</strong>';
		var divError = document.getElementById('div_error');
		var divErrorHolder = document.getElementById('div_error_holder');
		var imgCar = document.getElementById('img_car');
		divError.innerHTML = '';
		divErrorHolder.style.display = 'none';
		imgCar.src = "upload/photos/thumbs/"+document.getElementById('hidden_photos'+carId).value;
		document.getElementById('div_price').style.display = 'block';
	}
	else
	{
		document.getElementById('div_price').style.display = 'none';
	}
}

//Reservation form - Show Airport CB if present
function location_change(type,dumb)
{
	
	if(type==0)
	{
		//pickup
		var dv = document.getElementById('div_cb_airport_pickup');
		var L = document.getElementById('select_location_pickup');
		var cb = document.getElementById('cb_airport_pickup');
		var A = document.getElementById('input_address_pickup');
		var city = document.getElementById('div_city_pickup');
		var city_input = document.getElementById('input_city_pickup');
	}
	else
	{
		//dropoff
		var dv = document.getElementById('div_cb_airport_dropoff');
		var L = document.getElementById('select_location_dropoff');
		var cb = document.getElementById('cb_airport_dropoff');
		var A = document.getElementById('input_address_dropoff');
		var city = document.getElementById('div_city_dropoff');
		var city_input = document.getElementById('input_city_dropoff');
	}
	if(airport_locations[L.selectedIndex]==1)
	{
		dv.style.display='block';
		cb.checked=false;
	}
	else
	{
		dv.style.display='none';
		cb.checked=false;
	}
	if(L.selectedIndex!=78)
		A.value="";
	else
		A.value = adrTM;
	if(L.selectedIndex!=85)
	{
		city_input.value="";
		city.style.display="none";
	}
	else
	{
		city.style.display="block";
		city_input.value="";
	}
}

//Reservation form - Clear address when airport is checked
function airport_checked(type)
{
	
	if(type==0)
	{
		//pickup
		var A = document.getElementById('input_address_pickup');
		var cb = document.getElementById('cb_airport_pickup');
	}
	else
	{
		//dropoff
		var A = document.getElementById('input_address_dropoff');
		var cb = document.getElementById('cb_airport_dropoff');
	}
	if(cb.checked==true)
		A.value="";
}

//Reservation form - Validation for price calculation (without alerts)
function validate_reservation_simple()
{

	//Car type
	if(document.getElementById('select_car').value=="0")
		return false;
	//Dates
	var date_pickup;
	date_pickup=document.getElementById("select_day_pickup").options[document.getElementById("select_day_pickup").selectedIndex].value;
	date_pickup+="/";
	date_pickup+=document.getElementById("select_month_pickup").options[document.getElementById("select_month_pickup").selectedIndex].value;
	date_pickup+="/";
	date_pickup+=document.getElementById("select_year_pickup").options[document.getElementById("select_year_pickup").selectedIndex].value;
	if(check_date_str(date_pickup)==false)
		return false;
	//Reset package restrictions
	document.getElementById("select_year_dropoff").disabled = false;
	document.getElementById("select_month_dropoff").disabled = false;
	document.getElementById("select_day_dropoff").disabled = false;
	document.getElementById("select_time_pickup").disabled = false;
	document.getElementById("select_min_pickup").disabled =false;
	document.getElementById("select_time_dropoff").disabled = false;
	document.getElementById("select_min_dropoff").disabled = false;
	var dvErrPickup = document.getElementById("div_error_pickup");
	dvErrPickup.style.display='none';
	//Set package restrictions
	var selPackage = document.getElementById("select_package").options[document.getElementById("select_package").selectedIndex].value;
	if(selPackage=="1")
	{
		//weekend
		var date_pickupD = new Date(document.getElementById("select_year_pickup").options[document.getElementById("select_year_pickup").selectedIndex].value,document.getElementById("select_month_pickup").options[document.getElementById("select_month_pickup").selectedIndex].value-1,document.getElementById("select_day_pickup").options[document.getElementById("select_day_pickup").selectedIndex].value)
		var day_pickup =  date_pickupD.getDay();	
		//calculate default dropoff date
		var date_dropoffNew  = date_pickupD;
		date_dropoffNew.setDate(date_pickupD.getDate()+3);
		document.getElementById("select_year_dropoff").selectedIndex = year_values[date_dropoffNew.getFullYear()];
		document.getElementById("select_month_dropoff").selectedIndex = date_dropoffNew.getMonth();
		document.getElementById("select_day_dropoff").selectedIndex = date_dropoffNew.getDate()-1;
		document.getElementById("select_year_dropoff").disabled = true;
		document.getElementById("select_month_dropoff").disabled = true;
		document.getElementById("select_day_dropoff").disabled = true;
		document.getElementById("select_time_pickup").selectedIndex = 12;
		document.getElementById("select_min_pickup").selectedIndex = 0;
		document.getElementById("select_time_dropoff").selectedIndex = 9;
		document.getElementById("select_min_dropoff").selectedIndex = 0;
		document.getElementById("select_time_pickup").disabled = true;
		document.getElementById("select_min_pickup").disabled = true;
		document.getElementById("select_time_dropoff").disabled = true;
		document.getElementById("select_min_dropoff").disabled = true;
		//test if is Friday
		if(day_pickup!=5)
		{
			dvErrPickup.style.display='block';
			return false;
		}
	}
	if(selPackage=="2")
	{
		//calculate default dropoff date
		var date_pickupD = new Date(document.getElementById("select_year_pickup").options[document.getElementById("select_year_pickup").selectedIndex].value,document.getElementById("select_month_pickup").options[document.getElementById("select_month_pickup").selectedIndex].value-1,document.getElementById("select_day_pickup").options[document.getElementById("select_day_pickup").selectedIndex].value)
		var date_dropoffNew  = date_pickupD;
		date_dropoffNew.setDate(date_pickupD.getDate()+10);
		document.getElementById("select_year_dropoff").selectedIndex = year_values[date_dropoffNew.getFullYear()];
		document.getElementById("select_month_dropoff").selectedIndex = date_dropoffNew.getMonth();
		document.getElementById("select_day_dropoff").selectedIndex = date_dropoffNew.getDate()-1;
		document.getElementById("select_year_dropoff").disabled = true;
		document.getElementById("select_month_dropoff").disabled = true;
		document.getElementById("select_day_dropoff").disabled = true;
	}
	if(selPackage=="3")
	{
		//calculate default dropoff date
		var date_pickupD = new Date(document.getElementById("select_year_pickup").options[document.getElementById("select_year_pickup").selectedIndex].value,document.getElementById("select_month_pickup").options[document.getElementById("select_month_pickup").selectedIndex].value-1,document.getElementById("select_day_pickup").options[document.getElementById("select_day_pickup").selectedIndex].value)
		var date_dropoffNew  = date_pickupD;
		date_dropoffNew.setDate(date_pickupD.getDate()+30);
		document.getElementById("select_year_dropoff").selectedIndex = year_values[date_dropoffNew.getFullYear()];
		document.getElementById("select_month_dropoff").selectedIndex = date_dropoffNew.getMonth();
		document.getElementById("select_day_dropoff").selectedIndex = date_dropoffNew.getDate()-1;
	}
	var date_dropoff;
	date_dropoff=document.getElementById("select_day_dropoff").options[document.getElementById("select_day_dropoff").selectedIndex].value;
	date_dropoff+="/";
	date_dropoff+=document.getElementById("select_month_dropoff").options[document.getElementById("select_month_dropoff").selectedIndex].value;
	date_dropoff+="/";
	date_dropoff+=document.getElementById("select_year_dropoff").options[document.getElementById("select_year_dropoff").selectedIndex].value;
	if(!check_date_str(date_dropoff))
		return false;
	var l_dt = new Date();
	
	var today = Date.UTC( l_dt.getFullYear(), l_dt.getMonth()+1, l_dt.getDate(),l_dt.getHours(),l_dt.getMinutes(),0);
	time_pickup=document.getElementById("select_time_pickup").options[document.getElementById("select_time_pickup").selectedIndex].value;
	time_dropoff=document.getElementById("select_time_dropoff").options[document.getElementById("select_time_dropoff").selectedIndex].value;
	if(today>=formatDateJS(date_pickup,time_pickup))
		return false;
	if(today>=formatDateJS(date_dropoff,time_dropoff))
		return false;
	if(formatDateJS(date_pickup,time_pickup)>=formatDateJS(date_dropoff,time_dropoff))
		return false;
	//Package restrictions
	if(selPackage!="0")
	{
		var date_pickup = new Date(document.getElementById("select_year_pickup").options[document.getElementById("select_year_pickup").selectedIndex].value,document.getElementById("select_month_pickup").options[document.getElementById("select_month_pickup").selectedIndex].value-1,document.getElementById("select_day_pickup").options[document.getElementById("select_day_pickup").selectedIndex].value)
		var date_dropoff = new Date(document.getElementById("select_year_dropoff").options[document.getElementById("select_year_dropoff").selectedIndex].value,document.getElementById("select_month_dropoff").options[document.getElementById("select_month_dropoff").selectedIndex].value-1,document.getElementById("select_day_dropoff").options[document.getElementById("select_day_dropoff").selectedIndex].value)
		var one_day=1000*60*60*24;
		var days = Math.ceil(date_dropoff.getTime()-date_pickup.getTime())/one_day;
		switch(selPackage)
		{
			/*
			case "1":
			{
				if(days!=3)
					return false;
				else
				{
					var day_pickup =  date_pickup.getDay();	
					var day_dropoff =  date_dropoff.getDay();
					if((day_pickup!=5)||(day_dropoff!=1))
						return false;
					else
					{
						if((time_pickup<12)||(time_dropoff>=9))	
							return false;         
					}
				}
				break;
			}
			case "2":
			{
				if(days!=10)
					return false;
				break;
			}
			*/
			case "3":
			{
				if(days<30)
					return false;
				break;
			}
		}
	}
	//Location
	other_location_pickup=document.getElementById("select_location_pickup").options[document.getElementById("select_location_pickup").selectedIndex].value;
	other_location_dropoff=document.getElementById("select_location_dropoff").options[document.getElementById("select_location_dropoff").selectedIndex].value;
	city_location_pickup = document.getElementById("input_city_pickup").value;
	city_location_dropoff = document.getElementById("input_city_dropoff").value;
	if((other_location_pickup==0)||((other_location_pickup==85)&&(city_location_pickup=="")))
		return false;
	if((other_location_dropoff==0)||((other_location_dropoff==85)&&(city_location_dropoff=="")))
		return false;
	return true;
}

//Check/uncheck checkbox for an extra when clicking label + recalculate total price
function check_extras(no)
{
	if(document.getElementById("cb_extras"+no).checked  == true)
		document.getElementById("cb_extras"+no).checked  = false;
	else
		document.getElementById("cb_extras"+no).checked  = true;
	calculate_price();
}
//Hide CNP for countries diferent from Romania
function change_country(ind)
{
	if(ind!=201)
		document.getElementById('tr_cnp').style.display = 'none';
	else
	{
		if(testIE6())
			document.getElementById('tr_cnp').style.display = 'block';
		else
			document.getElementById('tr_cnp').style.display = 'table-row';
	}
}
function eliminatePrice(str)
{
	return str.substring(0,str.indexOf(" ("));
}
//Validate Reservation Form and display alerts
function validate_reservation()
{
	var divError = document.getElementById('div_error');
	var divErrorHolder = document.getElementById('div_error_holder');
	//Car type
	if(document.getElementById('select_car').value=="0")
	{
		divError.innerHTML = err_required_car;
		divErrorHolder.style.display = 'block';
		window.scrollTo(0,0);
		return false;
	}
	//Dates
	var date_pickup;
	date_pickup=document.getElementById("select_day_pickup").options[document.getElementById("select_day_pickup").selectedIndex].value;
	date_pickup+="/";
	date_pickup+=document.getElementById("select_month_pickup").options[document.getElementById("select_month_pickup").selectedIndex].value;
	date_pickup+="/";
	date_pickup+=document.getElementById("select_year_pickup").options[document.getElementById("select_year_pickup").selectedIndex].value;
	if(check_date_str(date_pickup)==false)
	{
		divError.innerHTML = err_time_pickup;
		divErrorHolder.style.display = 'block';
		window.scrollTo(0,0);
		return false;
	}
	var date_dropoff;
	date_dropoff=document.getElementById("select_day_dropoff").options[document.getElementById("select_day_dropoff").selectedIndex].value;
	date_dropoff+="/";
	date_dropoff+=document.getElementById("select_month_dropoff").options[document.getElementById("select_month_dropoff").selectedIndex].value;
	date_dropoff+="/";
	date_dropoff+=document.getElementById("select_year_dropoff").options[document.getElementById("select_year_dropoff").selectedIndex].value;
	if(!check_date_str(date_dropoff))
	{
		divError.innerHTML=err_time_dropoff;
		divErrorHolder.style.display = 'block';
		window.scrollTo(0,0);
		return false;
	}
	var l_dt = new Date();
	var today = Date.UTC( l_dt.getFullYear(), l_dt.getMonth()+1, l_dt.getDate(),l_dt.getHours(),l_dt.getMinutes(),0);
	time_pickup=document.getElementById("select_time_pickup").options[document.getElementById("select_time_pickup").selectedIndex].value;
	time_dropoff=document.getElementById("select_time_dropoff").options[document.getElementById("select_time_dropoff").selectedIndex].value;
	if(today>=formatDateJS(date_pickup,time_pickup))
	{
		divError.innerHTML=err_time_pickup_today;
		divErrorHolder.style.display = 'block';
		window.scrollTo(0,0);
		return false;
	}
	if(today>=formatDateJS(date_dropoff,time_dropoff))
	{
		divError.innerHTML=err_time_dropoff_today;
		divErrorHolder.style.display = 'block';
		window.scrollTo(0,0);
		return false;
	}
	if(formatDateJS(date_pickup,time_pickup)>=formatDateJS(date_dropoff,time_dropoff))
	{
		divError.innerHTML=err_time_missmatch;
		divErrorHolder.style.display = 'block';
		window.scrollTo(0,0);
		return false;
	}
	//Package restrictions
	var selPackage = document.getElementById("select_package").options[document.getElementById("select_package").selectedIndex].value;
	if(selPackage!="0")
	{
		var date_pickup = new Date(document.getElementById("select_year_pickup").options[document.getElementById("select_year_pickup").selectedIndex].value,document.getElementById("select_month_pickup").options[document.getElementById("select_month_pickup").selectedIndex].value-1,document.getElementById("select_day_pickup").options[document.getElementById("select_day_pickup").selectedIndex].value)
		var date_dropoff = new Date(document.getElementById("select_year_dropoff").options[document.getElementById("select_year_dropoff").selectedIndex].value,document.getElementById("select_month_dropoff").options[document.getElementById("select_month_dropoff").selectedIndex].value-1,document.getElementById("select_day_dropoff").options[document.getElementById("select_day_dropoff").selectedIndex].value)
		var one_day=1000*60*60*24;
		var days = Math.ceil(date_dropoff.getTime()-date_pickup.getTime())/one_day;
		switch(selPackage)
		{
			case "1":
			{
				if(days!=3)
				{
					divError.innerHTML=error_package+packages_tooltip[1];
					divErrorHolder.style.display = 'block';
					window.scrollTo(0,0);
					return false;
				}
				else
				{
					var day_pickup =  date_pickup.getDay();	
					var day_dropoff =  date_dropoff.getDay();
					if((day_pickup!=5)||(day_dropoff!=1))
					{
						divError.innerHTML=error_package+packages_tooltip[1];
						divErrorHolder.style.display = 'block';
						window.scrollTo(0,0);
						return false;
					}
				}
				break;
			}
			case "2":
			{
				if(days!=10)
				{
					divError.innerHTML=error_package+packages_tooltip[2];
					divErrorHolder.style.display = 'block';
					window.scrollTo(0,0);
					return false;
				}
				break;
			}
			case "3":
			{
				if(days<30)
				{
					divError.innerHTML=error_package+packages_tooltip[3];
					divErrorHolder.style.display = 'block';
					window.scrollTo(0,0);
					return false;
				}
				break;
			}
		}
	}
	//Location
	other_location_pickup=document.getElementById("select_location_pickup").options[document.getElementById("select_location_pickup").selectedIndex].value;
	other_location_dropoff=document.getElementById("select_location_dropoff").options[document.getElementById("select_location_dropoff").selectedIndex].value;
	city_location_pickup = document.getElementById("input_city_pickup").value;
	city_location_dropoff = document.getElementById("input_city_dropoff").value;
	if((other_location_pickup==0)||((other_location_pickup==85)&&(city_location_pickup=="")))
	{
		divError.innerHTML=err_location_pickup;
		divErrorHolder.style.display = 'block';
		window.scrollTo(0,0);
		return false;
	}
	if((other_location_dropoff==0)||((other_location_dropoff==85)&&(city_location_dropoff=="")))
	{
		divError.innerHTML=err_location_dropoff;
		divErrorHolder.style.display = 'block';
		window.scrollTo(0,0);
		return false;
	}
	//Contact details
	name = trim(document.getElementById('input_name').value);
	surname = trim(document.getElementById('input_surname').value);
	mail = trim(document.getElementById('input_mail').value);
	city = trim(document.getElementById('input_city').value);
	phone = trim(document.getElementById('input_phone').value);
	cnp = trim(document.getElementById('input_cnp').value);
	id = trim(document.getElementById('input_id').value);
	country = document.getElementById('select_country').value;
	document.getElementById('input_voucher').value = trim(document.getElementById('input_voucher').value);
	if((name=="")||(surname=="")||(mail=="")||(city=="")||(phone=="")||(id=="")||((country=="201")&&(cnp=="")))
	{
		divError.innerHTML=contact_error;
		divErrorHolder.style.display = 'block';
		window.scrollTo(0,0);
		return false;
	}
	if(!check_mail(mail))
	{
		divError.innerHTML=err_invalid_mail;
		divErrorHolder.style.display = 'block';
		window.scrollTo(0,0);
		return false;
	}
	if(!check_phoneNo(phone))
	{
		divError.innerHTML=err_invalid_phone;
		divErrorHolder.style.display = 'block';
		window.scrollTo(0,0);
		return false;
	}
	if(country=="201")
	{
		if(!check_CNP(cnp))
		{
			divError.innerHTML=err_invalid_cnp;
			divErrorHolder.style.display = 'block';
			window.scrollTo(0,0);
			return false;
		}
	}
	if(document.getElementById('cb_terms').checked==false)
	{
		divError.innerHTML=err_required_terms;
		divErrorHolder.style.display = 'block';
		window.scrollTo(0,0);
		return false;
	}
	return true;
}

//Calculate total price for selected date
function calculate_price()
{
	if(validate_reservation_simple())
	{
		var p=0;
		var info_text = "";
		//calculate car price
		var carId = document.getElementById('select_car').value;
		var price_values = document.getElementById('hidden_prices'+carId).value.split(";");
		var date_pickup = new Date(document.getElementById("select_year_pickup").options[document.getElementById("select_year_pickup").selectedIndex].value,document.getElementById("select_month_pickup").options[document.getElementById("select_month_pickup").selectedIndex].value-1,document.getElementById("select_day_pickup").options[document.getElementById("select_day_pickup").selectedIndex].value)
		var date_dropoff = new Date(document.getElementById("select_year_dropoff").options[document.getElementById("select_year_dropoff").selectedIndex].value,document.getElementById("select_month_dropoff").options[document.getElementById("select_month_dropoff").selectedIndex].value-1,document.getElementById("select_day_dropoff").options[document.getElementById("select_day_dropoff").selectedIndex].value)
		var one_day=1000*60*60*24;
		var days = Math.ceil(Math.ceil(date_dropoff.getTime()-date_pickup.getTime())/one_day);
		var p_unit = 0;
		var dates_equal = 0;
		var selPackage = document.getElementById("select_package").options[document.getElementById("select_package").selectedIndex].value;
		if(days==0)
		{
			days++;
			dates_equal=1;
		}
		if(days==1)
			days_text = cars_day;
		else
			days_text = cars_days;
		if(selPackage=="0")
		{
			if(days<=4)
			{
				if(price_values[0]!="-")
				{
					p=days*price_values[0];
					info_text = "&bull;&nbsp;<u>"+total_car_price+"</u>: "+days+" "+days_text+" * "+price_values[0]+" Euro = "+p+" Euro";
					p_unit = price_values[0];
				}
			}
			if(days>=5 && days<=7)
			{
				if(price_values[1]!="-")
				{
					p=days*price_values[1];
					info_text = "&bull;&nbsp;<u>"+total_car_price+"</u>: "+days+" "+days_text+" * "+price_values[1]+" Euro = "+p+" Euro";
					p_unit = price_values[1];
				}
			}
			if(days>=8 && days<=14)
			{
				if(price_values[2]!="-")
				{
					p=days*price_values[2];
					info_text = "&bull;&nbsp;<u>"+total_car_price+"</u>: "+days+" "+days_text+" * "+price_values[2]+" Euro = "+p+" Euro";
					p_unit = price_values[2];
				}
			}
			if(days>=15 && days<=30)
			{
				if(price_values[3]!="-")
				{
					p=days*price_values[3];
					info_text = "&bull;&nbsp;<u>"+total_car_price+"</u>: "+days+" "+days_text+" * "+price_values[3]+" Euro = "+p+" Euro";
					p_unit = price_values[3];
				}
			}
		}
		//if(days>30)
			//p=0;
		else
		{
			//Package prices
			switch(selPackage)
			{
				case "1":
				{
					if(price_values[4]!="-")
					{
						p=days*price_values[4];
						info_text = "&bull;&nbsp;<u>"+total_car_price+"</u>: "+days+" "+days_text+" * "+price_values[4]+" Euro = "+p+" Euro";
						p_unit = price_values[4];
					}
					break;
				}
				case "2":
				{
					if(price_values[5]!="-")
					{
						p=days*price_values[5];
						info_text = "&bull;&nbsp;<u>"+total_car_price+"</u>: "+days+" "+days_text+" * "+price_values[5]+" Euro = "+p+" Euro";
						p_unit = price_values[5];
					}
					break;
				}
				case "3":
				{
					if(price_values[6]!="-")
					{
						p=days*price_values[6];
						info_text = "&bull;&nbsp;<u>"+total_car_price+"</u>: "+days+" "+days_text+" * "+price_values[6]+" Euro = "+p+" Euro";
						p_unit = price_values[6];
					}
					break;
				}
			}
		}
		if(p!=0)
		{
			//add extras
			if(document.getElementById('cb_extras1').checked==true)
			{
				p=p+days*50;
				info_text += "<br/>&bull;&nbsp;<u>"+eliminatePrice(extras[1])+"</u>: "+days+" "+days_text+" * 50 Euro = "+days*50+" Euro";
			}
			if(document.getElementById('cb_extras2').checked==true)
			{
				if(days<=10)
				{
					p=p+days*5;
					info_text += "<br/>&bull;&nbsp;<u>"+eliminatePrice(extras[2])+"</u>: "+days+" "+days_text+" * 5 Euro = "+days*5+" Euro";
				}
				else
				{
					p=p+50;
					info_text += "<br/>&bull;&nbsp;<u>"+eliminatePrice(extras[2])+"</u>: 50 Euro(max)";
				}
			}
			if(document.getElementById('cb_extras3').checked==true)
			{
				if(days<=10)
				{
					p=p+days*3;
					info_text += "<br/>&bull;&nbsp;<u>"+eliminatePrice(extras[3])+"</u>: "+days+" "+days_text+" * 3 Euro = "+days*3+" Euro";
				}
				else
				{
					p=p+30;
					info_text += "<br/>&bull;&nbsp;<u>"+eliminatePrice(extras[3])+"</u>: 30 Euro(max)";
				}
			}
			if(document.getElementById('cb_extras4').checked==true)
			{
				if(days<=10)
				{
					p=p+days*3;
					info_text += "<br/>&bull;&nbsp;<u>"+eliminatePrice(extras[4])+"</u>: "+days+" "+days_text+" * 3 Euro = "+days*3+" Euro";
				}
				else
				{
					p=p+30;
					info_text += "<br/>&bull;&nbsp;<u>"+eliminatePrice(extras[4])+"</u>: 30 Euro(max)";
				}
			}
			if(document.getElementById('cb_extras5').checked==true)
			{
				if(days<=10)
				{
					p=p+days*3;
					info_text += "<br/>&bull;&nbsp;<u>"+eliminatePrice(extras[5])+"</u>: "+days+" "+days_text+" * 5 Euro = "+days*5+" Euro";
				}
				else
				{
					p=p+30;
					info_text += "<br/>&bull;&nbsp;<u>"+eliminatePrice(extras[5])+"</u>: 50 Euro(max)";
				}
			}
			//add mentions charges
			time_pickup=document.getElementById("select_time_pickup").options[document.getElementById("select_time_pickup").selectedIndex].value;
			time_dropoff=document.getElementById("select_time_dropoff").options[document.getElementById("select_time_dropoff").selectedIndex].value;
			//night
			var n1=0;
			var n2=0;
			if(selPackage!="3")
			{
				if((time_pickup>0)&&(time_pickup<6))
				{
					p=p+20;
					n1=1;
					document.getElementById('a_mention1').style.color="#35A711";
					document.getElementById('a_mention2').style.color="#35A711";
					document.getElementById('hidden_mention1').value="1";
					document.getElementById('hidden_mention2').value="1";
					document.getElementById('cb_mention1').checked=true;
					document.getElementById('cb_mention2').checked=true;
					info_text += "<br/>&bull;&nbsp;<u>"+eliminatePrice(mentions[1])+"</u>: 10 Euro";
					info_text += "<br/>&bull;&nbsp;<u>"+eliminatePrice(mentions[2])+"</u>: 10 Euro";
				}
				else
				{
					document.getElementById('a_mention2').style.color="#35A711";
					document.getElementById('a_mention1').style.color="#35A711";
					document.getElementById('hidden_mention1').value="0";
					document.getElementById('hidden_mention2').value="0";
					document.getElementById('cb_mention1').checked=false;
					document.getElementById('cb_mention2').checked=false;
				}
				if((time_dropoff>0)&&(time_dropoff<6))
				{
					p=p+20;
					n2=1;
					document.getElementById('a_mention3').style.color="#35A711";
					document.getElementById('a_mention4').style.color="#35A711";
					document.getElementById('hidden_mention3').value="1";
					document.getElementById('hidden_mention4').value="1";
					document.getElementById('cb_mention3').checked=true;
					document.getElementById('cb_mention4').checked=true;
					info_text += "<br/>&bull;&nbsp;<u>"+eliminatePrice(mentions[3])+"</u>: 10 Euro";
					info_text += "<br/>&bull;&nbsp;<u>"+eliminatePrice(mentions[4])+"</u>: 10 Euro";
				}
				else
				{
					document.getElementById('a_mention4').style.color="#35A711";
					document.getElementById('a_mention3').style.color="#35A711";
					document.getElementById('hidden_mention3').value="0";
					document.getElementById('hidden_mention4').value="0";
					document.getElementById('cb_mention3').checked=false;
					document.getElementById('cb_mention4').checked=false;
				}
				if((((time_pickup>20)||(time_pickup<8)))&&(n1==0))
				{
					p=p+10;
					document.getElementById('a_mention1').style.color="#35A711";
					info_text += "<br/>&bull;&nbsp;<u>"+eliminatePrice(mentions[1])+"</u>: 10 Euro";
					document.getElementById('hidden_mention1').value="1";
					document.getElementById('cb_mention1').checked=true;
				}
				else
				{
					if(n1==0)
					{
						document.getElementById('a_mention1').style.color="#35A711";
						document.getElementById('hidden_mention1').value="0";
						document.getElementById('cb_mention1').checked=false;
					}
				}
				if((((time_dropoff>20)||(time_dropoff<8)))&&(n2==0))
				{
					p=p+10;
					document.getElementById('a_mention3').style.color="#35A711";
					info_text += "<br/>&bull;&nbsp;<u>"+eliminatePrice(mentions[3])+"</u>: 10 Euro";
					document.getElementById('hidden_mention3').value="1";
					document.getElementById('cb_mention3').checked=true;
				}
				else
				{
					if(n2==0)
					{
						document.getElementById('a_mention3').style.color="#35A711";
						document.getElementById('hidden_mention3').value="0";
						document.getElementById('cb_mention3').checked=false;
					}	
				}
				//pickup time < dropof time
				if(selPackage!="1")
				{
					if((dates_equal==0)&&(time_dropoff*1>time_pickup*1))
					{
						document.getElementById('a_mention8').style.color="#35A711";
						document.getElementById('hidden_mention8').value="1";
						document.getElementById('cb_mention8').checked=true;
						dif = time_dropoff-time_pickup;
						if(dif>2)
						{
							if(dif<=4)
							{
								p=p+(p_unit/2);
								info_text += "<br/>&bull;&nbsp;<u>"+mentions[8]+"</u>: "+p_unit+"/"+cars_day+"/2 = "+p_unit/2+" Euro";
							}
							else
							{
								p=p+p_unit*1;
								info_text += "<br/>&bull;&nbsp;<u>"+mentions[8]+"</u>: "+p_unit+" Euro/"+cars_day;
							}
						}
					}
					else
					{
						document.getElementById('a_mention8').style.color="#35A711";
						document.getElementById('hidden_mention8').value="0";
						document.getElementById('cb_mention8').checked=false;
					}
				}
			}
			//airport/extra hours
			location_pickup=document.getElementById("cb_airport_pickup").checked;
			location_dropoff=document.getElementById("cb_airport_dropoff").checked;
			if(location_pickup==true)
			{
				p=p+10;
				document.getElementById('a_mention6').style.color="#35A711";
				info_text += "<br/>&bull;&nbsp;<u>"+eliminatePrice(mentions[6])+"</u>: 10 Euro";
				document.getElementById('hidden_mention6').value="1";
				document.getElementById('cb_mention6').checked=true;
			}
			else
			{
				document.getElementById('a_mention6').style.color="#35A711";
				document.getElementById('hidden_mention6').value="0";
				document.getElementById('cb_mention6').checked=false;
			}
			if(location_dropoff==true)
			{
				p=p+10;
				document.getElementById('a_mention7').style.color="#35A711";
				info_text += "<br/>&bull;&nbsp;<u>"+eliminatePrice(mentions[7])+"</u>: 10 Euro";
				document.getElementById('hidden_mention7').value="1";
				document.getElementById('cb_mention7').checked=true;
			}
			else
			{
				document.getElementById('a_mention7').style.color="#35A711";
				document.getElementById('hidden_mention7').value="0";
				document.getElementById('cb_mention7').checked=false;
			}
			//not in Timisoara
			other_location_pickup=document.getElementById("select_location_pickup").options[document.getElementById("select_location_pickup").selectedIndex].value;
			other_location_dropoff=document.getElementById("select_location_dropoff").options[document.getElementById("select_location_dropoff").selectedIndex].value;
			if(((other_location_pickup!=0)&&(other_location_pickup!=78))||((other_location_dropoff!=0)&&(other_location_dropoff!=78)))
			{	
				document.getElementById('a_mention5').style.color="#35A711";
				info_text += "<span style='color:#35A711'><br/>+ "+mentions_tooltip[5]+"</span>";
				document.getElementById('hidden_mention5').value="1";
				document.getElementById('cb_mention5').checked=true;
			}
			else
			{
				document.getElementById('a_mention5').style.color="#35A711";
				document.getElementById('hidden_mention5').value="0";
				document.getElementById('cb_mention5').checked=false;
			}
			info_text += "<span style='color:#35A711'><br/>"+cars_tva+"</span>";
		}
		//display price
		if(p!=0)
		{
			document.getElementById('div_total').innerHTML = p+" Euro/"+days+" "+days_text;
			document.getElementById('cdiv_total_text').innerHTML = info_text;
			document.getElementById('cdiv_total_text').style.color="#35A711";
			document.getElementById('hidden_total').value =  p+" Euro/"+days+" "+days_text;
		}
		else
		{
			document.getElementById('div_total').innerHTML = "---";
			document.getElementById('cdiv_total_text').innerHTML = total_unavailable;
			document.getElementById('cdiv_total_text').style.color="#35A711";
			document.getElementById('hidden_total').value =  "";
		}
	}
	else
	{
		//validation failed -> cannot calculate price
		document.getElementById('div_total').innerHTML = "---";
		document.getElementById('a_mention1').style.color="#35A711";
		document.getElementById('a_mention2').style.color="#35A711";
		document.getElementById('a_mention3').style.color="#35A711";
		document.getElementById('a_mention4').style.color="#35A711";
		document.getElementById('a_mention5').style.color="#35A711";
		document.getElementById('a_mention6').style.color="#35A711";
		document.getElementById('a_mention7').style.color="#35A711";
		document.getElementById('a_mention8').style.color="#35A711";
		document.getElementById('hidden_mention1').value="0";
		document.getElementById('hidden_mention2').value="0";
		document.getElementById('hidden_mention3').value="0";
		document.getElementById('hidden_mention4').value="0";
		document.getElementById('hidden_mention5').value="0";
		document.getElementById('hidden_mention6').value="0";
		document.getElementById('hidden_mention7').value="0";
		document.getElementById('hidden_mention8').value="0";
		document.getElementById('cb_mention1').checked=false;
		document.getElementById('cb_mention2').checked=false;
		document.getElementById('cb_mention3').checked=false;
		document.getElementById('cb_mention4').checked=false;
		document.getElementById('cb_mention5').checked=false;
		document.getElementById('cb_mention6').checked=false;
		document.getElementById('cb_mention7').checked=false;
		document.getElementById('cb_mention8').checked=false;
		document.getElementById('cdiv_total_text').innerHTML = total_invalid;
		document.getElementById('cdiv_total_text').style.color="#35A711";
		document.getElementById('hidden_total').value =  "";
	}
}
var crt = new Array;
crt[1] = 1;
crt[2] = 1;
crt[3] = 1;
function changePackage(dir,type)
{
	var priceInfo;
	var photoInfo;
	crt[type] = crt[type] + dir;
	if(crt[type]==0)
		crt[type] = no[type];
	if(crt[type]==no[type]+1)
		crt[type]=1;
	switch(type)
	{
		case 1:
		{
			aInfo = pWE[crt[type]].split(";");
			break;
		}
		case 2:
		{
			aInfo = pVA[crt[type]].split(";");
			break;
		}
		case 3:
		{
			aInfo = pBU[crt[type]].split(";");
			break;
		}
	}
	priceInfo = aInfo[0];
	photoInfo = aInfo[1];
	idInfo = aInfo[2];
	var imgP = document.getElementById("img_package"+type);
	var labelP = document.getElementById("label_package"+type);
	var aP = document.getElementById("a_package"+type);
	var aC = document.getElementById("a_car"+type);
	labelP.innerHTML = priceInfo;
	imgP.src = "upload/photos/thumbs/"+photoInfo;
	aP.href ="book.php?package="+type+"&car="+idInfo;
	aC.href ="cars.php?car="+idInfo;
}
function gotoBookCar()
{
	var selCars = document.getElementById('select_cars_short');
	var carId = selCars.options[selCars.selectedIndex].value;
	var strTo ="";
	if(carId!=0)
		strTo = "?car="+carId;
	document.location="book.php"+strTo;
}
function menuOver(no,crt,obj,lg)
{
	if(no!=crt)
	{
		obj.src = "images/"+lg+"/menu"+no+"_sel.jpg";
		var imgSh = document.getElementById("img_menu"+no+"_sh");
		imgSh.src = "images/"+lg+"/menu"+no+"_sh_sel.jpg";
	}
}
function menuOut(no,crt,obj,lg)
{
	if(no!=crt)
	{
		obj.src = "images/"+lg+"/menu"+no+".jpg";
		var imgSh = document.getElementById("img_menu"+no+"_sh");
		imgSh.src = "images/"+lg+"/menu"+no+"_sh.jpg";
	}
}
function submitSubscribe(act)
{
	var hAct = document.getElementById('hidden_newsletter');
	hAct.value = act;
	if(validate_newsletter()==true)
		document.getElementById('form_newsletter').submit();
}
function ch_lg(language,method)
{
	
	if( method != "")
	{
		document.changeC.lang.value = language;
		document.changeC.submit();
	}
}
function validate_register()
{
	var divError = document.getElementById('div_error');
	username = trim(document.getElementById('input_username').value);
	password = trim(document.getElementById('input_password').value);
	name = trim(document.getElementById('input_name').value);
	surname = trim(document.getElementById('input_surname').value);
	mail = trim(document.getElementById('input_mail').value);
	city = trim(document.getElementById('input_city').value);
	phone = trim(document.getElementById('input_phone').value);
	cnp = trim(document.getElementById('input_cnp').value);
	id = trim(document.getElementById('input_id').value);
	country = document.getElementById('select_country').value;
	code = trim(document.getElementById('input_code').value);
	if((username=="")||(password=="")||(name=="")||(surname=="")||(mail=="")||(city=="")||(phone=="")||(id=="")||(code=="")||((country=="201")&&(cnp=="")))
	{
		divError.innerHTML=contact_error;
		window.scrollTo(0,0);
		return false;
	}
	if(!check_mail(mail))
	{
		divError.innerHTML=err_invalid_mail;
		window.scrollTo(0,0);
		return false;
	}
	if(!check_phoneNo(phone))
	{
		divError.innerHTML=err_invalid_phone;
		window.scrollTo(0,0);
		return false;
	}
	if(country=="201")
	{
		if(!check_CNP(cnp))
		{
			divError.innerHTML=err_invalid_cnp;
			window.scrollTo(0,0);
			return false;
		}
	}
	return true;
}
