
function createRequestObject()
    {   
      var request_obj ;
        var browser = navigator.appName ;
        
    if (browser == "Microsoft Internet Explorer")
     {
        request_obj = new ActiveXObject("Microsoft.XMLHttp");
     } 
    else
     {
        request_obj = new XMLHttpRequest();
     }
        return request_obj;
    }
 
var http1=createRequestObject();
var http2=createRequestObject();
var captiontext;
var pagenumcaption;

/**Load Trip year and redirect to dbformpage**/
function loadtripyear()
    {
        
        captiontext="-Month-";  
             
        var pageid=document.getElementById('pageID').value;
        var w = document.getElementById('drpdown_year').selectedIndex;
        var selected_text = document.getElementById('drpdown_year').options[w].value;
        if (selected_text=="-Year-")
        { 
            var statesList = document.getElementById("drpdown_month");
            statesList.options.length = 1; 
             document.getElementById("drpdown_month").options[0].text='-Month-';
        }
        else
        {           
            http2.open('get','/ajax/dbform.aspx?pageid='+pageid+'&year='+selected_text);       
            http2.onreadystatechange = loadmonth;
            http2.send(null);
        } 
               
    } 

  function loadmonth()
    {
  
        if (http2.readyState==4)
         {
            var i;
            var response1 =  http2.responseText.split("@"); 
                
            var val=response1[0].split("$");                     
            var statename;
            var stateid;
            var val1;
            var statesList = document.getElementById("drpdown_month");
            statesList.options.length = 1;
            document.getElementById("drpdown_month").options[0].text=captiontext;
            document.getElementById("drpdown_month").options[0].value="0";

            for (i=0;i<val.length-1;i++)
            {
                val1=val[i].split("#");
                statename=val1[0];
                stateid=val1[1];                
                statesList.options[statesList.options.length] = new Option(statename,stateid);
            }                      
         }
    }
  /**Display trip story details according tothe month and year**/                                                 
function loadtripstory(display)
{
        var pageid=document.getElementById('pageID').value;
        var w = document.getElementById('drpdown_year').selectedIndex;
        var selected_text = document.getElementById('drpdown_year').options[w].value;
        var x = document.getElementById("drpdown_month").selectedIndex;
        var month = document.getElementById("drpdown_month").options[x].value;                
        var pagenum = document.getElementById('drpdown_num').selectedIndex;          
       
        pagenum = document.getElementById('drpdown_num').options[pagenum].value;   
         
        pagenumcaption=pagenum;
        if(display=='month')
            pagenum=1;
        
        if (month=='-Month-')
        {    
            document.getElementById('tripTitles').innerHTML=""; 
            month="0";          
        }
        if(selected_text=='-Year-')
        {
            selected_text="0";
        }
       
              document.getElementById('tripTitles').innerHTML='<img src="/images/loading.gif" style="padding-left:20px;padding-top:30px"/>';
            var url='/ajax/dbform.aspx?pageid='+pageid+'&year='+selected_text+'&month='+month+'&pagenum='+pagenum;                             
            http1.open('get',url);       
            http1.onreadystatechange =loadtrip;
            http1.send(null);            
              
        return false;            
}


 function loadtrip()
    {
       document.getElementById('othertripstories').innerHTML="";
       document.getElementById('tripTitles').innerHTML=""; 
        document.getElementById('tripTitles').innerHTML='<img src="/images/Loading.gif" />';               
        if (http1.readyState==4)
         { 
             document.getElementById('tripTitles').innerHTML="";
            var y;    
            var paging='';   
            var response1 =  http1.responseText.split("@@");
                           
            var cnt=response1[0].split("?"); 
           
            var count=cnt[1];
                                  
            var tempcontact=response1[0].split("$");                              
            for (y=0;y<tempcontact.length-1;y++)
            {            
                var title=tempcontact[y].split("#");
                var length=title[0].length;
               
                var sTitle;
                var path;
                if(length>20)
                    sTitle=title[0].substring(0,20)+'...'; 
                 else
                     sTitle=title[0];
                 path="/"+title[1]+".aspx";                                                           
              
                document.getElementById('tripTitles').innerHTML=document.getElementById('tripTitles').innerHTML+"<li class=\"txt grey\"><a title=\""+title[0]+"\" href=\""+path+"\">"+sTitle+"</a></li>";
            }
           var pages=0;
           
             pages=parseInt(count) % 25;
            
             count=parseInt(count)/25
             if(pages!=0)
                count=parseInt(count)+1;
              var i=0;
             for(i=1;i<=parseInt(count);i++)
             {
                  paging=paging+ "<option value='"+ i +"'>" + i + "</option>";                 
             }                        
         }        
         document.getElementById('tripTitles').innerHTML="<ul>"+document.getElementById('tripTitles').innerHTML+"</ul>";                                                                                                
         document.getElementById('othertripstories').innerHTML="<select ID=\"drpdown_num\" Class=\"txtsmall drpdown numdrpdown\" onchange=\"loadtripstory()\">"+paging+"</select>";                                           
         document.getElementById('drpdown_num').value=pagenumcaption;
        
         if(document.getElementById('drpdown_num').value=='')
            document.getElementById('drpdown_num').value=1;
    }
    
    /**Loading trip by page**/
