﻿Namespace.register("How2go.Default");
How2go.Default=
{
    Test:function(v)
    {
        alert(v);
    }
    ,
    StyleId:''
    ,
    Login:function(userName,password,autoSave)
    {
        var UserName=How2go.$(userName);
        var Password=How2go.$(password);
        var AutoSave=How2go.$(autoSave);
        if (How2go.Trim(UserName.value)=='')
        {
            alert('请输入用户名称!');
            UserName.select();
            return;
        }
        if (How2go.Trim(Password.value)=='')
        {
            alert('请输入用户密码!');
            Password.select();
            return;
        }
        How2go.Load.Show();
        How2go.Ajax.Post('How2go.Login',
            'action=0&UserName='+UserName.value+'&Password='+Password.value+'&AutoSave='+AutoSave.checked+'',{oncomplate:function(){setTimeout(function(){		    
                var json=eval(How2go.Ajax.ResponseText['How2go.Login']);
                    How2go.Load.Hidden();
                        if (json[0].Status)
                        {
                            How2go.Redirect(How2go.Path+'/ITraffic.aspx');
                        }
                        else
                        {
                            alert(json[1].Message);
                        }
                    },50);
                }
            }
        );
		    
    }
    ,
    Exit:function()
    {
        How2go.Load.Show();
        How2go.Ajax.Post('How2go.Exit',
            'action=4',{oncomplate:function(){setTimeout(function(){		    
                var json=eval(How2go.Ajax.ResponseText['How2go.Exit']);
                    How2go.Load.Hidden();
                        How2go.Redirect(How2go.Path+'/Default.aspx');
                    },50);
                }
            }
        );
    }
    ,
    Style:function(style)
    {
        How2go.Load.Show();
        How2go.Ajax.Post('How2go.Style',
            'action=1&Style='+style+'',{oncomplate:function(){setTimeout(function(){		    
                var json=eval(How2go.Ajax.ResponseText['How2go.Style']);
                    How2go.Load.Hidden();
                        if (json[0].Status)
                        {
                            How2go.$(How2go.Default.StyleId).href=How2go.Path+'/Style/'+json[1].Style+'/Style.css';
                        }
                    },50);
                }
            }
        );
    }
    ,
    SearchPoi:function(city,keyWord)
    {
        var City=How2go.$(city);
        var KeyWord=How2go.$(keyWord);
        if (How2go.Trim(KeyWord.value)=='')
        {
            alert('请输入您要查询的路况名称!');
            KeyWord.select();
            return;
        }
        var page=How2go.Path+"/Traffic.aspx?City="+escape(City.value)+"&KeyWord="+escape(How2go.Mark(KeyWord.value))+"";
        How2go.Redirect(page);
    }
    ,
    SearchRole:function(city1,keyWord1,city2,keyWord2,type,block)
    {
        var City1=How2go.$(city1);
        var KeyWord1=How2go.$(keyWord1);
        var City2=How2go.$(city2);
        var KeyWord2=How2go.$(keyWord2);
        var Type=How2go.$(type);
        var Block=How2go.$(block);
 
        if (How2go.Trim(KeyWord1.value)=='')
        {
            alert('请输入您要查询的路况线路始点的名称!');
            KeyWord1.select();
            return;
        }
        if (How2go.Trim(KeyWord2.value)=='')
        {
            alert('请输入您要查询的路况线路终点的名称!');
            KeyWord2.select();
            return;
        }
        var page=How2go.Path+"/TRoad.aspx?City1="+escape(How2go.Select(City1).value)+"&KeyWord1="+escape(How2go.Mark(KeyWord1.value))+"&City2="+escape(How2go.Select(City2).value)+"&KeyWord2="+escape(How2go.Mark(KeyWord2.value))+"&Type="+escape(How2go.Select(Type).value)+"&Block="+escape(Block.checked)+"";
        How2go.Redirect(page);
    }
    ,
    City:function(id)
    {
        var sel=How2go.$(id);
            if (How2go.Select(sel).value=='')
            {
                How2go.City.Show(id);
            }
            else
            {
                How2go.City.Select(How2go.Select(sel).text);
            }
    }
    ,
    //Online('1','&ComeFrom=" + referrer + "&Browser=" + context.Request.Url.ToString().Trim() + "&Location=' + document.title+ ''
    Online:function(action,send)
    {
                if (!(navigator.appVersion.match(/\bMSIE\b/)=='MSIE'))
                {
                   var ajax= new XMLHttpRequest();
                }
                else
                {
                    var ajax=new ActiveXObject("Microsoft.XMLHTTP");
                }
            var send="Action="+action+send;
            
            path="/BBS/Utility/Ajax.aspx";            
            ajax.open("POST",''+path+'?',true);
            ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
            ajax.send(send);
    }
	,
	RouteStyle:function(id,selectValue)
	{
		var obj=How2go.$(id);
		if (null!=obj)
		{
			How2go.Ajax.Post('How2go.RouteStyle',
                    'action=13',{oncomplate:function(){setTimeout(function(){		    
                        var json=eval(How2go.Ajax.ResponseText['How2go.RouteStyle']);
									obj=How2go.$(id);
										if (null!=obj)
										{
											obj.length=0;
											if (json[0].Status)
											{
												for(var i=1;i<json.length;i++)
												{
													obj.length=i;
													obj.options[i-1].value=json[i].Value;
													obj.options[i-1].text=json[i].Text;	
													if (selectValue==json[i].Value)
													{
														obj.options[i-1].selected=true;	
													}
												}
											}
										}
                            },50);
                        }
                    }
                );
		}
	}
}
Namespace.register("How2go.Slide");
How2go.Slide={
	
	Init:function(index)
		{
			var tempInterval;
			//clearInterval(tempInterval);
			var silde1="<img src=\"mobile.jpg\" style=\"cursor:pointer;width:338px;height:190px\" id=\"How2go.Slide1\" />";
			var silde2="<img src=\"pnd.jpg\" style=\"cursor:pointer;width:338px;height:190px\"  id=\"How2go.Slide2\"/>";
			var div1="<div id=\"How2go.Slide.Div1\" style=\"position:absolute; margin-top:160px; margin-left:190px; height:150px; width:67px; height:18px; background-image:url(images/slidebutton.jpg);text-align:center;line-height:16px; padding-top:4px;cursor:pointer\">手机应用</div>";
			var div2="<div id=\"How2go.Slide.Div2\" style=\"position:absolute; margin-top:160px; margin-left:260px; height:150px; width:67px; height:18px; background-image:url(images/slidebutton1.jpg);text-align:center;line-height:16px; padding-top:4px;cursor:pointer\">车载导航</div>";
			var obj=document.getElementById("How2go.Slide");
			if (null!=obj)
			{
					obj.innerHTML =div1;
					obj.innerHTML +=div2;
				if (index==1)
				{
					obj.innerHTML +=silde1;
					var  s=document.getElementById("How2go.Slide1");
					var  d1=document.getElementById("How2go.Slide.Div1");
					var  d2=document.getElementById("How2go.Slide.Div2");
					d1.style.backgroundImage="url(images/slidebutton.jpg)";
					d2.style.backgroundImage="url(images/slidebutton1.jpg)";
						s.src="images/mobile.jpg";
					s.onmouseover=function()
					{
						clearInterval(tempInterval);
						return;
					}
					s.onmouseout=function()
					{
						How2go.Slide.Init(2);
					}
					d1.onmousedown=s.onmousedown=function()
					{
						window.location="Company/Mobile.aspx";	
					}
					d2.onmousedown=s.onmousedown=function()
					{
						window.location="Company/PND.aspx";	
					}
					
					d1.onmouseover=function()
					{
						clearInterval(tempInterval);
						s.src="images/mobile.jpg";
						d1.style.backgroundImage="url(images/slidebutton.jpg)";
						d2.style.backgroundImage="url(images/slidebutton1.jpg)";
						return;
					}
					d2.onmouseover=function()
					{
						clearInterval(tempInterval);
						s.src="images/pnd.jpg";
						d1.style.backgroundImage="url(images/slidebutton1.jpg)";
						d2.style.backgroundImage="url(images/slidebutton.jpg)";
						return;
					}
				}
				else
				{
					obj.innerHTML +=silde2;	
					var  s=document.getElementById("How2go.Slide2");
					var  d1=document.getElementById("How2go.Slide.Div1");
					var  d2=document.getElementById("How2go.Slide.Div2");
					d1.style.backgroundImage="url(images/slidebutton1.jpg)";
					d2.style.backgroundImage="url(images/slidebutton.jpg)";
						s.src="images/pnd.jpg";
					s.onmouseover=function()
					{
						clearInterval(tempInterval);
						return;
					}
					
					d1.onmousedown=s.onmousedown=function()
					{
						window.location="Company/Mobile.aspx";	
					}
					d2.onmousedown=s.onmousedown=function()
					{
						window.location="Company/PND.aspx";	
					}
					
					s.onmouseout=function()
					{
						How2go.Slide.Init(1);
					}
					
					d2.onmouseover=function()
					{
						clearInterval(tempInterval);
						s.src="images/pnd.jpg";
						d1.style.backgroundImage="url(images/slidebutton1.jpg)";
						d2.style.backgroundImage="url(images/slidebutton.jpg)";
						return;
					}
					d1.onmouseover=function()
					{
						clearInterval(tempInterval);
						s.src="images/mobile.jpg";
						d1.style.backgroundImage="url(images/slidebutton.jpg)";
						d2.style.backgroundImage="url(images/slidebutton1.jpg)";
						return;
					}
				}
			}
		 tempInterval=setInterval(
           
					  function(){
									   if (index==1)
									   {
											index =2;   
										}
										else
										{
											index=1;	
										}
									 How2go.Slide.Init(index);
									clearInterval(tempInterval);
					  
					  },2000
					  )
		}
	}