﻿var isMSIE = (navigator.userAgent.indexOf('MSIE') >= 0 && navigator.userAgent.indexOf('Opera') < 0);
var isFirefox= (navigator.userAgent.indexOf('Firefox') >= 0); 
var isOpera = (navigator.userAgent.indexOf('Opera') >= 0);
var ie = navigator.appName.indexOf('MSIE6.0') >= 0 ? 6 : (navigator.appName.indexOf('MSIE7.0') >= 0 ? 7 : (navigator.appName.indexOf('MSIE8.0') >= 0 ? 8 : 5.5));

var Try = {
    these: function() {	
        var returnValue;
        for(var i = 0; i < arguments.length; i++){
            var lambda = arguments[i];
            try{
                returnValue = lambda();	
                break;
            } 
            catch(e){}
        }
        return returnValue;
    }
}
var xmlHttp = Try.these(
    function() { return new ActiveXObject('Msxml2.XMLHTTP')},
    function() { return new ActiveXObject('Microsoft.XMLHTTP')},
    function() { return new XMLHttpRequest()}
) || false;

String.prototype.trim = function(){ return this.replace(/(^[\s]*)|([\s]*$)/g, "");}
String.prototype.lTrim = function(){ return this.replace(/(^[\s]*)/g, "");}
String.prototype.rTrim = function(){ return this.replace(/([\s]*$)/g, "");}
String.prototype.replaceAll  = function(s1,s2){ return this.replace(new RegExp(s1,"gm"),s2); } 
String.prototype.equals  = function(s1){ return this.replace(s1,'') == '' ? true :false; } 

function $I(i){ return document.getElementById(i); }
function $N(name){ return document.getElementsByName(name); }
function $T(tag){ return document.getElementsByTagName(tag); }

var _st = window.setTimeout; 
window.setTimeout = function(fRef, mDelay) {
    if(typeof fRef == 'function'){ 
        var argu = Array.prototype.slice.call(arguments,2); 
        var f = (function(){ fRef.apply(null, argu); }); 
        return _st(f, mDelay); 
    } 
    return _st(fRef,mDelay);
}
var _si = window.setinterval; 
window.setinterval = function(fRef, mDelay) { 
    if(typeof fRef == 'function'){ 
        var argu = Array.prototype.slice.call(arguments,2); 
        var f = (function(){ fRef.apply(null, argu);}); 
        return _si(f, mDelay); 
    } 
    return _si(fRef,mDelay);
}

