var table_background_variable ="";
var prefix = "";

var emailUrls = new Array(2);
emailUrls["us"] = "goToEmailForm('R')";
emailUrls["canada"]="http://app01.extra.daimlerchrysler.com/wccs/ca/index_en.jsp";
emailUrls["mexico"]="goToEmailForm('R')";

function doSubmit(screenName){
  
    if(screenName =='us' || screenName=="canada" || screenName=="mexico"){
        country = screenName;
    
   	}
    document.main.screenName.value = screenName;
    document.main.country.value = country;
    document.main.emailUrl.value = emailUrls[country];
    document.main.action = "index.jsp";
    document.main.submit();     

 }
 
function getDomain_local(url) {
  var domain = window.location.href;
  var was5url = "";
  
  if (domain.indexOf( "://uat" ) >= 0) {
	was5url = "http://uat-5.chrysler.com";
  } else if (domain.indexOf( "://test" ) >= 0) {
	was5url = "http://test-5.chrysler.com";
  } else if (domain.indexOf( "://www" ) >= 0) {
  	was5url = "http://www-5.chrysler.com";
  } 
  
  // open the Incentives silo window..
  openExternal(was5url + url); 
}



function openExternal(url){
    newWindow = window.open(url, "newWindow");
    newWindow.focus();
}

    function viewRecall(){
	//alert("Inside ViewRecall() method...");    
	if (validateForm() == false)
	    return;
	//url = "http://clwccs03.cldc.chrysler.com/selfservice/recallinfo.jsp?vin=" + document.recallForm.vin.value;
	//newWindow = window.open(url, "newWIndow");
	//newWindow.focus();
	document.recallForm.action="index.jsp";
	if (emailUrls[country])
	    document.recallForm.emailUrl.value = emailUrls[country];
	else
	     document.recallForm.emailUrl.value = "";
	document.recallForm.country.value = country;
	document.recallForm.submit();
	return;
    }

    function validateForm(){
//    alert("Inside validateForm() method..."); 
	str = trim(document.recallForm.vin.value) + "";
	if (str.length != 8 && str.length != 17){
	    alert("Please enter your valid VIN number.");
	    document.recallForm.vin.focus();
	    return false;
	}
	document.recallForm.vin.value = str.toUpperCase();
//	alert("You entered..."+document.recallForm.vin.value);
	return true;
    }

    function leftTrim(str){
	while(str.length >0){
	    if(str.substring(0, 1)==" ")
		str = str.substring(1);
	    else
		break;
	}
	return str;
    }

    function rightTrim(str){
	while(str.length >0){
	    intLength = str.length;
	    if(str.substring(intLength -1)==" ")
		str = str.substring(0, intLength - 1);
	    else
		break;
	    //alert(str);
	}
	return str;
    }

    function trim(str){
	str = leftTrim(str);
        str = rightTrim(str);
	return str;
    }
 
