arrMainStoryLnk=new Array("#","#","#","#","#");
function StartAjax()
{
 var xmlHttp; 
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
 return  xmlHttp;
}// end function

//Used to Show to Toggle the show/Hide of Login and Regoster on top 
function disaplyHideRegister()
	{
		if(document.getElementById("dvTop").className=="dvTopHide")
			{
				document.getElementById("dvTop").className='dvTopShow'
				document.getElementById("dvTop1").className='dvTopHide'
			}
		else
			{
				document.getElementById("dvTop").className='dvTopHide'
				document.getElementById("dvTop1").className='dvTopShow'
			}
	}

//Used in top Story to Change the the Selected Horizontal Menu font and background Image 
function getActiveHorizontalMenu(st_id)
	{
		for(i=0;i<=arrMainStoryLnk.length-1;i++)
			{
				if(i==st_id)
					{
					document.getElementById("tdst_"+i).className="active_Topmnu";
					document.getElementById("tp_"+i).className="topYellow";
					}
				else
					{
					 document.getElementById("tdst_"+i).className="inactive_Topmnu";
					 document.getElementById("tp_"+i).className="topWhite";
					}
				}
		}
//Used in Find a Vehicle to Change the Search button Image
function changeImg()
		{
			document.getElementById("img_Search").src="/img/search_over.gif";
		}

function echeck(str) {
		Email=document.frm_wc.txtemail;
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
			Email.focus();
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
			Email.focus();
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
			Email.focus();
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
			Email.focus();
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
			Email.focus();
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
			Email.focus();
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
			Email.focus();
		    return false
		 }
	
 		 return true					
	}
function common_echeck(Email) {
		str=Email.value;
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
			Email.focus();
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
			Email.focus();
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
			Email.focus();
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
			Email.focus();
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
			Email.focus();
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
			Email.focus();
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
			Email.focus();
		    return false
		 }
	
 		 return true					
	}