function sc(objName,objConName,css,css1,id,num){    
    for(var i=1; i <= num; i++){ 
        var obj = $I(objName + i); 
        obj.className = css; 
    }
    var cur_obj = $I(objName + id); 
    cur_obj.className = css1;   
    for(var i=1; i <= num; i++){ 
        var obj = $I(objName + objConName + i); 
        obj.style.display = "none"; 
    }
    var cur_obj = $I(objName + objConName + id); 
    cur_obj.style.display = "";
}
function AddTabAction(objName,objConName,css,curCss,count,isClick){
    if(isClick){  
        for(var i=1; i<=count; i++){ 
            var obj = $I(objName + i); 
            obj.onclick = Function("return sc('" + objName + "','" + objConName + "','" + css + "','" + curCss + "'," + i + "," + count + ")");
        } 
    }
    else{ 
        for(var i=1; i<=count; i++){ 
            var obj = $I(objName + i); 
            obj.onmouseover = Function("return sc('" + objName + "','" + objConName + "','" + css + "','" + curCss + "'," + i + "," + count + ")"); 
        } 
    }
}
function SelectOperate(chbName,oper){ 
    var chbItem = $N(chbName);  var count = chbItem.length;
	switch(oper){ 
	    case 1: for(var i=0; i<count;i++){ chbItem[i].checked = true; } break;
		case 2: for(var i=0; i<count;i++){ chbItem[i].checked = false; } break;
		case 3: for(var i=0; i<count;i++){ chbItem[i].checked = chbItem[i].checked == true ? false : true; } break;
	}
}
function SelectOperateId(chbId,count,oper){
	switch(oper){ 
	    case 1: for(var i=0; i<count;i++){ var chbItem = $I(chbId+(i+1)); chbItem.checked = true; } break;
		case 2: for(var i=0; i<count;i++){ var chbItem = $I(chbId+(i+1));chbItem.checked = false; } break;
		case 3: for(var i=0; i<count;i++){ var chbItem = $I(chbId+(i+1));chbItem.checked = chbItem.checked == true ? false : true; } break; 
	}
}
function GetSelectedItem(chbName,delimiter,txtResult){
	var chbItem = $N(chbName); var txtResult = $I(txtResult); var items = []; var p = 0; var count = chbItem.length;
	for(var i=0; i<count;i++){
	    if(true == chbItem[i].checked){ items[p] = chbItem[i].value;}
	    else{ p--;}
	    p++; 
	}
	if(txtResult == null || txtResult == undefined){ return items.join(delimiter); } 
	else{ txtResult.value = items.join(delimiter); }
}
function GetSelectedText(chbName,delimiter,txtResult){
	var chbItem = $N(chbName); var txtResult = $I(txtResult); var items = []; var p = 0; var count = chbItem.length;
	for(var i=0; i<count;i++){ 
	    if(true == chbItem[i].checked){ items[p] = chbItem[i].alt; }
	    else{ p--;} 
	    p++; 
	}
	if(txtResult == null || txtResult == undefined){ return items.join(delimiter); } 
	else{ txtResult.value = items.join(delimiter); }
}
function ShowSelectedItem(chbName,delimiter,txtResult){
	var chbItem = $N(chbName);var txtResult = $I(txtResult);var items = txtResult.value.replace(/\(|\)/g, "").split(delimiter);
	if(items.length > 0){ 
	    var p=0; var count = items.length; 
	    for(var i=0; i<count;i++){ 
	        var count1 = chbItem.length; 
	        for(var j=0; j< count1;j++){  
	            if(chbItem[j].value == items[i]){ chbItem[j].checked = true; }
	        }
	    }
	}
}
function GSI(chbName,delimiter,txtResult){GetSelectedItem(chbName,delimiter,txtResult);}
function GST(chbName,delimiter,txtResult){GetSelectedText(chbName,delimiter,txtResult);}
function SSI(chbName,delimiter,txtResult){ShowSelectedItem(chbName,delimiter,txtResult);}
function SO(chbName,oper){SelectOperate(chbName,oper);}

function CheckSeleteCount(chbName,txtNewOrder,btnName,prompt,prompt1){
	var chbItem = $N(chbName); var btn = $I(btnName); var order = txtNewOrder != null ? $I(txtNewOrder) : null; 
	var p = 0; var count = chbItem.length; 
	for(var i=0; i<count;i++){ 
	    if(p>1){ 
	        break; 
	    }
	    else{ 
	        if(true != chbItem[i].checked) { p--; }
	        p++;
	    }
	 }
	if(p > 1){ 
	    alert(prompt); return false;
	}  
	else if(p == 0){ 
	    alert(prompt1); return false;
	}
	else{ 
	    if(order != null){
	        if(order.value == ""){ order.focus();}
	        else{btn.click();}
	    }
	    else{ 
	        btn.click();
	    }
	}
}
function TxtFocus(obj,objValue){if(obj.value == objValue){obj.value='';}}

