
var g_agt = navigator.userAgent.toLowerCase();
var is_opera = (g_agt.indexOf("opera") != -1);
var g_title = "";
var g_iframeno = 0;
var g_dialog_sWord;
var g_dialog_sButton;
var g_dialog_sAction;
var g_dialog_excss;

function $$(s){
if(document.getElementById){
	return eval('document.getElementById("' + s + '")');
}
else{
	return eval('document.all.' + s);
}
}

function s(s){if (!$$(s)) return; $$(s).style.display = "block";}

function h(s){if (!$$(s)) return; $$(s).style.display = "none";}

function hy(){
	for(var i=1;i<=4;i++){
		$$("hn"+i).className = "hn_of";
		s("hn_xx"+i);
		h("hn"+i+"_l");
		setflag("hn"+i+"_l");
	}
}
function xs(n){
	hy();
	s("hn"+n+"_l");
	$$("hn"+n+"_l").focus();
	h("hn_xx"+n);
	$$("hn"+n).className = "hn_on";
	void(0);
}
function setflag(s){
	if (!$$(s)) return;
	if (document.all ? true : false){
		$$(s).onmouseover = function () { hnmouseover(event); };
	}
	else{
		$$(s).addEventListener("mouseover", function (evnt) { hnmouseover(evnt); }, false);
	}
}

function hnmouseover(event){  }

function exist(s)
{
	return $$(s)!=null;
}

function myInnerHTML(idname, URL)
{
	if (exist(idname))
	{
		var xmlhttp = GetXmlHttpObject();
        xmlhttp.open("Get",URL,true);
        xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4 && xmlhttp.status==404) {$$(idname).innerHTML='Unable to read this page!';return}
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
        $$(idname).innerHTML=xmlhttp.responseText;
          }
        }
        xmlhttp.send(null);
	}
}