function rate_img(id_picture,rate)
{
	document.getElementById("rate_div").innerHTML = "<table cellspacing=0 cellpadding=0 border=0><tr><td align=center ><font face='Arial' color='#2D629E' size='2'><b>Rating...</b></font></td></tr></table>";
	NewxmlHttp5=StartAjax();
	NewxmlHttp5.onreadystatechange=function()
	{
		
		if (NewxmlHttp5.readyState==4) 
			{
				if (NewxmlHttp5.status!=404)
				{	
				   if((NewxmlHttp5.responseText).length > 0)
					{
						//alert(NewxmlHttp5.responseText);
						document.getElementById("showRate").innerHTML = NewxmlHttp5.responseText;	
						document.getElementById("rate_div").innerHTML ="<table cellspacing=0 cellpadding=0 border=0><tr><td  align=center ><font face='Arial' color='#2D629E' size='2'><b>Sucessfully posted your vote.</b></font></td></tr></table>";	
						
					}
				}
			
			}
			
	}
	datafile = "ajx_photorate.php?id_picture="+id_picture+"&rate="+rate;
	NewxmlHttp5.open("GET", datafile, true);
	NewxmlHttp5.setRequestHeader("Cache-Control","no-cache"); 
	NewxmlHttp5.send(null);
}
function generalAjax(file,obj)
{

	NewxmlHttp5=StartAjax();
	NewxmlHttp5.onreadystatechange=function()
	{
		
		if (NewxmlHttp5.readyState==4) 
			{
				if (NewxmlHttp5.status!=404)
				{	
				   if((NewxmlHttp5.responseText).length > 0)
					{

						obj.innerHTML = NewxmlHttp5.responseText;	
						
						
					}
				}
			
			}
			
	}
	NewxmlHttp5.open("GET", file, true);
	NewxmlHttp5.setRequestHeader("Cache-Control","no-cache"); 
	NewxmlHttp5.send(null);
}
function rotateImg(id_picture,id_gallery,flow,pos,tot)
{
	document.getElementById("rate_div").innerHTML = "<table cellspacing=0 cellpadding=0 border=0><tr><td align=center ><font face='Arial' color='#2D629E' size='2'><b>Loading Picture...</b></font></td></tr></table>";
	
	NewxmlHttp6=StartAjax();
	NewxmlHttp6.onreadystatechange=function()
	{
		if (NewxmlHttp6.readyState==4) 
			{
				if (NewxmlHttp6.status!=404)
				{	
				   if((NewxmlHttp6.responseText).length > 0)
					{
						//alert(NewxmlHttp6.responseText);
						document.getElementById("imgBox").innerHTML = NewxmlHttp6.responseText;	
						
					}
				}
			
			}
			
	}
	datafile = "ajx_rotateimg.php?id_picture="+id_picture+"&id_gallery="+id_gallery+"&flow="+flow+"&pos="+pos+"&tot="+tot;
	NewxmlHttp6.open("GET", datafile, true);
	NewxmlHttp6.setRequestHeader("Cache-Control","no-cache"); 
	NewxmlHttp6.send(null);
}
function test(id_picture,id_gallery,flow,pos,tot)
{
   alert("pos:"+pos+"tot:"+tot);

}
function imgSlideShow(id_picture,id_gallery,flow,pos,tot)
{
	/*c=document.getElementById("icounter").value;
	if(parseInt(c)==parseInt(tot))
	{
		c=1;
	 }else{c=parseInt(c)+1;}
	
	document.getElementById("icounter").value=c; 
	 */
	pos=parseInt(pos);
	tot=parseInt(tot);
    if(pos==tot)
	{
		 pos=1;
	}else{pos=pos+1;}
	flow='cont';
	rotateImg(id_picture,id_gallery,flow,pos,tot);
	
	t=setTimeout(imgSlideShow(id_picture,id_gallery,flow,pos,tot),6000);
	
}
function rate_vid(video_id,rate)
{
	document.getElementById("rate_div").innerHTML = "<table cellspacing=0 cellpadding=0 border=0><tr><td align=center ><font face='Arial' color='#2D629E' size='2'><b>Rating...</b></font></td></tr></table>";
	NewxmlHttp5=StartAjax();
	NewxmlHttp5.onreadystatechange=function()
	{
		
		if (NewxmlHttp5.readyState==4) 
			{
				if (NewxmlHttp5.status!=404)
				{	
				   if((NewxmlHttp5.responseText).length > 0)
					{
						//alert(NewxmlHttp5.responseText);
						document.getElementById("showRate").innerHTML = NewxmlHttp5.responseText;	
						document.getElementById("rate_div").innerHTML = "<table cellspacing=0 cellpadding=0 border=0><tr><td  align=center ><font face='Arial' color='#2D629E' size='2'><b>Sucessfully posted your vote.</b></font></td></tr></table>";	
						
					}
				}
			
			}
			
	}
	datafile = "ajx_videorate.php?video_id="+video_id+"&rate="+rate;
	NewxmlHttp5.open("GET", datafile, true);
	NewxmlHttp5.setRequestHeader("Cache-Control","no-cache"); 
	NewxmlHttp5.send(null);
}
function getSubMenu()
		{
			var htmContent="&nbsp;&nbsp;<a href='/photo_gallery.php' class='mnuSubCls'>Photo Gallery</a>&nbsp;&nbsp;<span class='mnuSubCls'>|</span>&nbsp;&nbsp;<a href='/video_gallery.php' class='mnuSubCls'>Video Gallery</a>&nbsp;&nbsp;<span class='mnuSubCls'>|</span>&nbsp;&nbsp;<a href='/wallpaper_list.php' class='mnuSubCls'>Wallpaper</a>";
			document.getElementById('idSubtext').innerHTML=htmContent;

		}




 function getVehicle()
	{
		document.getElementById("model_hidden").value=document.getElementById("model_s").value;
		document.getElementById("version_hidden").value=document.getElementById("version_s").value;
		if((document.frmFinder.mfg_sel.value=='') && (document.frmFinder.model_sel.value=='') && (document.frmFinder.version_sel.value=='') && (document.frmFinder.segment_sel.value=='') && (document.frmFinder.priceRange.value==''))
		{
			alert("select at least one criteria to search !!");
			return false;
		
		}
		else
		{
			
			document.frmFinder.submit();
		}
	
	}
 function getVehicleHome()
	{
		
		document.getElementById("model_hidden").value=document.getElementById("model_s").value;
		document.getElementById("version_hidden").value=document.getElementById("version_s").value;
		
		if((document.frmFinder.mfg_sel.value=='') && (document.getElementById("model_hidden").value=='') && (document.getElementById("version_hidden").value==''))
		{
			alert("select at least one criteria to search !!");
			return false;
		
		}
		else
		{
			
			return true;
			
			
		}
	
	}
	function validbsmSearch()
	{
		document.getElementById("model_smodel1").value=document.getElementById("smodel_s1").value
		if((document.frmcarsearch.smanu.value=='')&&(document.frmcarsearch.smodel.value==''))
		{
			alert("select at least one criteria to search !!");
			return false;	
		}
		else{
			document.frmcarsearch.submit();
		}
	
	}
	function validbsmSearch2()
	{
		document.getElementById("model_smodel2").value=document.getElementById("smodel_s2").value
		if((document.frmbikesearch.smanu.value=='')&&(document.frmbikesearch.smodel.value==''))
		{
			alert("select at least one criteria to search !!");
			return false;	
		}
		else{
			document.frmbikesearch.submit();
		}
	
	}