function ChangeHeight(objName,num,basicNum,wh){
    var wh = "h"; var basicNum = 100; 
    if(basicNum == "undefined" || basicNum == null)basicNum = 100;  wh = (wh == "undefined" || wh == null) ? "h" : wh;
    var obj = ("object" == typeof(objName)) ? objName : document.getElementById(objName); 
    var oldNum = parseInt(obj.style.height.replace(".px",""),10);
    if(wh == "h"){
        if(num > 0){ 
            obj.style.height = oldNum + num + ".px"; 
        } 
        else{
            if(oldNum + num >= basicNum){ 
                obj.style.height = oldNum + num + ".px"; 
            } 
        }
    }
    else{ 
        oldNum = parseInt(obj.style.width.replace(".px",""),10);
        if(num > 0){ 
            obj.style.width = oldNum + num + ".px"; 
        } 
        else{ 
            if(oldNum + num >= basicNum){ 
                obj.style.width = oldNum + num + ".px"; 
            } 
        }
    }
}
function TTSH(objName,obj1Name,asc){return ToTheSameHeight(objName,obj1Name,asc);}
function ToTheSameHeight(objName,obj1Name,asc){
    var obj = $("#" + objName)[0];
    var obj1 = $("#" + obj1Name).get(0);
    var h = obj.offsetHeight;
    var h1 = obj1.offsetHeight;
    if(asc){ obj.style.height = h1 + "px"; }
    else{ obj1.style.height = h + "px"; }
}
function PhotoSlide(object,config){
	this.obj = object; jQuery(this.obj).css({display:""})
	this.config = config ? config : {width:"300px",height:"200px",fontsize:"12px",right:"10px",bottom:"10px",time:"4000",showButton:true};
	this.pause = false; var _this = this;
	if(!this.config.right){ this.config.right = "0px"; } if(!this.config.bottom){ this.config.bottom = "3px"; }
	if(this.config.fontsize == "12px" || !this.config.fontsize){ this.size = "12px"; this.height = "21px"; this.right = "6px"; this.bottom = "10px"; }
	else if(this.config.fontsize == "14px"){ this.size = "14px"; this.height = "23px"; this.right = "6px"; this.bottom = "15px"; }
	this.count = jQuery(this.obj + " li").size(); this.n =0; this.j =0; var t;
	this.factory = function(){
		jQuery(this.obj).css({position:"relative",zIndex:"0",margin:"0",padding:"0",width:this.config.width,height:this.config.height,overflow:"hidden"})
		jQuery(this.obj).prepend("<div style='" + (this.config.showButton == true? "" : "display:none;") + "position:absolute;z-index:20;right:"+this.config.right+";bottom:"+this.config.bottom+"'></div>");
		jQuery(this.obj + " li").css({width:"100%",height:"100%",overflow:"hidden"}).each(function(i){jQuery(_this.obj + " div").append("<a>"+(i+1)+"</a>")});
		jQuery(this.obj + " img").css({border:"none",width:"100%",height:"100%"})
		this.resetclass(this.obj + " div a",0);		
		jQuery(this.obj + " span").each(function(i){			
			jQuery(this).parent().append(jQuery(this).clone(true));  jQuery(this).html("");
			jQuery(this).css({position:"absolute",margin:"0",padding:"0",zIndex:"1",bottom:"0",left:"0",height:_this.height,width:"100%",background:"#000",opacity:"0.4",overflow:"hidden"})
			jQuery(this).next().css({position:"absolute",margin:"0",padding:"0",zIndex:"2",bottom:"0",left:"0",height:_this.height,lineHeight:_this.height,textIndent:"5px",width:"100%",textDecoration:"none",fontSize:_this.size,color:"#fff",background:"none",zIndex:"1",opacity:"1",overflow:"hidden"})
			if(i!= 0){jQuery(this).hide().next().hide()}
		});
		this.slide(); this.addhover();  t = setInterval(this.autoplay,this.config.time);
	}	
	this.slide = function(){
		jQuery(this.obj + " div a").mouseover(function(){
			_this.j = jQuery(this).text() - 1;  _this.n = _this.j;
			if (_this.j >= _this.count){return;}
			jQuery(_this.obj + " li").hide();  jQuery(_this.obj + " span").hide(); /*jQuery(_this.obj + " li").eq(_this.j).fadeIn("slow");*/
			jQuery(_this.obj + " li").eq(_this.j).show();  
			jQuery(_this.obj + " li").eq(_this.j).find("span").show();  _this.resetclass(_this.obj + " div a",_this.j);
		});
	}
	this.addhover = function(){ jQuery(this.obj).hover(function(){clearInterval(t);}, function(){t = setInterval(_this.autoplay,_this.config.time)}); }	
	this.autoplay = function(){ _this.n = _this.n >= (_this.count - 1) ? 0 : ++_this.n; jQuery(_this.obj + " div a").eq(_this.n).triggerHandler('mouseover'); }	
	this.resetclass =function(obj,i){
		jQuery(obj).css({float:"left",marginRight:"3px",width:"15px",height:"14px",lineHeight:"15px",textAlign:"center",fontWeight:"800",fontSize:"12px",color:"#000",background:"#fff",cursor:"pointer"});  jQuery(obj).eq(i).css({color:"#fff",background:"#ff7d01",textDecoration:"none"});
	}
	this.factory();
}
/* pop window */
function PopWin(title, msg, w, h, autoclose, timing, url, showCloseButton){ 
	var objSelect = document.getElementsByTagName("select");
	for(var j=0;j<objSelect.length;j++){
		objSelect[j].style.display="none";
	} 	
	var iWidth = document.documentElement.clientWidth;
	var iHeight = document.documentElement.clientHeight;
	
	var bgObj = document.createElement("div");
	bgObj.id = "BgDiv";
	bgObj.style.width = iWidth+"px";
	bgObj.style.height = Math.max(document.body.clientHeight, iHeight)+"px";
	document.body.appendChild(bgObj);
	
	var msgObj=document.createElement("div"); 
	msgObj.id = "MsgDiv";
	msgObj.style.top = (iHeight-h)/2+"px";
	msgObj.style.left = (iWidth-w)/2+"px";
	msgObj.style.width = w+"px";
	msgObj.style.height = h+"px";
	document.body.appendChild(msgObj);

	var table = document.createElement("table"); 
	msgObj.appendChild(table); 
	table.id = "MsgDivTable";
	var tr = table.insertRow(-1); 
	var titleBar = tr.insertCell(-1);
	tr.id = "MsgTitle";
	titleBar.id = "MsgDivTitle";
	titleBar.innerHTML = title; 
	
	/*location.href 方式跳转系统无法判断链接来源,改用 A onclick 事件处理*/
	var gotoLink = "<a id=\"MsgGotoLink\" href=\"" + url + "\"></a>";
	titleBar.innerHTML += gotoLink; 
	
	var moveX = 0;
	var moveY = 0;
	var moveTop = 0;
	var moveLeft = 0;
	var moveable = false;
	var docMouseMoveEvent = document.onmousemove;
	var docMouseUpEvent = document.onmouseup;
	titleBar.onmousedown = function() {
		var evt = GetEvent();
		moveable = true;
		moveX = evt.clientX;
		moveY = evt.clientY;
		moveTop = parseInt(msgObj.style.top);
		moveLeft = parseInt(msgObj.style.left);
		document.onmousemove = function() {
			if (moveable) {
				var evt = GetEvent();
				var x = moveLeft + evt.clientX - moveX;
				var y = moveTop + evt.clientY - moveY;
				if ( x > 0 &&( x + w < iWidth) && y > 0 && (y + h < iHeight) ) {
					msgObj.style.left = x + "px";
					msgObj.style.top = y + "px";
				}
			}
		};	
		document.onmouseup = function () {
			if (moveable) {
				document.onmousemove = docMouseMoveEvent;
				document.onmouseup = docMouseUpEvent;
				moveable = false;
				moveX = 0;
				moveY = 0;
				moveTop = 0;
				moveLeft = 0;
			}
		};
	}
	var closeBtn = tr.insertCell(-1); 
	closeBtn.id = "MsgDivClose";
	if(!showCloseButton){
	    closeBtn.innerHTML = "<span title='关闭' style='display:none;'>&nbsp;</span>"; 
	}else{
	    closeBtn.innerHTML = "<span title='关闭'>&nbsp;</span>"; 
	}
	closeBtn.onclick = function(){ 
		for(var j=0;j<objSelect.length;j++){
			objSelect[j].style.display="";
		} 
		document.body.removeChild(bgObj); 
		document.body.removeChild(msgObj); 
	}
	var msgBox = table.insertRow(-1).insertCell(-1); 
	msgBox.id = "MsgBox"; 
	msgBox.colSpan = "2"; 
	msgBox.innerHTML = msg; 

	function GetEvent() {
		return window.event || arguments.callee.caller.arguments[0];
	}
	if(autoclose){
	    window.setTimeout(RemoveObj, timing,objSelect,bgObj,msgObj);
	}
	function RemoveObj(objSelect,bgObj,msgObj) {
	    if(url.trim() != ""){
	        if(url.trim() == "reload"){
	            location.reload(); 
	        }
	        else{
		        if(isMSIE){
                    $I("MsgGotoLink").click();
                }
                else{ /*兼容火狐,jquery方式处理*/
                    $("#MsgGotoLink").click(function(){ 
                        document.location = $(this).attr("href");/* window.location = $(this).attr("href"); */ 
                    });  
                    $("#MsgGotoLink").click();   
                }
		    }
		}	
		else{
		    for(var j=0;j<objSelect.length;j++){
			    objSelect[j].style.display = "";
		    } 
		    document.body.removeChild(bgObj); 
		    document.body.removeChild(msgObj); 
		}
	}
}
function MsgDivClose(){
	$("#MsgDivClose").trigger("click");
}
function CloseWin(){
    MsgDivClose();
}   
function ChangeWinSize(w,h){
    var MsgDiv = $I("MsgDiv");
	MsgDiv.style.width = w+"px";
	MsgDiv.style.height = h+"px";
}
function HiddenWin(){
    var MsgDiv = $I("MsgDiv");
    MsgDiv.style.display = "none";
}
function ShowWin(){
    var MsgDiv = $I("MsgDiv");
    MsgDiv.style.display = "";
}
/* pop window end */