function dialog(v_w, v_h, v_title)
{
	var width = v_w;
	var height = v_h;
	var title = v_title;
	
	var sBox = '\
		<div id="dialogBox" style="FLOAT:left;display:none;z-index:19999;width:'+width+'px;">\
			<div style="position:absolute;top:0px;width:'+width+'px;filter:alpha(opacity=40);-moz-opacity:0.4;opacity:0.4;filter:\'alpha(opacity=40)\'"><img src="/js/src/widget/templates/images/h460_t.gif" width="'+width+'" height="8" /></div>\
			<div style="position:absolute;height:'+height+'px;top:8px;" >\
			<table border="0" cellpadding="0" cellspacing="0">\
			<tr style="height:'+(height)+'px;"><td style="background:#000000;width:7px;filter:alpha(opacity=40);-moz-opacity:0.4;opacity:0.4;filter:\'alpha(opacity=40)\'"></td>\
			<td style="width:'+(width-14)+'px;">\
				<div style="border:1px solid #565656;">\
				<table width="100%" border="0" cellpadding="0" cellspacing="0">\
				';

		var sClose = '<a href="###" onclick="javascript:new dialog().close();"><b class=text0 >×</b></a>';
		sBox +=	'\
					<tr height="24" bgcolor="#6795B4">\
						<td>\
							<div style="FONT-WEIGHT: bold; BACKGROUND: #CF501E; BORDER-BOTTOM: #565656 1px solid; HEIGHT: 24px;PADDING-TOP: 4px;">\
								<div id="dialogBoxTitle" style="PADDING-RIGHT: 8px; PADDING-LEFT: 8px; FONT-SIZE: 13px; FLOAT: left; PADDING-BOTTOM: 3px; COLOR: #fff; PADDING-TOP: 3px">'+title+'</div>\
								<div id="dialogClose" class="text8" style="PADDING-RIGHT: 3px; PADDING-LEFT: 3px; FLOAT: right; PADDING-BOTTOM: 2px; PADDING-TOP: 2px">' + sClose + '</div>\
							</div>\
						</td>\
					</tr>\
					<tr valign="top">\
						<td id="dialogBody" class="text1" style="height:' + (height-28) + 'px" bgcolor="#ffffff"></td>\
					</tr>\
		';
		
	     sBox += '\
				</table>\
				</div>\
			</td>\
			<td style="background:#000000;width:7px;filter:alpha(opacity=40); -moz-opacity:0.4;opacity:0.4;filter:\'alpha(opacity=40)\'"></td></tr>\
			</table>\
			</div>\
			<div class=ts460 style="position:absolute;top:'+(height+8)+'px;width:'+width+'px;filter:alpha(opacity=40);-moz-opacity:0.4;opacity:0.4;filter:\'alpha(opacity=40)\'"><img src="/js/src/widget/templates/images/h460_b.gif" width="'+width+'" height="8" /></div>\
		</div><div id="dialogBoxShadow" style="display:none;z-index:19998;"></div>\
	';
	
	var sIfram = '\
		<iframe id="dialogIframBG" name="dialogIframBG" frameborder="0" marginheight="0" marginwidth="0" hspace="0" vspace="0" scrolling="no" style="position:absolute;z-index:19997;display:none;"></iframe>\
	';
	
	var sBG = '\
		<div id="dialogBoxBG" style="position:absolute;top:0px;left:0px;width:100%;height:100%;"></div>\
	';
	
	this.init = function()
	{
		$$('dialogCase') ? $$('dialogCase').parentNode.removeChild($$('dialogCase')) : function(){};
		var oDiv = document.createElement('span');
		oDiv.id = "dialogCase";
		if (!is_opera)
		{
			oDiv.innerHTML = sBG + sIfram + sBox;
		}
		else
		{
			oDiv.innerHTML = sBG + sBox;
		}
		document.body.appendChild(oDiv);
	}

	this.open = function(_sUrl)
	{		
		this.show();
		$$("dialogBody").innerHTML="<div style='padding:10px;'><img src='/images/loading.gif' align='absmiddle'> <font style='color:#ccc;'>加载中...</font></div>";
		myInnerHTML('dialogBody', _sUrl);
	}

	this.show = function()
	{
		this.middle('dialogBox');
		if ($$('dialogIframBG'))
		{
			$$('dialogIframBG').style.top = $$('dialogBox').style.top;
			$$('dialogIframBG').style.left = $$('dialogBox').style.left;
			$$('dialogIframBG').style.width = $$('dialogBox').offsetWidth + "px";
			$$('dialogIframBG').style.height = $$('dialogBox').offsetHeight + "px";
			$$('dialogIframBG').style.display = 'block';
		}
		if (!is_opera) {
			this.shadow();
		}
	}
	
	this.reset = function()
	{
		this.close();
	}

	this.close = function()
	{
		if (window.removeEventListener) 
		{
			window.removeEventListener('resize', this.event_b, false);
			window.removeEventListener('scroll', this.event_b, false);
		} 
		else if (window.detachEvent) 
		{
			try {
				window.detachEvent('onresize', this.event_b);
				window.detachEvent('onscroll', this.event_b);
			} catch (e) {}
		}
		if ($$('dialogIframBG')) {
			$$('dialogIframBG').style.display = 'none';
		}
		$$('dialogBox').style.display='none';
		$$('dialogBoxBG').style.display='none';
		$$('dialogBoxShadow').style.display = "none";
		if (typeof(parent.onDialogClose) == "function")
		{
			parent.onDialogClose($$('dialogBoxTitle').innerHTML);
		}
	}

	this.shadow = function()
	{
		this.event_b_show();
		if (window.attachEvent)
		{
			window.attachEvent('onresize', this.event_b);
			window.attachEvent('onscroll', this.event_b);
		}
		else
		{
			window.addEventListener('resize', this.event_b, false);
			window.addEventListener('scroll', this.event_b, false);
		}
	}
	
	this.event_b = function()
	{
		var oShadow = $$('dialogBoxShadow');
		
		if (oShadow.style.display != "none")
		{
			if (this.event_b_show)
			{
				this.event_b_show();
			}
		}
	}
	
	this.event_b_show = function()
	{
		var oShadow = $$('dialogBoxShadow');
		oShadow['style']['position'] = "absolute";
		oShadow['style']['display']	= "";		
		oShadow['style']['opacity']	= "0.2";
		oShadow['style']['filter'] = "alpha(opacity=20)";
		oShadow['style']['background']	= "#000";
		var sClientWidth = parent ? parent.document.body.offsetWidth : document.body.offsetWidth;
		var sClientHeight = parent ? parent.document.body.offsetHeight : document.body.offsetHeight;
		var sScrollTop = parent ? (parent.document.body.scrollTop+parent.document.documentElement.scrollTop) : (document.body.scrollTop+document.documentElement.scrollTop);
		oShadow['style']['top'] = '0px';
		oShadow['style']['left'] = '0px';
		oShadow['style']['width'] = sClientWidth + "px";
		oShadow['style']['height'] = (sClientHeight + sScrollTop) + "px";
	}

	this.middle = function(_sId)
	{
		$$(_sId)['style']['display'] = '';
		$$(_sId)['style']['position'] = "absolute";

		var sClientWidth = parent.document.body.clientWidth;
		var sClientHeight = parent.document.body.clientHeight;
		var sScrollTop = parent.document.body.scrollTop+parent.document.documentElement.scrollTop;

		var sleft = (sClientWidth - $$(_sId).offsetWidth) / 2;
		var iTop = sScrollTop + 80;
		if($$(_sId).offsetWidth == 400)
		{
             iTop = sScrollTop + 160;
		}
		var sTop = iTop > 0 ? iTop : 0;

		$$(_sId)['style']['left'] = sleft + "px";
		$$(_sId)['style']['top'] = sTop + "px";
	}
}

