
function enterLeads(element1){


var viewportwidth;
		 var viewportheight;

 // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight

 if (typeof window.innerWidth != 'undefined')
 {
      viewportwidth = window.innerWidth,
      viewportheight = window.innerHeight
 }

// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)

 else if (typeof document.documentElement != 'undefined'
     && typeof document.documentElement.clientWidth !=
     'undefined' && document.documentElement.clientWidth != 0)
 {
       viewportwidth = document.documentElement.clientWidth,
       viewportheight = document.documentElement.clientHeight
 }

 // older versions of IE

 else
 {
       viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
       viewportheight = document.getElementsByTagName('body')[0].clientHeight
 }


			element1 = document.getElementById(element1);
		  	 if (element1.style.display == 'block')
			   {
				    element1.style.display = 'none';

			   }

			   else
      			{

			element1.style.display = 'block';
              		 element1.style.position='absolute';
              		 element1.style.left=document.documentElement.scrollLeft + viewportwidth/3+'px';
               		element1.style.top= document.documentElement.scrollTop + viewportheight/4 +'px';

			element1.style.width='340px';
			element1.style.height='200px';

			}
		}

function enterLeadsForUsed(element1,carname,oemName,carVariantId,carDetailUrl,usedCarId,usedCarCity,usedCarUserId,usedCarUserNo,ownerType)
{
	var viewportwidth;
	var viewportheight;
	 // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
	 if (typeof window.innerWidth != 'undefined')
	 {
	      viewportwidth = window.innerWidth,
	      viewportheight = window.innerHeight
	 }
	// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
	 else if (typeof document.documentElement != 'undefined'
	 && typeof document.documentElement.clientWidth !=
     	'undefined' && document.documentElement.clientWidth != 0)
	 {
	       viewportwidth = document.documentElement.clientWidth,
	       viewportheight = document.documentElement.clientHeight
	 }
	 // older versions of IE
	 else
	 {
	       viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
	       viewportheight = document.getElementsByTagName('body')[0].clientHeight
	 }

	//document.write('<p>Your viewport width is '+viewportwidth+'x'+viewportheight+'</p>');
		document.getElementById('carName').value=carname;
		document.getElementById('oemName').value=oemName;
		document.getElementById('popupheaderDiv').innerHTML="Get detail on "+carVariantId;
		document.getElementById('carVariantId').value=carVariantId;
    		document.getElementById('carDetailUrl').value=carDetailUrl;
		document.getElementById('usedCarCity').value=usedCarCity;
		document.getElementById('usedCarUserId').value=usedCarUserId;
		document.getElementById('usedCarUserNo').value=usedCarUserNo;
		document.getElementById('ownerType').value=ownerType;
		document.getElementById('usedCarId').value=usedCarId;
		element1 = document.getElementById(element1);
		 if (element1.style.display == 'block')
		   {
				element1.style.display = 'none';

		   }

		   else
			{
               element1.style.display = 'block';
               element1.style.position='absolute';
               element1.style.left=document.documentElement.scrollLeft + viewportwidth/3+'px';
               element1.style.top= document.documentElement.scrollTop + viewportheight/4 +'px';
               element1.style.width='290px';
               element1.style.height='100px';
	}
}

	function leadsSubmit(element1,element2){
		var viewportwidth;
		 var viewportheight;

 // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight

 if (typeof window.innerWidth != 'undefined')
 {
      viewportwidth = window.innerWidth,
      viewportheight = window.innerHeight
 }

// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)

 else if (typeof document.documentElement != 'undefined'
     && typeof document.documentElement.clientWidth !=
     'undefined' && document.documentElement.clientWidth != 0)
 {
       viewportwidth = document.documentElement.clientWidth,
       viewportheight = document.documentElement.clientHeight
 }

 // older versions of IE

 else
 {
       viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
       viewportheight = document.getElementsByTagName('body')[0].clientHeight
 }

			element1 = document.getElementById(element1);
		  	 if (element1.style.display == 'block')
			   {
				    element1.style.display = 'none';

			   }

			   else
      			{

 			element1.style.display = 'block';
              		 element1.style.position='absolute';
              		 element1.style.left=document.documentElement.scrollLeft + viewportwidth/3+'px';
               		element1.style.top= document.documentElement.scrollTop + viewportheight/4 +'px';

			document.getElementById("submitResponse").innerHTML=element2;
			}
		}