/* insertAtCaret */
function InsertAtCaret(obj,str) { 
    if(document.selection) { 
	    obj.focus(); 
	    var sel=document.selection.createRange(); 
	    document.selection.empty(); 
	    sel.text = str; 
    } 
    else { 
	    var prefix, main, suffix; 
	    prefix = obj.value.substring(0, obj.selectionStart); 
	    main = obj.value.substring(obj.selectionStart, obj.selectionEnd); 
	    suffix = obj.value.substring(obj.selectionEnd); 
	    obj.value = prefix + str + suffix; 
    } 
    obj.focus(); 
} 

function SISS(img,w,h){ ScaleImageShowSize(img,w,h); }
function ScaleImageShowSize(img,w,h){
    var newImage = new Image();	newImage.src = img.src;	var oldWidth = newImage.width; var oldHeight = newImage.height;
	var newWidth; var newHeight;	
	if(Number(oldWidth) > Number(w) || Number(oldHeight) > Number(h)){
		if(Number(oldWidth) > Number(oldHeight)){
			newWidth = w; var ratio = w/oldWidth; newHeight = oldHeight*ratio; img.width = newWidth; img.height = newHeight;
		} else{ newHeight = h; var ratio = h/oldHeight; newWidth = oldWidth*ratio; img.width = newWidth; img.height = newHeight; }
	} else{ img.width = oldWidth; img.height = oldHeight; }	
}
/* char length */
String.prototype.gblen = function() { var len = 0; 
    for(var i = 0; i < this.length; i++) {if(this.charCodeAt(i) > 127 || this.charCodeAt(i) == 94){len += 2;} else { len ++;}} return len;   
}   
/* cut char */
String.prototype.gbtrim = function(len, s) {   
    var str = '';  var sp  = s || ''; var len2 = 0;   
    for (var i=0; i<this.length; i++) { if (this.charCodeAt(i) > 127 || this.charCodeAt(i) == 94) { len2 += 2; } else { len2 ++; } }   
    if (len2 <= len) {  return this; } len2 = 0; len  = (len > sp.length) ? len-sp.length: len;   
    for (var i=0; i<this.length; i++) { if (this.charCodeAt(i)>127 || this.charCodeAt(i)==94) { len2 += 2; } else { len2 ++; }   
        if (len2 > len) { str += sp; break; } str += this.charAt(i);  } return str;   
}   
function AddFavorite(sURL, sTitle) {
    try { window.external.addFavorite(sURL, sTitle); }
    catch (e) {
        try { window.sidebar.addPanel(sTitle, sURL, ""); }
        catch (e) { alert("加入收藏失败，请使用Ctrl+D进行手动添加"); }
    }
}
/*------------------------------------------------------以上代码为公共代码，不可随意修改------------------------------------------------------*/
var webDir = $I("webdir") == null ? $I("webdir1").value : $I("webdir").value;
var webUrl = $I("weburl") == null ? $I("weburl1").value : $I("weburl").value;
var webUserUrl = $I("webuser") == null ? $I("webuser1").value : $I("webuser").value;