function loadtripbypage()
{
     var w = document.getElementById('drpdown_year').selectedIndex;
        var selected_text = document.getElementById('drpdown_year').options[w].value;
        var x = document.getElementById("drpdown_month").selectedIndex;
        var month = document.getElementById("drpdown_month").options[x].value; 
         var pagenum =  document.getElementById("drpdown_month").selectedIndex;
        pagenum = document.getElementById('drpdown_num').options[pagenum].value; 
        
        if (month=='-Month-')
        {    
            document.getElementById('tripTitles').innerHTML="";           
        }
        else if(selected_text!='-Year-')
        {       
            var url='/ajax/dbform.aspx?year='+selected_text+'&month='+month+'&page='+pagenum;            
            http3.open('get',url);       
            http3.onreadystatechange =loadtripbypage;
            http3.send(null);
        }  
        return false;    
}


/****Home page js*****/
function createRequestObject()
    {       
        var request_obj ;
        var browser = navigator.appName ;
        
    if (browser == "Microsoft Internet Explorer")
     {
        request_obj = new ActiveXObject("Microsoft.XMLHttp");
     } 
    else
     {
        request_obj = new XMLHttpRequest();
     }
        return request_obj;
    }
 
var http2=createRequestObject();
var http1=createRequestObject();
var http3=createRequestObject();
var http4=createRequestObject();
var captiontext;

  function prodlist()
  { 
        var a = document.getElementById('Ddlproduct').selectedIndex;
        var prod_text = document.getElementById('Ddlproduct').options[a].value;
       document.location=prod_text+".aspx";
  }                                                 