function getDropDown(table,vl,dopId)
{
	NewxmlHttp6=StartAjax();
	NewxmlHttp6.onreadystatechange=function()
	{
		if (NewxmlHttp6.readyState==4) 
			{
				if (NewxmlHttp6.status!=404)
				{	
				   if((NewxmlHttp6.responseText).length > 0)
					{
						document.getElementById(dopId).innerHTML = NewxmlHttp6.responseText;	
						
					}
				}
			
			}
			
	}
	datafile = "/common/ajfile.php?table="+table+"&vl="+vl;
	NewxmlHttp6.open("GET", datafile, true);
	NewxmlHttp6.setRequestHeader("Cache-Control","no-cache"); 
	NewxmlHttp6.send(null);
}

function getfVehicle(table,vId,sId)
{
	var whVal;
	whVal=document.getElementById(vId).value;
	getDropDown(table,whVal,sId);
	getfModel_m();
}


function getfModel_m()
{
	var whVal;
	whVal=document.getElementById("model_s").value;
	document.getElementById("model_hidden").value=whVal;
}


function getRevDropDown(table,vl,dopId)
{
	NewxmlHttp6=StartAjax();
	NewxmlHttp6.onreadystatechange=function()
	{
		if (NewxmlHttp6.readyState==4) 
			{
				if (NewxmlHttp6.status!=404)
				{	
				   if((NewxmlHttp6.responseText).length > 0)
					{
						document.getElementById(dopId).innerHTML = NewxmlHttp6.responseText;	
						
					}
				}
			
			}
			
	}
	datafile = "/common/ajfileRev.php?table="+table+"&vl="+vl;
	NewxmlHttp6.open("GET", datafile, true);
	NewxmlHttp6.setRequestHeader("Cache-Control","no-cache"); 
	NewxmlHttp6.send(null);
}

function getRevVehicle(table,vId,sId)
	{
		var whVal;
		whVal=document.getElementById(vId).value;
		getRevDropDown(table,whVal,sId);
	}
function validSecSearch()
{
	  if(document.frmsecs.s_keyword.value=='')
		{
			alert("Enter search keyword  !!");
			return false;	
		}
		else{
			document.frmsecs.submit();
		}

}
function validTSearch()
{
	  if(document.frmwsearch.topsearchtxt.value=='')
		{
			alert("Enter search keyword  !!");
			return false;	
		}
		else{

		   document.frmwsearch.action="/whole_search.php";
		   document.frmwsearch.submit();
		}

}