function ShowLoginWelcome(str){
    if(str == undefined)str = "";
    /*网页顶部登录*/
    if($I("toplogin") != null || $I("toplogin") != "undefined"){
        var objLogin = $I("toplogin");
        var loginText = "出门吧欢迎您，请 <a href='" + webUserUrl + "/user/login.aspx'>登录</a> 或 " +
                    "<a href='" + webUserUrl + "/user/register.aspx'>注册</a> |";
        objLogin.innerHTML = loginText + str;
        return true;
    }
}
var UnLoginPrompt = "对不起，您还没有登录，<br />请<a href=\"" + webUserUrl + "/user/login.aspx\">点此立即登录</a>！" + 
    "<br />如果您没还有注册成为本站会员，<br />请<a href=\"" + webUserUrl + "/user/register.aspx\">点此立即免费注册</a>！";

function ShowLoginInfo(objLogin,uid,uname,str){
    if(str == undefined || str == null)str = "";
    objLogin.innerHTML = "<a href=\"" + webUserUrl + "/" + uid + "/\"><b>" + uname + "</b></a>|" + 
                        "<a href=\"" + webUserUrl + "/" + uid + "/\">我的家园</a>|" + 
                        "<a href=\"" + webUserUrl + "/uc/\">个人中心</a>" + 
                        "<a href=\"javascript:void(0);\" onclick=\"Logout();\">退出</a>|"+ 
                        "<a href=\"" + webUserUrl + "/\">家园首页</a>|" + str;  
}
function UserLogin(str){    
    if(str == undefined || str == null)str = "";
    if($I("toplogin") == null || $I("toplogin") == "undefined") return false;
    var url = webDir + "/ajax/userlogin.aspx";    
    xmlHttp.open("post", url, true);
    xmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
    xmlHttp.send("action=userstatus");
    xmlHttp.onreadystatechange = function(){
        if(4 == xmlHttp.readyState){
            if(200 == xmlHttp.status){
                result = xmlHttp.responseText;
                if(result != "-1" && result != "-2" && result != "0"){
			        var results = result.split('|');
			        var objLogin = $I("toplogin");
			        ShowLoginInfo(objLogin,results[0],results[1],str);
			        return true;
		        }else{		            
		            ShowLoginWelcome(str);
		        }
            }
        }
    }
}