var state,city;
var statename,cityname;
function loadcon()
{

statename=document.getElementById('Ddlstate').selectedIndex;   
state=document.getElementById('Ddlstate').options[statename].value;
cityname=document.getElementById('Ddlcity').selectedIndex;   
city=document.getElementById('Ddlcity').options[cityname].value;
  document.location="/sales.aspx?state="+state+"&city="+city;
}
function loadimgOut(imgid)
{
	
	if(imgid=='classic-icon-new-1')
        document.getElementById(imgid).src='/images/products/classic-icon-new-1.gif';
    else if(imgid=='classic-icon-new')
        document.getElementById(imgid).src='/images/products/classic-icon-new.gif';
    else if(imgid=='icon-bullet-350')
        document.getElementById(imgid).src='/images/products/icon-bullet-350.gif';
    else if(imgid=='icon-bullet-electra-5s')
        document.getElementById(imgid).src='/images/products/icon-bullet-electra-5s.gif';
    else if(imgid=='icon-thunderbird')
        document.getElementById(imgid).src='/images/products/icon-thunderbird.gif';
    else if(imgid=='icon-machismo-500')
        document.getElementById(imgid).src='/images/products/icon-machismo-500.gif';
    else if(imgid=='icon-machismo')
        document.getElementById(imgid).src='/images/products/icon-machismo.gif';
    else if(imgid=='icon-bullet-electra')
        document.getElementById(imgid).src='/images/products/icon-bullet-electra.jpg';
    
}
function loadimgOut2(imgid)
{
    if(imgid=='icon-bullet-350_tab2')
        document.getElementById(imgid).src='/images/products/icon-bullet-350.gif';
    else if(imgid=='icon-bullet-electra-5s_tab2')
        document.getElementById(imgid).src='/images/products/icon-bullet-electra-5s.gif';
    else if(imgid=='icon-thunderbird_tab2')
        document.getElementById(imgid).src='/images/products/icon-thunderbird.gif';
    else if(imgid=='icon-machismo-500_tab2')
        document.getElementById(imgid).src='/images/products/icon-machismo-500.gif';
    else if(imgid=='icon-machismo_tab2')
        document.getElementById(imgid).src='/images/products/icon-machismo.gif';
    else if(imgid=='icon-bullet-electra_tab2')
        document.getElementById(imgid).src='/images/products/icon-bullet-electra.gif';
    
}
function loadimg(cid,imgid)
{
	if(imgid=='classic-icon-new-1')
    {
        document.getElementById(imgid).src='/images/products/classic-icon-new-1-hy.gif';
        if(document.getElementById('prodname')!=null)
        document.getElementById('prodname').innerHTML='Classic 350';
    }
    else if(imgid=='classic-icon-new')
    {
        document.getElementById(imgid).src='/images/products/classic-icon-new-hy.gif';
        if(document.getElementById('prodname')!=null)
        document.getElementById('prodname').innerHTML='Classic 500';
     }
    else if(imgid=='icon-bullet-350')
    {
        document.getElementById(imgid).src='/images/products/icon-bullet-350-hy.gif';
        if(document.getElementById('prodname')!=null)
        document.getElementById('prodname').innerHTML='Bullet 350';
     }
    else if(imgid=='icon-bullet-electra-5s')
    {
        document.getElementById(imgid).src='/images/products/icon-bullet-electra-5s-hy.gif';
        if(document.getElementById('prodname')!=null)
        document.getElementById('prodname').innerHTML='Electra Twinspark';
    }
    else if(imgid=='icon-thunderbird')
    {
        document.getElementById(imgid).src='/images/products/icon-thunderbird-hy.gif';
        if(document.getElementById('prodname')!=null)
        document.getElementById('prodname').innerHTML='Thunderbird Twinspark';
     }
    else if(imgid=='icon-machismo-500')
    {
        document.getElementById(imgid).src='/images/products/icon-machismo-500-hy.gif';
        if(document.getElementById('prodname')!=null)
        document.getElementById('prodname').innerHTML='Bullet Machismo 500';
     }
    else if(imgid=='icon-machismo')
    {     
       document.getElementById(imgid).src='/images/products/icon-machismo-hy.gif';
       if(document.getElementById('prodname')!=null)
       document.getElementById('prodname').innerHTML='Bullet Machismo';
     }
    else if(imgid=='icon-bullet-electra')
    {
        document.getElementById(imgid).src='/images/products/icon-bullet-electra-hy.gif';
        if(document.getElementById('prodname')!=null)
        document.getElementById('prodname').innerHTML='Bullet Electra';
    }
    else if(imgid=='350uceicon3')
    {
        document.getElementById(imgid).src='/images/products/350uceicon3.gif';
        if(document.getElementById('prodname')!=null)
        document.getElementById('prodname').innerHTML='Bullet 350 UCE';
    }
    http1.open('get','/app/Home_image.aspx?cid='+cid);       
    http1.onreadystatechange = bbhome;
    http1.send(null);
}
/**For old home page***/
function loadimgHome(cid,imgid)
{
    if(imgid=='icon-bullet-350')
        document.getElementById(imgid).src='/images/products/icon-bullet-350-hy.gif';
    else if(imgid=='icon-bullet-electra-5s')
        document.getElementById(imgid).src='/images/products/icon-bullet-electra-5s-hy.gif';
    else if(imgid=='icon-thunderbird')
        document.getElementById(imgid).src='/images/products/icon-thunderbird-hy.gif';
    else if(imgid=='icon-machismo-500')
        document.getElementById(imgid).src='/images/products/icon-machismo-500-hy.gif';
    else if(imgid=='icon-machismo')
       document.getElementById(imgid).src='/images/products/icon-machismo-hy.gif';
    else if(imgid=='icon-bullet-electra')
        document.getElementById(imgid).src='/images/products/icon-bullet-electra-hy.jpg';
    
    http1.open('get','/app/Home_imageforold.aspx?cid='+cid);       
    http1.onreadystatechange = bbhome;
    http1.send(null);
}
/***For tab2***/
function loadimg2(cid,imgid)
{
    if(imgid=='icon-bullet-350_tab2')
    {    
        document.getElementById(imgid).src='/images/products/icon-bullet-350-hy.gif';
        document.getElementById('prodname_tab2').innerHTML='Bullet 350';
     }
    else if(imgid=='icon-bullet-electra-5s_tab2')
    {
        document.getElementById(imgid).src='/images/products/icon-bullet-electra-5s-hy.gif';
        document.getElementById('prodname_tab2').innerHTML='Bullet Electra 5s';
    }
    else if(imgid=='icon-thunderbird_tab2')
    {
        document.getElementById(imgid).src='/images/products/icon-thunderbird-hy.gif';
        document.getElementById('prodname_tab2').innerHTML='Thunderbird Twinspark';
     }
    else if(imgid=='icon-machismo-500_tab2')
    {
        document.getElementById(imgid).src='/images/products/icon-machismo-500-hy.gif';
        document.getElementById('prodname_tab2').innerHTML='Bullet Machismo 500';
     }
    else if(imgid=='icon-machismo_tab2')
    {     
       document.getElementById(imgid).src='/images/products/icon-machismo-hy.gif';
       document.getElementById('prodname_tab2').innerHTML='Bullet Machismo';
     }
    else if(imgid=='icon-bullet-electra_tab2')
    {
        document.getElementById(imgid).src='/images/products/icon-bullet-electra-hy.gif';
        document.getElementById('prodname_tab2').innerHTML='Bullet Electra';
    }
    
    http1.open('get','/app/Home_image.aspx?cid='+cid);       
    http1.onreadystatechange = bbhome2;
    http1.send(null);
}