function toggleview1(element1)
{
	var viewportwidth;
	 var viewportheight;

 // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight

 if (typeof window.innerWidth != 'undefined')
 {
      viewportwidth = window.innerWidth,
      viewportheight = window.innerHeight
 }

// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)

 else if (typeof document.documentElement != 'undefined'
     && typeof document.documentElement.clientWidth !=
     'undefined' && document.documentElement.clientWidth != 0)
 {
       viewportwidth = document.documentElement.clientWidth,
       viewportheight = document.documentElement.clientHeight
 }

 // older versions of IE

 else
 {
       viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
       viewportheight = document.getElementsByTagName('body')[0].clientHeight
 }
 element1 = document.getElementById(element1);
  if (element1.style.display == 'block')
  {
  	element1.style.display = 'none';
   }

   return;
}

function showmake(element1){

			element1 = document.getElementById(element1);
		  	 if (element1.style.display == 'block')
			   {
				    element1.style.display = 'none';

			   }

			   else
      			{

 			element1.style.display = 'block';
			element1.style.position='absolute';
			element1.style.left=left;
			element1.style.top=top;
			element1.style.width='560px';
			element1.style.height='293px';

			}
		}


function popupCar(pop_Up, carModelName, oemName, carVariantId)
{

alert(pop_Up);
var viewportwidth;
var viewportheight;
if (typeof window.innerWidth != 'undefined')
{
     viewportwidth = window.innerWidth,
     viewportheight = window.innerHeight
}
else if (typeof document.documentElement != 'undefined'
&& typeof document.documentElement.clientWidth !=
'undefined' && document.documentElement.clientWidth != 0)
{
      viewportwidth = document.documentElement.clientWidth,
      viewportheight = document.documentElement.clientHeight
}
else
{
      viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
      viewportheight = document.getElementsByTagName('body')[0].clientHeight
}

element1 = document.getElementById(pop_Up);
alert(element1);
if (element1.style.display == 'none')
{
               element1.style.display = 'block';
               element1.style.position='absolute';
               element1.style.left=document.body.scrollLeft + viewportwidth/7+'px';
               element1.style.top= document.body.scrollTop + viewportheight/7 +'px' ;
               element1.style.width='550px';
               element1.style.height='270px';


       }
return;

}
function makeUrlForComparisonResults(obj,removeCar)
{
	var urlstr;
	var carList=document.getElementsByName("removeCars");
	if(carList.length==2)
	urlstr="compare-2car" ;
	if(carList.length==3)
	urlstr="compare-2car";
	if(carList.length==4)
	urlstr="compare-3car";
	for(var index=0;index<carList.length;index++)
	{
		var car=carList[index];
		if(car!=null)
		{
			if(car.value != removeCar){
			urlstr= urlstr  + "/" + removeSpaces(removeSlace(car.value)) ;
		}
	}
}
	obj.href=urlstr;
}
				function submitForm() {
					var urlstr= "compare-cars";
					document.getElementById("compareForm").action=urlstr;
				}

				function removeSlace(string) {
				var tstring = "";
				splitstring = string.split("/");
				tstring=splitstring[0];
				for(i = 1; i < splitstring.length; i++)
					tstring += "!"+splitstring[i];
				return tstring;
				}


function removeSpaces(string) {
				var tstring = "";
				splitstring = string.split(" ");
				tstring=splitstring[0];
				for(i = 1; i < splitstring.length; i++)
					tstring += "_"+splitstring[i];
				return tstring;
			}

	function getsubmitbutton()
	{
		if(document.getElementById("oemName").selectedIndex!=0 )
		{
			document.getElementById("addEditCustomerCare").action="addEditCustomerCare.do";
			document.getElementById("addEditCustomerCare").submit();
			return true;

		}
		return false;
	}

	function changeValue()
	{
		document.getElementById("infoSave").value="Save";
	}
	function changeRemove()
	{
		document.getElementById("infoSave").value="Remove";
	}








function showrenewpolicylists(id)
{
if(id=='new')
{
$('#carMakeRenew').hide();
$('#modelMakeRenew').hide();
$('#carMake').show();
$('#modelMake').show();
$('#CarVariantRenew').hide();
$('#CarVariant').show();
$('#trinsurername').hide();
$('#policyType').val('new');


}
if(id==='renew')
{
$('#carMakeRenew').show();
$('#modelMakeRenew').show();
$('#CarVariantRenew').show();
$('#carMake').hide();
$('#modelMake').hide();
$('#CarVariant').hide();
$('#trinsurername').show();
$('#policyType').val('renew');

}





}
function getCitylist(defaultcity)
{
	$('#trinsurername').hide();
	$('#policyType').val('new');
	var city=document.getElementById("residenceCity");
	stateWiseCityArray.sort();
	for(var start_index=0;start_index<stateWiseCityArray.length;start_index++)
	{
		var option=document.createElement("option");
		option.value=stateWiseCityArray[start_index][1];
		option.text=stateWiseCityArray[start_index][1];
		city.options.add(option);
		if(defaultcity==option.text)
			city.options.selectedIndex = start_index+1;
		document.getElementById("residenceCity").disabled=false;
	}

}