if($I("AfterLogin") == null || $I("AfterLogin") == "undefined"){
    UserLogin("");
}
function Logout(){
    var url = webDir + "/ajax/userlogin.aspx";
    xmlHttp.open("post", url, true);
    xmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
    xmlHttp.send("action=logout");
    xmlHttp.onreadystatechange = function(){
        if(4 == xmlHttp.readyState){
            if(200 == xmlHttp.status){
                result = xmlHttp.responseText;
                if(result == "1"){
		            ShowLoginWelcome();
		            window.location.reload();
		        }
            }
        }
    }
}

/*关于搜索提示*/
var searchPrompt = Array();
searchPrompt[0] = "输入商家名称、地址、属性、氛围等";
searchPrompt[1] = "输入优惠名称、分类、属性等";

var formSearch = $I("frmMainSearch");
function ShowSearchPrompt(){
    var c = $I("c");
    var q = $I("q");
    var search = $I("search");
    SetSearchPrompt();
    function SetSearchPrompt(){
        if(c.value == "store"){
            formSearch.action =  webUrl + "/searchstore.html";
            if(q.value.trim() == "" || (q.value.trim() != "" && q.value.trim() == searchPrompt[1])){
                q.value = searchPrompt[0]; q.style.color = "#999";
            }
        } 
        else if(c.value == "youhui"){
            formSearch.action = webUrl + "/searchyouhui.html";
            if(q.value.trim() == "" || (q.value.trim() != "" && q.value.trim() == searchPrompt[0])){
                q.value = searchPrompt[1]; q.style.color = "#999";
            }
        }
    }
    search.onclick = function(){ if(q.value.trim() == searchPrompt[0] || q.value.trim() == searchPrompt[1] ){ q.value = ""; } }
    c.onchange = function(){ SetSearchPrompt(); }
    q.onfocus = function(){ if(q.value.trim() == searchPrompt[0] || q.value.trim() == searchPrompt[1] ){q.value = ""; q.style.color = "#000";}}
    q.onblur = function(){ if(q.value.trim() == ""){SetSearchPrompt();}}
     
    var ti = 0;
    /*每日一帖*/
    function GetNewTips(){
        
        $I("newtips").innerHTML = '<img src="' + webDir +'/images/notice.gif" style="margin:8px 8px -2px 16px; width:15px; display:inline-block; float:left;"/><a href="http://www.chumenba.com/card/store/" target="_blank" style="color:#f50; line-height:24px; display:inline-block;margin-top:5px; float:left;font-weight:bold;">出门卡折扣商家一览</a>';
    }
    //GetNewTips();

    /*加载搜索热门关键字*/
    function GetHotKeywords(){
        $I("hsk").innerHTML = '<a href="http://www.chumenba.com/news/bulletin/2028.html" target="_blank" style="color:#f50; line-height:24px; display:inline-block;margin-top:5px; float:left;font-weight:bold;">公告：出门吧取消电话预订服务</a>';
    }
    //GetHotKeywords();
}
if(isMSIE){
   if(formSearch != null){ ShowSearchPrompt(); }
}
else{
    ShowSearchPrompt();
}