var response2,response3,response4;
var imgsrc,alttext,href,target;
 function bbhome()
    {
        if (http1.readyState==4)
         {             
             var response1 =  http1.responseText.split("%");              
             response2=response1[0].split("$");
             target=response2[1];
             response3=response2[0].split("#");
             href=response3[1];
             response4=response3[0].split("@");
             alttext=response4[1];
             imgsrc=response4[0];  
             
             if (imgsrc!="")                                        
             {
             document.getElementById('productimg').innerHTML="<a href=\""+ href +"\"><img src=\"/images/"+imgsrc+"\" alt=\""+alttext+"\" title=\""+alttext+"\" border=\"0\"></a>";                         
             }
         }                  
    }
    function bbhome2()
    {
        if (http1.readyState==4)
         {             
             var response1 =  http1.responseText.split("%");              
             response2=response1[0].split("$");
             target=response2[1];
             response3=response2[0].split("#");
             href=response3[1];
             response4=response3[0].split("@");
             alttext=response4[1];
             imgsrc=response4[0];  
             
             if (imgsrc!="")                                        
             {
             document.getElementById('productimg_tab2').innerHTML="<a href=\""+ href +"\"><img src=\"/images/"+imgsrc+"\" alt=\""+alttext+"\" title=\""+alttext+"\" border=\"0\"></a>";                         
             }
         }                  
    }