function TabFunction(lstTab,lstContents,sObj,sTab,hCls,sCls)
	{
		if(sTab=="idTabBike")
			{
				
				document.getElementById("lnktab").innerHTML="<A HREF='/bike/quick_compare.php' class='subscr'>Quick Comparisions</A>";	
				
			}
		else
			{	
				document.getElementById("lnktab").innerHTML="<A HREF='/car/quick_compare.php' class='subscr'>Quick Comparisions</A>";
				
				
			}

		
		lstTab=lstTab.split(',');
		lstContents=lstContents.split(',');
		var r;
		var z;
		for(var i=0;i<lstTab.length;i++)
			{ r=lstTab[i];
			 if(r==sTab)
				{
					document.getElementById(r).className=sCls; 
					
				}
			else
				{
					document.getElementById(r).className=hCls; 
				}
			}
		
		for(var j=0;j<lstContents.length;j++)
			{
			//alert(document.getElementById("cmpBike"));
			  z=lstContents[j];
			  //alert(z);
			
			if(z==sObj)
				{
					document.getElementById(z).style.display = 'block'; 
				}
			else
				{
					document.getElementById(z).style.display = 'none';
				}
			
			}
			
	}

function wc_ajax(name,email,query)
{

file="/common/update_wc.php?txtname="+name+"&txtemail="+email+"&txtquery="+query+"";
	NewxmlHttp5=StartAjax();
	NewxmlHttp5.onreadystatechange=function()
	{
		if (NewxmlHttp5.readyState==4) 
			{	
				if (NewxmlHttp5.status!=404)
				{
					document.frm_wc.whichCarhidden.value= NewxmlHttp5.responseText;
					

				}
			
			}
			
	}
	NewxmlHttp5.open("GET", file, true);
	NewxmlHttp5.setRequestHeader("Cache-Control","no-cache"); 
	NewxmlHttp5.send(null);
}

function callValidate_wc()
	{

		var name;
		var email;
		var query;
	if(document.frm_wc.txtname.value=="")
		{
			alert("Please put your name !!");
			document.frm_wc.txtname.focus();
			return false;
		}
	if(echeck(document.frm_wc.txtemail.value)==false)
		{
			document.frm_wc.txtemail.focus();
			return false;
		}
	if(document.frm_wc.txtquery.value=="")
		{
			alert("Please put your Question !!");
			document.frm_wc.txtquery.focus();
			return false;
		}
		name=document.frm_wc.txtname.value;
		email=document.frm_wc.txtemail.value;
		query=document.frm_wc.txtquery.value;
	
//	if(document.frm_wc.whichCarhidden.value!="")
//		{

//		}

	if(document.frm_wc.whichCarhidden.value=="")
		{
			window.open("/common/openWichcar.htm","Which Car","menubar=1,resizable=1,width=350,height=250");
			wc_ajax(name,email,query);
		}
	
	

	}


			function checkEnter(e){ 
	var characterCode;
	if(e && e.which){ 
	e = e
	characterCode = e.which
	}
	else{
	e = event
	characterCode = e.keyCode

	}
//alert(characterCode);
		if(characterCode == 13){
			validTSearch();
			//document.forms[0].submit() //submit the form
			//return false
		}
		else{
		return true
		}

}
function TabFunctionNews(lstTab,lstContents,sObj,sTab,hCls,sCls)
	{
		if(sTab=="idTabBike")
			{
				
				document.getElementById("lnktab_news").innerHTML="<A HREF='/story_listing.php?id=22' class='subscr'>News</A>";	
				
			}
		else
			{	
				document.getElementById("lnktab_news").innerHTML="<A HREF='#' class='subscr'>News</A>";
				
				
			}

		
		lstTab=lstTab.split(',');
		lstContents=lstContents.split(',');
		var r;
		var z;
		for(var i=0;i<lstTab.length;i++)
			{ r=lstTab[i];
			 if(r==sTab)
				{
					document.getElementById(r).className=sCls; 
					
				}
			else
				{
					document.getElementById(r).className=hCls; 
				}
			}
		
		for(var j=0;j<lstContents.length;j++)
			{

			  z=lstContents[j];

			
			if(z==sObj)
				{
					document.getElementById(z).style.display = 'block'; 
				}
			else
				{
					document.getElementById(z).style.display = 'none';
				}
			
			}
			
	}
