function trim(value){
  return value.replace(/^\s+|\s+$/,'');
}
function changeLanguage() {
  var language = document.getElementById("languageSelector").value;
  if (language == "turkce") {
  	 window.location = "/";
  }else{
    window.location = "/"+ language +"/";
  }
}
function validateSearchResultsForm(searchForm){
    var errors = "";
    
    errors = validateMandatoryDroplist(searchForm.city, "Pick-up City", errors);
    errors = validateMandatoryDroplist(searchForm.location, "Pick-up Location", errors);
    errors = validateMandatoryDroplist(searchForm.dropCity, "Drop City", errors);
    errors = validateMandatoryDroplist(searchForm.dropLocation, "Drop Location", errors);
  
    if(errors==""){
		searchForm.submit();
        return true;
    } else {
        alert(errors);
        return false;
    }        
}
function rezFormKontrol(searchForm){
    var errors = "";
    
    errors = validateMandatoryDroplist(searchForm.adi, "Name", errors);
    errors = validateMandatoryDroplist(searchForm.soyadi, "Surname", errors);
    errors = validateMandatoryDroplist(searchForm.cepTel, "Mobile", errors);
    errors = validateMandatoryDroplist(searchForm.email, "Email", errors);
  
    if(errors==""){
		searchForm.submit();
        return true;
    } else {
        alert(errors);
        return false;
    }        
}
function girisFormKontrol(searchForm){
    var errors = "";
    
    errors = validateMandatoryDroplist(searchForm.userName, "E-Mail ", errors);
    errors = validateMandatoryDroplist(searchForm.password, "Password  ", errors);
  
    if(errors==""){
		searchForm.submit();
        return true;
    } else {
        alert(errors);
        return false;
    }        
}
function validateMandatoryDroplist(droplist, name,  errors){
    if(droplist.value=="" || droplist.value==0){    
        errors = errors + name + " empty?\n";
    }
    return errors;
}

function isNumeric(sText){
   var validChars  = "0123456789";
   var returnValue = true;
   var currentChar;
 
   for (var i = 0; i < sText.length && returnValue == true; i++) { 
      currentChar = sText.charAt(i); 
      if (validChars.indexOf(currentChar) == -1) {
         returnValue = false;
      }
   }
   return returnValue;
}
function isNumberic(v) {
var isNum = /^[0-9]*$/;
	if (!isNum.test(v.value)) {
		v.value = v.value.replace(/[^0-9]/g,"");
	}
}
function detayCar(carID){
	window.open('detayCar.php?id=' + carID + '','carDetay','height=470,width=500,left=100,top=100,scrollbars=no,toolbar=no,menubar=no,location=no');
}
  function show_address ( whichone ) {
      theaddress=whichone;
      if (theaddress.id=="teslimSartlari") {
         if (document.rezForm.sartlar.value == 1) {
            theaddress.style.display=""
         } else {
            theaddress.style.display="none"
         }
      }
   }
function headingClick(checkbox, options, index){
    var element = document.getElementById(options);
    if(checkbox.checked==true){
        element.style.display='none';
        var i=0;
        while(true){
            var subelem = document.getElementById("optionCB" + index + ":" + i++);
            if(subelem==null || i>100)
                break;
            subelem.checked = false;
        }
    } else {
        element.style.display='';
    }
}

function disableSearchResultsForm(isDisabled){
    if(isDisabled){    
        document.SearchResultsForm.city.disabled=isDisabled;
        document.SearchResultsForm.location.disabled=isDisabled;
        document.SearchResultsForm.dropCity.disabled=isDisabled;
        document.SearchResultsForm.dropLocation.disabled=isDisabled;
    }     
}
function populateDroplists(dropList, serverUrl){
    var debug="";
    if(debug!=""){
        disableSearchResultsForm(false);
    }
    var serverPart = "";
    if(serverUrl!=null){
    	serverPart = serverUrl;
    }
    var dynaURL = serverPart + "/includes/teslimList.php?city=" + document.SearchResultsForm.city.value;
    var ie5dyna = dynaURL;
        if(dropList!="city"){
        dynaURL = dynaURL + "&location=" + document.SearchResultsForm.location.value;
        ie5dyna = ie5dyna + "&location=" + document.SearchResultsForm.location.value;
        	if(dropList!="location"){
                dynaURL = dynaURL + "&dropCity=" + document.SearchResultsForm.dropCity.value;
                ie5dyna = ie5dyna + "&dropCity=" + escape(document.SearchResultsForm.dropCity.value);
                	if(dropList!="dropCity"){
                        dynaURL = dynaURL + "&dropLocation=" + document.SearchResultsForm.dropLocation.value;
                        ie5dyna = ie5dyna + "&dropLocation=" + escape(document.SearchResultsForm.dropLocation.value);
                    }
                }
            }
	var ua = navigator.userAgent;
    var MSIEOffset = ua.indexOf("MSIE ");
    var IEVerNum=6;
    if (MSIEOffset != -1){
	    IEVerNum=parseFloat(ua.substring(MSIEOffset + 5, ua.indexOf(";", MSIEOffset)));
    }
    if (IEVerNum<5.5)
    {
		dynaURL = ie5dyna;
	}
	else
	{
		dynaURL = encodeURI(dynaURL);
	}
    if(debug!=""){    
        dynaURL = dynaURL + "&debug=true";
        alert(dynaURL);    
    }
    document.getElementById("dynaFrame").src = dynaURL;
}     

function makeRequest(url)
{
    var req=false;
    var returnValue = "";
    if(window.XMLHttpRequest) {
     try {
            req = new XMLHttpRequest();
        } catch(e) {
            req = false;
        }
    } else if(window.ActiveXObject) {
        try {
            req = new ActiveXObject("Msxml2.XMLHTTP");
       } catch(e) {
            try {
                req = new ActiveXObject("Microsoft.XMLHTTP");
            } catch(e) {
                req = false;
            }
 }
    }
    if(req){
        req.open("GET", url, false);
        req.send(null);
        if (req.readyState==4) {
            returnValue = req.responseText;            
        }
    }
    return returnValue;
}
    
function addOption(droplist, name, value){
    droplist.options[droplist.options.length] = new Option(name, value);
}

function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function Bekleyiniz(divid)	{
document.getElementById(divid).innerHTML='<img src="/css/img/ctrl.gif" width="16" height="16" alt="" align="left"><img src="/css/img/spacer.gif" width="25" height="1">';
}

function emailCheckEn(formName) {
formName.email.value=formName.email.value.toLowerCase();
var txt = formName.email.value;
 if ((txt.indexOf(" ")!=-1)) {
    alert("Warning! There should be no space in Mail Address!");
    return;
 }
 if ((txt.indexOf("@")==-1)) {
    alert("Warning! You haven't used @ in your Mail Address!");
    return;
 }
 if (txt.indexOf("@")<2) {
    alert("Warning! Please use an extension like .com after @ sign.");
    return;
 }

}