function UserAddFavorite(special,objId,favoriteUrl,favoriteTitle){    
    var url = webDir + "/ajax/useraction.aspx";
    xmlHttp.open("post", url, true);
    xmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
    var strAction = "action=addfavorite&special=" + special + "&objId=" + objId + "&url=" + favoriteUrl + "&title=" + escape(favoriteTitle);
    xmlHttp.send(strAction);
    xmlHttp.onreadystatechange = function(){
        if(4 == xmlHttp.readyState){
            if(200 == xmlHttp.status){
                result = xmlHttp.responseText;
                if(parseInt(result,10) > 0){
                    switch(special){
                        case "store": 
                            PopWin("收藏成功", "恭喜您，商家“" + favoriteTitle + "”已加入您的收藏！", 320, 80, true, 3000, "");
                            break;
                        case "comment": 
                            PopWin("收藏成功", "点评已收藏，谢谢！", 320, 80, true, 3000, "");
                            break;
                        case "article": 
                            PopWin("收藏成功", "文章已收藏，谢谢！", 320, 80, true, 3000, "");
                            break;
                    }
                }
                else if(result == "-1"){
                    PopWin("您还没有登录，请您先登录！", UnLoginPrompt, 320, 150, false, 3000, webUserUrl + "/user/login.aspx");
                }
                else{
                    PopWin("收藏没有成功", "对不起，您的收藏没有成功，<br />可能服务器正忙，请您稍候再试！", 320, 100, true, 3000, "");
                }
            }
        }
    }
}
function UserDeleteFavorite(favoriteId){
    if(confirm("您确定要删除这个收藏吗？")){
        var url = webDir + "/ajax/useraction.aspx";
        xmlHttp.open("post", url, true);
        xmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
        var strAction = "action=deletefavorite&favoriteId=" + favoriteId;
        xmlHttp.send(strAction);
        xmlHttp.onreadystatechange = function(){
            if(4 == xmlHttp.readyState){
                if(200 == xmlHttp.status){
                    result = xmlHttp.responseText;
                    if(parseInt(result,10) > 0){
                        PopWin("删除收藏成功", "", 150, 30, true, 0, "reload");
                    }
                    else if(result == "-1"){
                        PopWin("您还没有登录，请您先登录！", UnLoginPrompt, 320, 150, false, 3000, webUserUrl + "/user/login.aspx");
                    }
                    else{
                        PopWin("删除收藏失败", "对不起，您的收藏没有删除成功，<br />可能服务器正忙，请您稍候再试！", 320, 100, true, 2000, "");
                    }
                }
            }
        }
    }
}

/*新闻内容中插图自动加上“点击打开原图片”事件*/
function ImageHref(){
    $(".newscontent img").click( function() { window.open(this.src) } ); 
}
/*ImageHref();*/

function ShowControls(btn,objName){
    var obj = $I(objName); if(obj.style.display == ""){ obj.style.display = "none"; } else{ obj.style.display = ""; }
}

function copyToClipboard(obj,txt,isPop) 
{ 
    if(obj != null) { window.clipboardData.setData('text', document.getElementById(obj).value); }
    else{  window.clipboardData.setData('text', txt);  }
    if(isPop){ alert("内容已经复制到剪贴板，您可以按 Ctrl + V 键粘贴。"); }
} 

