var screen_res = "1280x800";
var WRInitTime=(new Date()).getTime();

function clickclear(thisfield, defaulttext) {
  if (thisfield.value == defaulttext) {
    thisfield.value = "";
	$("#comment").css("color", "#3F3E3E");
	$("#comment").css("font-size", "14px");

  }
}

function clickrecall(thisfield, defaulttext) {
  if (thisfield.value == "") {
   thisfield.value = defaulttext;
   $("#comment").css("color", "#9F9F9F"); 
  }
}


/*		$(document).ready(function() {			
			
			$("#contact").validate({
												
				submitHandler:function(form) {
					SubmittingForm();
				},
				rules: {
					name: {
						required:true,
						minlength: 3					
					},
					phone: {
						required:true, 
						minlength: 4
					},
					load_country_id:{
						required:true
					},
					land_country_id:{
						required:true
					},
					load_province_id:{
						required:true
					},
					land_province_id:{
						required:true
					}

				},
				messages: {
					name:{
						required: "Pole Imie jest wymagane",
						minlength: jQuery.format("Wpisz przynajmniej {0} znakow")		
					},
					phone:{
						required: "Pole Telefon jest wymagane",
						digits: "Wpisz poprawny numer telefonu", 
						minlength: jQuery.format("Wpisz przynajmniej {0} znakow")		
					},
					load_country_id:{
						required: "Wybierz kraj"
					},
					land_country_id:{
						required: "Wybierz kraj"
					},
					load_province_id:{
						required: "Wybierz region"
					},
					land_province_id:{
						required: "Wybierz region"
					}
				}
			});
		});
		

$("#contact").validate({
  highlight: function(element, errorClass) {
     $(element).addClass(errorClass);
     $(element.form).find("label[for=" + element.id + "]")
                    .addClass(errorClass);
  },
  unhighlight: function(element, errorClass) {
     $(element).removeClass(errorClass);
     $(element.form).find("label[for=" + element.id + "]")
                    .removeClass(errorClass);
  }
});

jQuery.validator.addMethod(
	"selectNone",
	function(value, element) {
		if (element.value == "none")
		{
			return false;
		}
		else return true;
	},
	"Please select an option."
);*/


function getXMLHTTP() { //fuction to return the xml http object
		var xmlhttp=false;	
		try{
			xmlhttp=new XMLHttpRequest();
		}
		catch(e)	{		
			try{			
				xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e){
				try{
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
				}
				catch(e1){
					xmlhttp=false;
				}
			}
		}
		 	
		return xmlhttp;
    }
	
	function getState(countryId, provinceId, cityName, dr) {		
		
		var strURL="findState.php?country="+countryId+"&province="+provinceId+"&city="+cityName+"&dr="+dr;
		var req = getXMLHTTP();
		
		if (countryId == "")
		{
			$('label[for=load_country_id]').show();
			$('#statediv *').remove();
			$('#citydiv *').remove();
		} else {
			if (countryId != "1")
			{
				$('#citydiv *').remove();
			}
			$('label[for=load_country_id]').hide();
		}
		if (req && countryId != "") {
			

			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('statediv').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
	}
	function getCity(countryId, stateId, cityId, cityName, dr) {		
		var strURL="findCity.php?country="+countryId+"&state="+stateId+"&cityId="+cityId+"&cityName="+cityName+"&dr="+dr;
		var req = getXMLHTTP();
		
		if (stateId == "")
		{
			$('label[for=load_province_id]').show();
			$('#statediv > table').remove();
			$('#citydiv > table').remove();
		} else {
			$('label[for=load_province_id]').hide();
		}

		if (req && stateId != "") {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('citydiv').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
	}


	function getState2(countryId, provinceId, cityName, dr) {
		
		var strURL="findState2.php?country="+countryId+"&province="+provinceId+"&city="+cityName+"&dr="+dr;
		var req = getXMLHTTP();
		
		if (countryId == "")
		{
			$('label[for=land_country_id]').show();
			$('#statediv_2 *').remove();
			$('#citydiv_2 *').remove();
		} else {
			if (countryId != "1")
			{
				$('#citydiv_2 *').remove();
			}
			$('label[for=land_country_id]').hide();
		}

		if (req && countryId != "") {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('statediv_2').innerHTML=req.responseText;
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
	}

	function getCity2(countryId, stateId, cityId, cityName, dr) {
		var strURL="findCity2.php?country="+countryId+"&state="+stateId+"&cityId="+cityId+"&cityName="+cityName+"&dr="+dr;
		var req = getXMLHTTP();
		
		if (stateId == "")
		{
			$('label[for=load_province_id]').show();
			$('#citydiv_2 *').remove();
		} else {
			$('label[for=load_province_id]').hide();
		}

		if (req && stateId != "") {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('citydiv_2').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
	}

  jQuery(document).ready(function() {
  jQuery("#dropmenu ul").css({display: "none"}); // Opera Fix
  jQuery("#dropmenu li").hover(function(){
          jQuery(this).find('ul:first').css({visibility: "visible",display: "none"}).show(268);
          },function(){
          jQuery(this).find('ul:first').css({visibility: "hidden"});
          });
  });