function nextimg(nextcid)
{
    http3.open('get','/app/Home_image.aspx?next=yes&cid='+nextcid);       
    http3.onreadystatechange = cc;
    http3.send(null);

}
var response5,response7;
 function cc()
    {   
        if (http3.readyState==4)
         {        
             var response1 =  http3.responseText.split("#");
                         
             response5=response1[0].split("@");
             response7=response5[0].split("~");  
           
           document.getElementById('icon_display').innerHTML=response7[0];
            
             document.getElementById('prev_icon').innerHTML="<a href=\"#\" onclick=\"previmg("+response5[1]+");\"><img src=\"/images/left-arrow.png\" alt=\"Royal Enfield\" border=\"0\" vspace=\"20\" /></a>";           
             if (response7[1]=="0")
             document.getElementById('next_icon').innerHTML="<a href=\"#\" ><img src=\"/images/right-arrow.png\" alt=\"Royal Enfield\" border=\"0\" vspace=\"0\" /></a>";           
             else
             document.getElementById('next_icon').innerHTML="<a href=\"#\" onclick=\"nextimg("+response7[1]+");\"><img src=\"/images/right-arrow.png\" alt=\"Royal Enfield\" border=\"0\" vspace=\"0\" /></a>";           
           
         }         
    } 

function previmg(prevcid)
{

    http4.open('get','/app/Home_image.aspx?prev=yes&cid='+prevcid);       
    http4.onreadystatechange = xx;
    http4.send(null);

}
var response6,response8;
 function xx()
    {   
        if (http4.readyState==4)
         {
        
             var response1 =  http4.responseText.split("#"); 
                     
             response6=response1[0].split("@");
              response8=response6[0].split("~");
             document.getElementById('icon_display').innerHTML=response8[0];
                
             if (response8[1]=="0")
              document.getElementById('prev_icon').innerHTML="<a href=\"#\" ><img src=\"/images/left-arrow.png\" alt=\"Royal Enfield\" border=\"0\" vspace=\"20\" /></a>";           
             else             
             document.getElementById('prev_icon').innerHTML="<a href=\"#\" onclick=\"previmg("+response8[1]+");\"><img src=\"/images/left-arrow.png\" alt=\"Royal Enfield\" border=\"0\" vspace=\"20\" /></a>";           
             document.getElementById('next_icon').innerHTML="<a href=\"#\" onclick=\"nextimg("+response6[1]+");\"><img src=\"/images/right-arrow.png\" alt=\"Royal Enfield\" border=\"0\" vspace=\"0\" /></a>";           
           
         }         
    } 

/***home page js ends****/
/****St_Products page js starts***/
 function createRequestObject()
    {       
        var request_obj ;
        var browser = navigator.appName ;
        
    if (browser == "Microsoft Internet Explorer")
     {
        request_obj = new ActiveXObject("Microsoft.XMLHttp");
     } 
    else
     {
        request_obj = new XMLHttpRequest();
     }
        return request_obj;
    }
 
var http2=createRequestObject();
var http1=createRequestObject();