function removeallindex() {
	var variantRenew=document.getElementById("CarVariant");
	if(variantRenew.length>0) {
	  for(var index=variantRenew.length;index>0;index--)
		 variantRenew.remove(index);
	}
}
function getVariantNames(base_url) {
    var oemname=document.getElementById("modelMake")[document.getElementById("modelMake").selectedIndex].text;
	var modelMake=document.getElementById("CarVariant");
 	if(modelMake.length>0) {
 	   for(var index=modelMake.length;index>0;index--)
 	      modelMake.remove(index);
 	}
	$.post(base_url+"/ajaxCallAction.do",{carModelName:oemname},
				function (data) {
					if(data!='ERROR') {
					  var data1 = eval(data);
					  document.getElementById("CarVariant").disabled=false;
					  $.each(data1, function(i, item) {
							var opt = new Option();
							opt.value = item.variantName;
							opt.text = item.variantName;
							$('#CarVariant')[0].options.add(opt);
						});
					}
				}
		);
}

function submitValidate() {
   var fieldRequired = Array("state","city","carMake","modelMake","CarVariant","nameBox","emailBox","residenceCity","mobileNoBox");
   var lblField = Array("stateCarRegistered","cityCarRegistered","carmakelabel","carModel","carVariant","name","email","cityResidence","mobileNumber");
   var fieldDescription = Array("Select State","Select City","Select Brand","Select Model","Select Variant","Enter Name","Enter Email Address","Select City of Residence","Enter Mobile Number");
   var HiddenfieldRequired = Array("insurername","state","city","carMakeRenew","modelMakeRenew","CarVariantRenew","nameBox","emailBox","residenceCity","mobileNoBox");
   var HiddenlblField = Array("insurerNamelbl","stateCarRegistered","cityCarRegistered","carmakelabel","carModel","carVariant","name","email","cityResidence","mobileNumber");
   var HiddenfieldDescription = Array("Select Previous Insurer Name","Select State","Select City","Select Brand","Select Model","Select Variant","Enter Name","Enter Email Address","Select City of Residence","Enter Mobile Number");
   if($('#policyType').val()=='renew') {
        fieldRequired=HiddenfieldRequired;
        lblField=HiddenlblField;
        fieldDescription=HiddenfieldDescription;
    }
	var alertMsg = "Please provide correct information for the following fields highlighted in red:\n\n";
	var checkerror=0;
	var l_Msg = alertMsg.length;
    for (var i = 0; i < fieldRequired.length; i++) {
	    var obj = document.getElementById(fieldRequired[i]);
	    var lblObj = document.getElementById(lblField[i]);
	    if (obj) {
		   if((obj.selectedIndex==0 || obj.selectedIndex==-1)) {
              lblObj.style.color="#ff0000";
		      alertMsg += " - " + fieldDescription[i] + "\n";
			  alert(alertMsg);
			  return false;
	        }
		   else if(obj.value=="") {
			  lblObj.style.color="#ff0000";
              alertMsg += " - " + fieldDescription[i] + "\n";
			  alert(alertMsg);
			  return false;
            }
		   else if(obj.id=="emailBox") {
              if(isEmail(document.getElementById("emailBox").value)) {
                lblObj.style.color="#000000";
                }
              else {
                lblObj.style.color="#ff0000";
	            alert("E-mail : Enter The Correct E-mail Address \n");
			    return false;
             }
        } else {
	        lblObj.style.color="#000000";
	    }
    }

    }
  if(!isPhoneNumber(document.getElementById("mobileNoBox").value)) {
     alert("Enter The Valid Mobile Number.");
    return false;
	}
return true;
 }



function fnNotAlphabet(e)
{
    var code = e.keyCode ? event.keyCode : e.which ? e.which : e.charCode;
    //Code Explanation{ 0-9, 45=Insert, 13=Enter, 08=Backspace, 09=Tab}
    if ((code >= 48 && code <= 57)||(code == 45 || code == 13 || code == 08 || code == 09)) {
        checknos = true;
	    return (checknos);
    }
    else {
	    checknos= false;
	    alert("Only Number Allowed !");
	    return (checknos);
    }
}


function fnAlphabetwithSpace(e)
{
	var code = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;
	//alert(code);s
	//if ((code >= 65 && code <= 91)||(code >= 97 && code <= 123) ||(code == 32))
    if ((code >= 65 && code <= 90)||(code >= 97 && code <= 122) || code==32 || code==46 || code==8 || code==17 || code==127 || code==9 || code==16 || code==37 || code==38 || code==39 || code==40)
	{
        checknos = true;
		return (checknos);
	}
	else
	{
		checknos= false;
		alert("Only Alphabates Allowed !");
		return (checknos);        }
}