function openWindow(_sUrl, _sWidth, _sHeight, _sTitle)
{
	var oEdit = new dialog(_sWidth, _sHeight, _sTitle);
	oEdit.init();
	oEdit.open(_sUrl);
}

//定义xmlHttp对象
function GetXmlHttpObject()
{
  var xmlHttp=null;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    }
return xmlHttp;
}

  //用户登录
    function UserLogin(){    
    var txtUserId=document.getElementById("UserId");
    var txtPassword=document.getElementById("PassWord");
    var IsRemember=document.getElementById("isgoindex");
    var spanLoginMsg=document.getElementById("LoginMsg");

    if(txtUserId.value==""){
    alert('请输入用户名！');
    return ;
    }    
 
    if(txtPassword.value==""){
    alert('请输入密码！');
    return;
    }
    spanLoginMsg.innerHTML="<img src='/images/loading.gif'> <font style='font-size:12px; color:#444;'>正在登录中...</font>";
    var flag="0";
    if(IsRemember.checked)flag="1";
     WebAspx.Ajax.User.UserLoginValid(txtUserId.value,txtPassword.value,flag,"1",function(res){
    spanLoginMsg.innerHTML="";
    var result=res.value; 
    if(result=="1"){
    spanLoginMsg.innerHTML="<font>已登录,开始畅游!</font>"
       location.reload();
    }
    else{
    txtUserId.value="";
    txtPassword.value="";
    spanLoginMsg.innerHTML="<font style='color:red;font-size:12px;'>登录失败,用户名密码错误.</font>"
    }
    

    });
    
        
    }
    

    function WinEmail(sname,svip,comid)
    {
    var ismail=document.getElementById("Win_IsMail");
    var txtmail=document.getElementById("Win_Mail");
    var isphone=document.getElementById("Win_IsPhone");
    var txtphone=document.getElementById("Win_Phone");
    var spanLoginMsg=document.getElementById("Win_LoginMsg");
    if(txtmail.value=="" && ismail.checked){
    alert('请输入邮箱账号！');
    return ;
    }    
    if(txtphone.value=="" && isphone.checked){
    alert('请输入手机号码！');
    return;
    }
    document.getElementById('Win_btnLogin').disabled=true;
    spanLoginMsg.innerHTML="<img src='/images/loading.gif' /><span style='color:red;font-size: 12px;' >正在发送...</span>"
    var mailflag="0"
    if(ismail.checked)mailflag="1"; 
    var phoneflag="0"
    if(isphone.checked)phoneflag="1"; 
    WebAspx.Ajax.User.UserMailValid(txtmail.value,txtphone.value,mailflag,phoneflag,sname,svip,comid,function(res){
    spanLoginMsg.innerHTML="";
    var msgcol=""; 
	if(res.value=="-1"){
      WinLogin();
    }
    else if(res.value=="1"){
        msgcol="<div style='float:left;PADDING-LEFT: 40px;PADDING-top: 3px;'><img src='/images/cbig_4.gif' /></div><div style='float:left;PADDING-LEFT: 16px;font-size: 14px;LINE-HEIGHT: 24px'>邮箱信件发送成功！<br>手机短信发送失败！</div>";
    }
	else{
		msgcol="<div style='float:left;PADDING-LEFT: 40px;PADDING-top: 3px;'><img src='/images/cbig_3.gif' /></div><div style='float:left;PADDING-LEFT: 16px;font-size: 14px;LINE-HEIGHT: 24px'>邮件,手机短信发送均失败！<br>原因:未知终端或余额不足！</div>";
	}
    document.getElementById('Win_UlEmail').innerHTML="<li>" + msgcol + "</li><li style='padding-top:100px;TEXT-ALIGN: center;'><INPUT type='button' value='确定' onclick='javascript:new dialog().close();' class='but0'></li>";
    }); 
    }

    function WinMessage(){
    var messageMsg=document.getElementById("MessageMsg");
    var txtUser=document.getElementById("txtUser"); 
    var txtContent=document.getElementById("txtContent");
    if(txtContent.value.length>=4 && txtContent.value.length<=500){
         messageMsg.innerHTML="<img src='/images/loading.gif' /> <span style='color:red' >发送中，请稍后...</span>";
         document.getElementById("bmessage").disabled = true;    
         WebAspx.Ajax.User.Add_Message(txtUser.value,txtContent.value,function(res){
                var resValue=res.value;
                if(resValue=='1'){
                messageMsg.innerHTML="<img src='/images/checkSelected.gif'/> <span style='color:green' >信息发送成功！</span>"; 
                setTimeout("GetButton()",5000);
                }
                else if(resValue=='-1'){ 
                WinLogin();
                }
                else{
                messageMsg.innerHTML="<img src='/images/check.gif' /> <span style='color:red' >信息发送失败！</span>"; 
                setTimeout("new dialog().close();",5000);
                }
          });
         
          }else{
                alert("请检查标题和内容是长度!");   
       }
    }

    function GetButton(){ 
        document.getElementById('bmessage').disabled=false;
        document.getElementById("MessageMsg").innerHTML="<INPUT type='button' value='关闭' onclick='javascript:new dialog().close();' class='but0'>";
        document.getElementById("txtContent").value="";
    }  

   function AddC_Sms(userId,up,sms_vip){
   WebAspx.Ajax.User.AddC_Smsvip(userId,up,function(res){
	 var voteObj=document.getElementById("hits_"+userId) 
     if(res.value=="1"){
		if(up == 1){voteObj.innerHTML=sms_vip + 1;}
		else{voteObj.innerHTML=sms_vip - 1;}
     }
     else if(res.value=="2"){
                alert('每天只有1点人气，谨慎使用！')
     }
     else if(res.value=="-1")
     {
      WinLogin();
     }
     else
     {
        alert(res.value)
     }
     
     
     });
    }

    function GetRandomNum(Min,Max){   
        var Range = Max - Min;   
        var Rand = Math.random();   
        return(Min + Math.round(Rand * Range));   
    }   

    function WinLogin(){
     return openWindow('/AjaxDiv.aspx?action=login', 400, 300, '用户登录');
	 alert(WebAspx.Ajax.User.Domain() + '/AjaxDiv.aspx?action=login');
    }

    function AddParty(par){
     return openWindow('/AjaxDiv.aspx?action=addparty&par=' + par, 400, 300, '网友活动报名');
    }

    function WinMember(par){
     var num = GetRandomNum(1,100);
     return openWindow('/AjaxDiv.aspx?action=member&par=' + par + '&ajax=' + num, 470, 390, '网友简易名片');
    }

    function SetEmail(par){
     var num = GetRandomNum(1,1000);
     return openWindow('/AjaxDiv.aspx?action=email&par=' + par + '&ajax=' + num, 380, 260, '发送商家信息');
    }

    function Show360Html(par){
     var num = GetRandomNum(1,100);
     return openWindow('/AjaxDiv.aspx?action=hotel&par=' + par + '&ajax=' + num, 616, 432, '全景360看房');
    }