function adddropdown(caption)
{

  captiontext=caption;
if (document.getElementById('Ddlcity')!=null)
{
    var w = document.getElementById('Ddlstate').selectedIndex;
    var selected_text = document.getElementById('Ddlstate').options[w].value;
    if (selected_text=="0")
    { 
    var statesList = document.getElementById("Ddlcity");
    statesList.options.length = 1; 
        document.getElementById('Ddlcity').options[0].text=caption;
    }
    else
    {     
        document.getElementById('loadingdiv').innerHTML='<img src="/images/loading_new.gif" style="padding-left:0px;padding-top:0px;float:left;" alt="loading..." title="loading..."/>';
        http2.open('get','/app/Generatecity.aspx?stateid='+selected_text);       
        http2.onreadystatechange = aa;
        http2.send(null);
    }
   }
} 

  function aa()
    {
           document.getElementById('loadingdiv').innerHTML='<img src="/images/loading_new.gif" alt="loading..." title="loading..."/>'; 
        if (http2.readyState==4)
         {
          document.getElementById('loadingdiv').innerHTML="&nbsp; ";
         var i;
            var response1 =  http2.responseText.split("~");
          
            var val=response1[0].split("$");
            var statename;
            var stateid;
            var val1;
            var statesList = document.getElementById("Ddlcity");
            statesList.options.length = 1;
            document.getElementById('Ddlcity').options[0].text=captiontext;
            document.getElementById('Ddlcity').options[0].value="0";

            for (i=0;i<val.length-1;i++)
            {
            val1=val[i].split("#");
            stateid=val1[0];
            statename=val1[1];           
            statesList.options[statesList.options.length] = new Option(statename,stateid);
            }                      
         }
    }

function prodlist()
 {
    var sel_text = document.getElementById('Ddlproduct').selectedIndex;         
    var prod_text = document.getElementById('Ddlproduct').options[sel_text].value;
        
    if (prod_text!="1")     
    document.location="/"+prod_text+".aspx";
 }                                                 
var state,city;
var statename,cityname;
function loadcon()
{
    statename=document.getElementById('Ddlstate').selectedIndex;   
    state=document.getElementById('Ddlstate').options[statename].value;
    cityname=document.getElementById('Ddlcity').selectedIndex;   
    city=document.getElementById('Ddlcity').options[cityname].value;
    document.location="/sales.aspx?state="+state+"&city="+city;
}
/***st_product.js ends****/
/***st_navigatorlanding****/
var desc1;
var details_navi;
var navi_x=0;
var desc_text="",details_cnt="",details1="",div_design="";
var description;
function navi_details(name,desc)
{
document.getElementById('navi_div').innerHTML="";
document.getElementById('navi_desc').innerHTML="";
document.getElementById('navi_name').innerHTML="";
var i=0,x=0;
document.getElementById('light_navi').style.display='block';
document.getElementById('fade_navi').style.display='block';
if (name!="")
{
document.getElementById('navi_name').innerHTML=name;
}


var myRegExp = new RegExp("~","g");
description = desc.replace(myRegExp, "'"); 

desc_text=description.split("$$");


 
if (desc_text.length>1)
{
details_navi = desc_text[0];
}
else
{
    details_navi=desc_text;    
}
document.getElementById('navi_desc').innerHTML=details_navi;

if (desc_text.length>1)
{
details_cnt=desc_text[1].split("$");

div_design=" <table cellpadding=\"0\" cellspacing=\"1\" border=\"0\" width=\"705\" >";
    for(i=0;i<details_cnt.length;i++)
    {       
        details1=details_cnt[i].split("#");
        if(x==0)
        {
        x=1;
        div_design=div_design+"<tr class=\"leftbgcolor\">";
        div_design=div_design+"<td class=\"table-pad1  grey txt-normal fntbold\"  width=\"266\">"+details1[0]+"</td>";
        div_design=div_design+"<td class=\"table-pad1  grey txt-normal\" width=\"419\">"+details1[1]+"</td></tr>";
        }
        else
        {
        div_design=div_design+"<tr class=\"gridcolor\">";
        div_design=div_design+"<td class=\"table-pad1  grey txt-normal fntbold\"  width=\"266\">"+details1[0]+"</td>";
        div_design=div_design+"<td class=\"table-pad1  grey txt-normal\" width=\"419\">"+details1[1]+"</td></tr>";
        x=0;
        }
    }
    document.getElementById('navi_div').innerHTML=div_design+"</table>";
    }

}
/***st_navigator landing js ends***/


