﻿var currentLine = -1;
function goPage(paramName,pageNum,formIndex){
		var formObject = eval("document.forms["+formIndex+"]");
		eval("document.forms["+formIndex+"]."+paramName).value=pageNum;
		formObject.submit(); 
}

function appendParam(actionUrl,formIndex){
	//alert(document.forms.length);
	var formObject = eval("document.forms["+formIndex+"]");
	if(formObject+'' != "undefined"){
		var ele = formObject.elements;
		for (var i = 0; i < ele.length; i++) {
			if (ele[i].tagName == "INPUT"){
				if(ele[i].type == "text" || ele[i].type == "hidden"){
					if(ele[i].value != null && ele[i].value != "")
						actionUrl = actionUrl + "&" + ele[i].name + "=" + ele[i].value;
				}
			}
			else if (ele[i].tagName == "SELECT"){
				if(ele[i].options[ele[i].selectedIndex].value != null 
				&& ele[i].options[ele[i].selectedIndex].value != "")
					actionUrl = actionUrl + "&" + ele[i].name + "=" + ele[i].options[ele[i].selectedIndex].value;
			}

		}		
	}
	return actionUrl;
}

function viewCateProduct(encodeTag,tabname,tabProdName) {
			var tabObject = document.getElementById(tabname);
			var tabs = tabObject.childNodes;
			var isup = true;
			for(tab in tabs) {
				if(tabs[tab].nodeType!=1) {
					continue;
				}
				if(tabs[tab].id == 'tab_'+encodeTag) {
					tabs[tab].className = 'navion rightborder';
					isup = false;
				}
				else {
					if(isup) {
						tabs[tab].className=tabs[tab].className = 'navioff leftborder';
					}
					else {
						
						tabs[tab].className=tabs[tab].className = 'navioff rightborder';
					}
					
				}
			}
			var prodObject = document.getElementById(tabProdName);
			var divs = prodObject.childNodes;
			for(p in divs) {
				if(divs[p].nodeType!=1) {
					continue;
				}
				if(divs[p].id == encodeTag) {
					divs[p].style.display = "block";
				}
				else {
					divs[p].style.display = "none";
				}
			}
			
}

String.prototype.trim = function(){
   //return this.replace(/(^\s*)|(\s*$)/g, "");
   //去&nbsp;与' '空格
   return this.replace(/(^\s*)|(\s*$)/g, "").replace(/(^(&nbsp;)*)|((&nbsp;)*$)/g, "");
}

function LTrim(str) {
	var whitespace = new String(" \t\n\r");
	var s = new String(str);
	if (whitespace.indexOf(s.charAt(0)) != -1) {
		var j = 0, i = s.length;
		while (j < i && whitespace.indexOf(s.charAt(j)) != -1) {
			j++;
		}
		s = s.substring(j, i);
	}
	return s;
}
function RTrim(str) {
	var whitespace = new String(" \t\n\r");
	var s = new String(str);
	if (whitespace.indexOf(s.charAt(s.length - 1)) != -1) {
		var i = s.length - 1;
		while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1) {
			i--;
		}
		s = s.substring(0, i + 1);
	}
	return s;
}

function clearview(path){
	var href = location.href;
	if(confirm("您确定清除？"))
		location.href=path + "/clearView.html?redirectUrl="+href;
}


function drag(obj, pos) {  
    if (typeof obj == "string") 
    	obj = document.getElementById(obj); 
    obj.orig_x = parseInt(obj.style.left) - document.body.scrollLeft;
    obj.orig_index = obj.style.zIndex;    
    obj.onmousedown = function(a)  
    {  
        var d=document;  
        if(!a)
        	a=window.event;  
        var x = a.clientX+d.body.scrollLeft-obj.offsetLeft;  
        d.ondragstart = "return false;"  
        d.onselectstart = "return false;"  
        d.onselect = "document.selection.empty();"  
                  
        if(obj.setCapture)  
            obj.setCapture();  
        else if(window.captureEvents)  
            window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);  

        d.onmousemove = function(a)  
        { 
            if(!a)
            	a=window.event;  
            var tmpLeft = parseInt(a.clientX+document.body.scrollLeft-x);
          	if((pos=="left" && tmpLeft>=leftInit&&tmpLeft<(rightPos-barWidth))||(pos=="right" && tmpLeft<=rightInit&&tmpLeft>(leftPos+barWidth))){
            	obj.style.left = tmpLeft + "px";
        	if(pos=="left") {
				document.getElementById("pfrom").value=Math.round((tmpLeft-leftInit)*(maxPrice-minPrice)/(rightInit-barWidth))+minPrice;
				leftPos=tmpLeft;
            }
        	else if(pos=="right"){
				document.getElementById("pto").value=Math.round((tmpLeft-leftInit-barWidth)*(maxPrice-minPrice)/(rightInit-barWidth))+minPrice;
            	rightPos=tmpLeft;
			}
            obj.orig_x = tmpLeft - document.body.scrollLeft;  
            
			var priceBarLeftPos=parseInt(document.getElementById("minPriceBar").style.left);
			var priceBarRightPos=parseInt(document.getElementById("maxPriceBar").style.left);
			document.getElementById("rangeBar").style.left=priceBarLeftPos+"px";
			document.getElementById("rangeBar").style.width=(priceBarRightPos-priceBarLeftPos) + "px";
           }
        }  

        d.onmouseup = function()  
        { 
            if(obj.releaseCapture)  
                obj.releaseCapture();  
            else if(window.captureEvents)  
                window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);  
            d.onmousemove = null;  
            d.onmouseup = null;  
            d.ondragstart = null;  
            d.onselectstart = null;  
            d.onselect = null;  
        }  
    }  
      
}

function openWindowWithScroll(url,winName,width,height){
	var X = (screen.width-width)/2;
	var Y = (screen.height-height)/2-50;
	var newwin = window.open(url,winName,"height="+height+", width="+width+", top="+Y+", left="+X+", toolbar=no, menubar=no, scrollbars=yes, resizable=no,location=no, status=no");
	newwin.focus();
}

function openTopWindowWithScroll(url,winName,width,height){
	var X = (screen.width-width)/2;
	var Y = 0;
	var newwin = window.open(url,winName,"height="+height+", width="+width+", top="+Y+", left="+X+", toolbar=no, menubar=no, scrollbars=yes, resizable=no,location=no, status=no");
	newwin.focus();
}

function formatFloat(src, pos)
{
	var num = Math.round(src*Math.pow(10, pos))/Math.pow(10, pos);
   /* var renum = num + ""; 
    
    if (num == parseInt(num)) 
    { 
        renum += "."; 
        
        for(var i=0;i < pos;i++) { 
            renum += "0" 
        } 
        return renum    
    } 
    len = (parseInt(src)+"").length+ pos +1 -(num+"").length; 
    if (len > 0) 
    {        
        for(var i=0;i <len;i++) 
        { 
            renum += "0" 
        } 
    } 
    */
    return num 
}

function commafy(num){
	num = num + "";
	var re=/(-?\d+)(\d{3})/
	while(re.test(num)){
		num=num.replace(re,"$1,$2")
	}
	return num;
}

function searchkdOnSubmit(){
	var keyword = document.getElementById("keyword");
	if (keyword.value.trim() == '' || keyword.value.trim() == '输入关键字比较商品'){
		if(keyword.value.trim() != '输入关键字比较商品')
			keyword.value = "";
		return false;
	}
	//creatSearchDiv("搜索中，请等待...");
	return true;
}
function searchkdOnSubmitForStore(domain){
	var keyword = document.getElementById("keyword");
	if (keyword.value.trim() == '' || keyword.value.trim() == '输入关键字比较商品'){
		if(keyword.value.trim() != '输入关键字比较商品')
			keyword.value = "";
		return false;
	}
	if(domain != null && domain != "")
		document.serchform.domain.value = domain;
	else
		document.serchform.domain.disabled = true;
	document.serchform.submit();
}

function creatSearchDiv(msg) {
	var divSearchWaiting = document.getElementById("divSearchWaiting");
	if (divSearchWaiting == null) {
		divSearchWaiting = document.createElement("DIV");
		divSearchWaiting.setAttribute("id", "divSearchWaiting");
		divSearchWaiting.className = "divSearchWaitingStyle";
		divSearchWaiting.innerHTML = msg;
		document.body.appendChild(divSearchWaiting);
	}

	var w = 0; 
	var h = 0;      	       	
	var ua = navigator.userAgent.toLowerCase();
	var os = new Object();
	os.isFirefox = ua.indexOf ("gecko") != -1;
	os.isOpera = ua.indexOf ("opera") != -1;
	os.isIE = !os.isOpera && ua.indexOf ("msie") != -1;
	os.isSafa = !os.isOpera && ua.indexOf ("safari") != -1;
	if(os.isOpera){
	     w = document.body.clientWidth;
	     h = document.body.clientHeight;
	}else if(os.isFirefox){
	     w = document.documentElement.clientWidth;
	     h = document.documentElement.clientHeight;
	}else if(os.isIE){
	      w = document.documentElement.clientWidth;
	      h = document.documentElement.clientHeight;
	}else if(os.isSafa){
	      w = document.body.clientWidth;
	      h = document.body.clientHeight;
	}    	
	divSearchWaiting.style.position = "absolute";  
	divSearchWaiting.style.left =  (w-200)/2 + "px"; 
	divSearchWaiting.style.zIndex = 1001;
	divSearchWaiting.style.top = (h-60)/2+ "px";
	divSearchWaiting.style.visibility = "visible";
}

function searchkdOnFocus(obj){

	if (obj.value.trim() == '输入关键字比较商品')
		obj.value = "";
	obj.style.color = '#333';
}

function searchkdOnBlur(obj){
	if (obj.value.trim() == '') {
		obj.value = '输入关键字比较商品';
		obj.style.color = '#999';
	} else {
		obj.style.color = '#333';
	}
}


function showChanneltype() {
	var obj = document.getElementById("channeltypediv");
	if(obj.style.visibility == "hidden")
		obj.style.visibility = "visible";
	else
		obj.style.visibility = "hidden";
	
	var srcobj = document.getElementById("channeltypecontain");
	var leftpos = 0,toppos = 0;
	var pObject = srcobj.offsetParent;
	if (pObject){
		leftpos += pObject.offsetLeft;
		toppos += pObject.offsetTop;
	}
	while(pObject=pObject.offsetParent ){
		leftpos += pObject.offsetLeft;
		toppos += pObject.offsetTop;
	}

	obj.style.left = (srcobj.offsetLeft + leftpos) + "px";
	obj.style.top = (srcobj.offsetTop + toppos + srcobj.offsetHeight - 1) + "px";
}

function selectChanneltype(obj){
	obj.style.backgroundColor="#FFE6C9";
	obj.style.color="#990000"
	keepChanneltype();
}

function unSelectChanneltype(obj){
	obj.style.backgroundColor="#fff";
	obj.style.color="#333333"
}

function hiddenChanneltype(){
	var obj = document.getElementById("channeltypediv");
	obj.style.visibility = "hidden";
}

function keepChanneltype(){
	var obj = document.getElementById("channeltypediv");
	obj.style.visibility = "visible";
}

function doSelectChanneltype(type,obj){
	document.getElementById("channeltypecontain").innerHTML=obj.innerHTML;
	document.getElementById("channeltype").value = type;
	hiddenChanneltype();
}


function resizeImg(id,maxWidth,maxHeight){  
     var showimg = new Image();
   	 showimg.src = id.src;
     var width = showimg.width;
     var height = showimg.height;
     if(width < maxWidth){
     	 id.width = width;
     }
     if(width > maxWidth){
         var scale = cScale(width,height,maxWidth,maxHeight);
         if (scale>1.0){
             scale=1.0;
         }
         width = parseInt(width * scale);
         height = parseInt(height * scale);
         id.width = width;
         id.height = height;
         if(height > maxHeight)
         	id.height = maxHeight;
    }
    if(height > maxHeight){
         var scale = cScale(height,width,maxHeight,maxWidth);
         if (scale>1.0){
             scale=1.0;
         }
         width = parseInt(width * scale);
         height = parseInt(height * scale);
         id.width = width;
         id.height = height;
         if(width > maxWidth)
         	id.width = maxWidth;
    }   
}

function resizeImgProd(id,maxWidth,maxHeight,dheight){  
    resizeImg(id,maxWidth,maxHeight);
    
    var ch = id.height;
    var mh  = (dheight-ch)/2;
    
    id.style.marginTop = mh+"px";
}

function cScale( w,  h,  maxWidth,  maxHeight)
{
    var scale = 1.0;
    scale = maxWidth / w >= maxHeight / h ? maxHeight / h : maxWidth / w;
    return parseFloat(scale);
}


function setTab(m,n){
	var tli=document.getElementById("menu"+m).getElementsByTagName("li");

	for(i=0;i<tli.length-1;i++){
		if(i==0)
			tli[i].className=i==n?"hover_l":"";
		else
			tli[i].className=i==n?"hover":"";
		mli=document.getElementById("md"+i);
		mli.style.display=i==n?"block":"none";
	}
}

function showHelpMsg(msg,obj){
	var floatAreaName = creatInfoDiv(msg);
	showMsgOfId(floatAreaName,obj,null,null,null);
}


function  hiddenHelpMsg(){
	var div = document.getElementById("divScreenHelpMsg");
	div.style.display = "none";
}

function creatInfoDiv(msg) {
	return creatDivWithId(msg,"divScreenHelpMsg");
}

function showMsgOfId(did,obj,width,bg,bordercolor){
	var floatArea = document.getElementById(did);
	var leftpos = 0,toppos = 0;
	var pObject = obj.offsetParent;
	if (pObject){
		leftpos += pObject.offsetLeft;
		toppos += pObject.offsetTop;
	}
	while(pObject=pObject.offsetParent )
	{
		leftpos += pObject.offsetLeft;
		toppos += pObject.offsetTop;
	}
	if(bordercolor != null)
		floatArea.style.borderColor = bordercolor;
	if(bg != null)
		floatArea.style.background = bg;
	if(width != null)
		floatArea.style.width = width+"px";	
	floatArea.style.padding = 0;
	floatArea.style.left = (obj.offsetLeft + leftpos) + "px";
	floatArea.style.top = (obj.offsetTop + toppos + obj.offsetHeight - 1) + "px";
	floatArea.style.display = "";
}

function creatDivWithId(msg,did){
	var div = document.getElementById(did);
	if (div == null || div + "" == "undefined") {
		div = document.createElement("DIV");
		div.setAttribute("id", did);
		div.className = "helpMsgBox";
		document.body.appendChild(div);
	}
	div.innerHTML = msg;	
	return did;
}

function copyToClipboard(theField) { 
	var txt = document.getElementById(theField).value;
    //IE
    if(window.clipboardData){
        window.clipboardData.clearData();
        window.clipboardData.setData("Text", txt);
        alert("IE复制成功！");
    }
    //Firefox
    else if(window.netscape){
        try{
            netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
        }catch(e){
            alert("被浏览器拒绝！\n请在浏览器地址栏输入'about:config'并回车\n然后将'signed.applets.codebase_principal_support'设置为'true'");
        }
        var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
        if(!clip){
            return;
        }
        var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
        if (!trans){
            return;
        }
        trans.addDataFlavor('text/unicode');
        var str = new Object();
        var len = new Object();
        var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
        var copytext = txt;
        str.data = copytext;
        trans.setTransferData("text/unicode",str,copytext.length*2);
        var clipid = Components.interfaces.nsIClipboard;
        if (!clip){
            return false;
        }
        clip.setData(trans,null,clipid.kGlobalClipboard);
        alert("Firefox复制成功！");
    }
} 


function validateDateStr(str)
   {
		
		var re=/^(\d{4})-(\d{2})-(\d{2})\s(\d{2}):(\d{2})$/
		if(!re.test(str))
		 return false;
		 
		var strYear=RegExp.$1;
		var strMonth=RegExp.$2;
		
		  strMonth=parseInt(strMonth,10)-1;
		  
		var strDate=RegExp.$3;
		   strDate=parseInt(strDate,10);
		var strHour=RegExp.$4;
		   strHour=parseInt(strHour,10);
		var strMinute=RegExp.$5;
		    strMinute=parseInt(strMinute,10);
		var tempDate=new Date(strYear,strMonth,strDate,strHour,strMinute,0);
		 return (tempDate.getFullYear()==strYear)&&(tempDate.getMonth()==strMonth)&&(tempDate.getDate()==strDate)&&(tempDate.getHours()==strHour)&&(tempDate.getMinutes()==strMinute);
}

function completeKey(e,src,cpath,width,bordercolor,kxflag){
	
	var keyc;
	if(window.event){
		keyc=e.keyCode;
	}else if(e.which){
		keyc=e.which;
	}

	if(keyc!=40 && keyc!=38){
		currentLine = -1;
		var http_request = null;
		var keyword = src.value;
		if(keyword.trim() !=""){
			if(window.XMLHttpRequest){ 
				http_request=new XMLHttpRequest(); 
				if(http_request.overrideMineType){ 
					http_request.overrideMineType("text/xml"); 
				} 
			}else if(window.ActiveXObject){ 
				try{ 
					http_request=new ActiveXObject("Msxml2.XMLHTTP"); 
				}catch(e){ //IE5.x 
					http_request=new ActiveXObject("Microsoft.XMLHTTP"); 
				} 
			} 
			http_request.open("GET",cpath+"/completeKey.ok?key="+encodeURI(keyword),true); 
			http_request.onreadystatechange=function(){
				if(http_request.readyState==4){ 
					if(http_request.status==200){ 
					 	var keystr= http_request.responseText;
						showCompleteKeys(keystr,cpath,src,width,bordercolor,kxflag);
					}else{ 
						//alert("ajax错误!"); 
						return ;
					} 
				} 
			}; 
			
			http_request.send(null);
		}else
			hiddenSearchKeyDiv();
		
	}
}

function  hiddenSearchKeyDiv(){
	var divSearchKey = document.getElementById("divSearchKey");
	if(divSearchKey != null)
		divSearchKey.style.display = "none";
}

function setSearchKeyValue(key){
	var keyword = document.getElementById("keyword");
	if(keyword != null)
		keyword.value = key;
}

function showCompleteKeys(keystr,cpath,obj,width,bordercolor,kxflag){
	if(keystr.length > 0){
		var keys = keystr.split(",,,");
		var msg = "";
		var namespace ="search";
		if(kxflag != null && kxflag == 1){
		 	namespace ="kxsearch";
		}
	
		for(var i =0;i<keys.length;i++){
			keys[i] = keys[i].replace("\\","\\\\");
			msg += "<a class='storejump' name='seachkeyjump'  onmouseover=\"setSearchKeyValue(\'"+keys[i]+"\')\" href='"+cpath+"/"+namespace+"/?keyword="+encodeURI(keys[i])+"'>"+""+keys[i]+"</a>";
		}
		msg = msg + "<a class='storejump' name='seachkeyjump' style='text-align:right;' href='javascript:void(0)' onclick='hiddenSearchKeyDiv();'>关闭&nbsp;&nbsp;</a>";
		showSearchKeyDiv(msg,obj,width,bordercolor);
	}else
		hiddenSearchKeyDiv();
}

function showSearchKeyDiv(msg,obj,width,bordercolor){
	var divname = creatDivWithId(msg,"divSearchKey");
	showMsgOfId(divname,obj,width,"white",bordercolor);
}
 
function dealKeydown(e,ename,sname){
	var it =  document.getElementsByName(sname); 
	var keyc;
	if(window.event){
		keyc=e.keyCode;
	}else if(e.which){
		keyc=e.which;
	}
	if(keyc==40 || keyc==38){
		if(keyc==40){
			if(currentLine<it.length-1){
				currentLine++;
				if(currentLine>=it.length-1){
					currentLine=-1;
				}
			}
			if(currentLine>=it.length-1){
				currentLine=-1;
			}
		}
		if(keyc==38){
			if(currentLine>=0){
				currentLine--;
				if(currentLine<=-1){
						currentLine=it.length-1;
				}
			}else{
				currentLine=it.length-1;
			}
		}
		set_style(currentLine,sname);
		if(currentLine>=0 && currentLine<it.length-1){			
			document.getElementById(ename).value = it[currentLine].childNodes[0].nodeValue.trim();
		}
		else{
			document.getElementById(ename).value = document.getElementById(ename).value.trim();				
		}
	}
}
function set_style(num,sname){
	var it =  document.getElementsByName(sname); 
	for(var i=0;i<it.length-1;i++){
		var li_node=it[i];
		li_node.className="storejump";
	}
	if(currentLine>=0 && currentLine<it.length-1){
		var i_node=it[currentLine];
		it[currentLine].className="highLi";
	}
}
	
function SetCookie(name,value) {  //两个参数，一个是cookie的名子，一个是值  

     var Days = 30; //此 cookie 将被保存 30 天  
     var exp  = new Date();    //new Date("December 31, 9998");  
     exp.setTime(exp.getTime() + Days*24*60*60*1000);  
     document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString()+";path=/";  
 }
 
 function SetCookieWitnMinute(name,value,minute) {
     var exp  = new Date();  
     exp.setTime(exp.getTime() + minute*60*1000);  
     document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString()+";path=/";  
 } 
   
 function getCookie(name){ //取cookies函数          
  
     var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));  
      if(arr != null) return unescape(arr[2]); return null;  
   
 }  
 
 
 function delCookie(name)//删除cookie  
 {  
     var exp = new Date();  
     exp.setTime(exp.getTime() + 30*24*60*60*1000- 1*24*60*60*1000);  
     var cval=getCookie(name);  
     if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString()+";path=/";  
 }  
  
 
 
 function setMenuCookie(varname,menuflag,url){
 	
    SetCookie(varname,menuflag);
    if(url!=''){
     window.location.href = url;
     
    
    }
 
 }
 
    function validateMobile( moblieValue){

       if(moblieValue.trim()==''){
	    return false;
       }
	     
	    var re =/^(13|15|18|14)[0-9]{9}$/;
	    if(!re.test(moblieValue)){
	    
	        return false;
	    }else{
	    
	        return true;
	    
	    }
    }
       
    function getRandamStr(length){
	    var rnd="";
	    for(var i=0;i<length;i++)
	        rnd+=Math.floor(Math.random()*10);
	    return rnd;
    }         

   
 // JavaScript Document
/*加入收藏*/
function addFavorite(url,title)
{
    if(confirm("网站名称："+title+"\n网址："+url+"\n确定添加收藏?")){
        var ua = navigator.userAgent.toLowerCase();
        if(ua.indexOf("msie 8")>-1){
            external.AddToFavoritesBar(url,title,'');//IE8
        }else{
            try {
                window.external.addFavorite(url, title);
            } catch(e) {
                try {
                    window.sidebar.addPanel(title, url, "");//firefox
                } catch(e) {
                    alert("加入收藏失败，请使用Ctrl+D进行添加");
                }
            }
        }
    }
    return false;
}
/*设为首页*/
function setHomepage()
{
if (document.all)
    {
       document.body.style.behavior='url(#default#homepage)';
       document.body.setHomePage('http://www.zhidaosoft.com');
    }
    else if (window.sidebar)
    {
    if(window.netscape)
    {
         try
         { 
            netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
         } 
         catch (e) 
         { 
            alert("该操作被浏览器拒绝，如果想启用该功能，请在地址栏内输入 about:config,然后将项 signed.applets.codebase_principal_support 值该为true"); 
            return false;
         }
    } 
    alert("您已将“之道官网”设为首页");
    var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);
    prefs.setCharPref('browser.startup.homepage','http://www.zhidaosoft.com');
}
}

/*优惠券的弹出框*/
function subCoupon(sele){
	var seleObj = document.getElementById('subCoupon');
	if(sele == 'over'){
		seleObj.style.display = 'block';
	}else{
		seleObj.style.display = 'none';	
	}
}
function introWeb(){
	var checkIntroWeb = getCookie('introWeb');
	var introWebID = document.getElementById('introWeb');
	if(checkIntroWeb != 'true'){
		generateLoginDiv('introWeb',611,320);
		introWebID.style.display = "block";
		setTimeout("viewSpeUrl('introWeb');",50000);
	}
}

/* 菜单上的hover变背景图*/
function menuHover(thisObj){
	if(thisObj.className == ""){
		thisObj.className = "seleHover";
	}
}
function menuOut(thisObj){
	if(thisObj.className == "seleHover"){
		thisObj.className = "";
	}
}

/*弹出框*/
function navjump(sele,type){
	var seleObj = document.getElementById(type);
    var top = $('#'+type+'Nav').offset().top;
	if(sele == 'over'){
		seleObj.style.display = 'block';	
	}else{
		seleObj.style.display = 'none';		
	}
        
    if(!+[1,])
    {
        $("#"+type).css("margin-top",top-171+"px");
    }
    else
    {
        $("#"+type).css("margin-top",top-166+"px");
    }
}

function searchMalls()
{
    var keywords = $('#bbsSearch_text').val();
    if(keywords=='' || keywords=='请输入商城的名称或域名！')
    {
        alert("请输入要搜索商城的名称或域名！");
        $('#bbsSearch_text').focus();
        return false;
    }
    $.ajax({
      url: contextPath+"index.php?con=index",
      data: "act=searchMalls&keywords="+keywords,
      dataType:'json',
      type: "GET",
      type: "POST",
      success: function(data){
            if(!data.id)
            {
                alert("抱歉，没有找到["+keywords+"]商城!");
            }
            else
            {
                window.open(data.url);
            }
      }
    });
}

﻿function AddFavorite(sURL, sTitle)
{
    try
    {
    window.external.addFavorite(sURL, sTitle);
    }
    catch (e)
    {
        try
        {
           window.sidebar.addPanel(sTitle, sURL, "");
        }
        catch (e)
        {
           alert('AddFavorite Failed');
        }
    }
}

function setHomepage(val)
{
    if (document.all) 
    {
        document.body.style.behavior='url(#default#homepage)';
        document.body.setHomePage(val)
    } 
    else if (window.sidebar)
    {
        if(window.netscape)
        { 
            try
            { 
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
            }
            catch (e)
            {
                window.sidebar.addPanel(val,'',"");
            }
        } 
        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);
        prefs.setCharPref('browser.startup.homepage',val);
    }
}

function setClipboard(maintext,isalert) 
{
    if (window.clipboardData) 
    {
        if(isalert==true)
        {
            alert("复制成功！可以把地址复制通过QQ，MSN，旺旺等聊天工具发给你的好友！");
        }
        return (window.clipboardData.setData("Text", maintext));
    } 
    else 
    {
        if (window.netscape) 
        {
            try{
            netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
            var clip = Components.classes["@mozilla.org/widget/clipboard;1"].createInstance(Components.interfaces.nsIClipboard);
            if (!clip) 
            {
                return;
            }
            var trans = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable);
            if (!trans) 
            {
                return;
            }
            trans.addDataFlavor("text/unicode");
            var str = new Object();
            var len = new Object();
            var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
            var copytext = maintext;
            str.data = copytext;
            trans.setTransferData("text/unicode", str, copytext.length * 2);
            var clipid = Components.interfaces.nsIClipboard;
            if (!clip) 
            {
                return false;
            }
            clip.setData(trans, null, clipid.kGlobalClipboard);
            if(isalert==true)
            {
                alert("复制成功！可以把地址复制通过QQ，MSN，旺旺等聊天工具发给你的好友！");
            }
            return true;
            }
            catch(e)
            {
                alert("您的firefox安全限制限制您进行剪贴板操作，请打开'about:config'将signed.applets.codebase_principal_support'设置为true'之后重试，相对路径为firefox根目录/greprefs/all.js");
                return false;
            }
        }
    }
    
    return false;
}

$(document).ready(function(){
    $("body").click(function(){
    temp = document.getElementById("divStoreObjMsg");
    if( temp != null)
        hiddenStoreObjMsg();            
    });
    var bbsSear = document.getElementById("bbsSearch");
    if(bbsSear != null && bbsSear != ""){
        seleRadio();
    }
})   

var bannerpicwidth ;
var time1 ;

function showTuanAover(){
    window.clearInterval(time1);
}
function showTuanAout(){
    if(time1){
        time1 = window.setInterval("showTuanleft("+bannerpicwidth+")",5000);
    }    
} 
function startPic(){
    showTuanNum(1,bannerpicwidth);
    time1 = window.setInterval("showTuanleft("+bannerpicwidth+")",5000);
}
function showTuanNum(num,width){
    var seleId = "#showTuanNum"+(num);
    $("#imgCont").stop().animate({left:-width*(num-1)});
    $(".showTuanNum").removeClass("showTuanNumSele");
    $(seleId).addClass("showTuanNumSele");        
}
function showTuanleft(width){
    var imgContLeft = document.getElementById("imgCont").style.left;
    var imgContLeftNum = -(parseInt(imgContLeft)/width-1);
    var imgContWidth = document.getElementById("imgCont").offsetWidth;
    var imgContWidthNum = imgContWidth/width;
    if(imgContLeftNum == imgContWidthNum){
        imgContLeftNum = 1;
    }else{
        imgContLeftNum++;
    }
    showTuanNum(imgContLeftNum,width);
}

var bannerpicwidth ;
var time1 ;
if(typeof(bannerpicwidth) == 'undefined' ) bannerpicwidth =  725;

function showTuanAover(){
    window.clearInterval(time1);
}
function showTuanAout(){
    if(time1){
        time1 = window.setInterval("showTuanleft("+bannerpicwidth+")",5000);
    }    
} 
function startPic(){
    showTuanNum(1,bannerpicwidth);
    time1 = window.setInterval("showTuanleft("+bannerpicwidth+")",5000);
}
function showTuanNum(num,width){
    var seleId = "#showTuanNum"+(num);
    $("#imgCont").stop().animate({left:-width*(num-1)});
    $(".showTuanNum").removeClass("showTuanNumSele");
    $(seleId).addClass("showTuanNumSele");        
}
function showTuanleft(width){
    try{
        var imgContLeft = document.getElementById("imgCont").style.left;
        var imgContLeftNum = -(parseInt(imgContLeft)/width-1);
        var imgContWidth = document.getElementById("imgCont").offsetWidth;
        var imgContWidthNum = imgContWidth/width;
        if(imgContLeftNum == imgContWidthNum){
            imgContLeftNum = 1;
        }else{
            imgContLeftNum++;
        }
        showTuanNum(imgContLeftNum,width);
    }
    catch(err) {} 
}


$(document).ready(function(){
    startPic();
});

jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        var path = options.path ? '; path=' + options.path : '';
        var domain = options.domain ? '; domain=' + options.domain : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};


    var unionstore = "0" //是否联合登陆商家,1:是，0：否  
    var currUserName = "";
    var gourl = "";
    //Interval事件id
    var timerID = 0;
    var eventEle = null;
         
     
    function createCoverDiv(){
        var bgObj0=document.createElement("div"); 
        bgObj0.setAttribute("id","divScreenBg");
        bgObj0.style.position="absolute"; 
        bgObj0.style.backgroundColor="#000000";
        if(document.all){
            bgObj0.style.filter = "alpha(opacity=40)";
        }else{
            bgObj0.style.MozOpacity = 0.4;
            bgObj0.style.opacity = 0.4;
        }
        bgObj0.style.top = "0px";   
        bgObj0.style.left = "0px"; 
        bgObj0.style.width = "100%"  
        var s_height = document.body.scrollHeight; 
        if(s_height < window.screen.availHeight){
            s_height=window.screen.availHeight;
        } 
        bgObj0.style.height=s_height+"px"//设置高度 
        bgObj0.style.zIndex = 1000;
        document.body.appendChild(bgObj0);
    }        
        
    function showCachLogin(divname){
       showLoginDiv(divname,650,320);
    }
    
        
    function showLoginDiv(divname,width,height){
       
        var cashObj=document.getElementById(divname); 
        var w = 0; 
        var h = 0;            
        var ua = navigator.userAgent.toLowerCase();
        var os = new Object();
        
        os.isFirefox = ua.indexOf ("gecko") != -1;
        os.isOpera = ua.indexOf ("opera") != -1;
        os.isIE = !os.isOpera && ua.indexOf ("msie") != -1;
        os.isSafa = !os.isOpera && ua.indexOf ("safari") != -1;
          if(os.isOpera){
              w = document.body.clientWidth;
              h = document.body.clientHeight;
          }else if(os.isFirefox){
              w = document.documentElement.clientWidth;
              h = document.documentElement.clientHeight;
          }else if(os.isIE){
              w = document.documentElement.clientWidth;
              h = document.documentElement.clientHeight;
          }else if(os.isSafa){
              w = document.body.clientWidth;
              h = document.body.clientHeight;
          }
        
        cashObj.style.position="absolute";  
        if(width == "-1"){ //特殊处理
            cashObj.style.left =  (w-600)/2 + "px"; 
            cashObj.style.width = "auto";  
            cashObj.style.height ="auto";  
         }else{
            cashObj.style.left =  (w-width)/2 + "px"; 
            cashObj.style.width = width+"";  
            cashObj.style.height = height + "";
         }
        
        cashObj.style.zIndex = 1001;
        clearInterval(timerID);

        timerID = setInterval(function(){moveCachLogin(cashObj,h,os,height);},10);
        cashObj.style.display="";
        /*
        //启用后，将滚动到层所在区域
        var loginname = document.getElementById("loginname");
        try{
            if(loginname != null){
                loginname.focus();
            }
        }catch(e){}
        */
    }        
        
    function hiddenCashDiv(){
        var cashObj = document.getElementById("cashLogin"); 
        clearInterval(timerID);
        cashObj.style.display = "none";
        var divScreenBg = document.getElementById("divScreenBg");
        document.body.removeChild(divScreenBg);
    }

    function moveCachLogin(obj,h,os,oh){
        if(obj){
            var st = 0;
            if(os.isOpera || os.isSafa){
                st = document.body.scrollTop;
            }else{
                st = document.documentElement.scrollTop;
            }
            if(oh != null && oh > 0)
                 obj.style.top = st+((h-oh)/2)+ "px";
            else 
                obj.style.top = st+((h-320)/2)+ "px";
        }
    }
        
    function generateCommonCashBackDiv(result){
        createCoverDiv();
        setCashBackInfo(result);
        showCachLogin("cashLogin");
    }
    
    function setCashBackInfo(result){
        var siteinfos = result.split(",,");
        /*
        var picobj = document.getElementById("sl"+siteinfos[2]);
        if(picobj != null)
            document.getElementById("sitelogodiv").innerHTML = "<img width='95' src='"+picobj.src+"' />";
        else
            document.getElementById("sitelogodiv").innerHTML = siteinfos[1];
            */
        if(siteinfos.length == 3)        
            document.getElementById("maxcashdiv").innerHTML    = "<span style='color:red;font-weight:bold;font-size:14px'>"+siteinfos[0]+"</span>";
        else
            document.getElementById("maxcashdiv").innerHTML    = "<span style='color:red;font-weight:bold;font-size:14px'>"+siteinfos[0]+"</span>";
        document.getElementById("cashsitename").innerHTML = "<a target='_blank' href='"+contextPath+"/s_"+siteinfos[2]+"/'>"+siteinfos[1]+"</a>";
        document.getElementById("cashUrl").value = gotoUrl;
    }
    
    //关闭返现登录提示
        function closeCommonCachLogin(){
            productOnload.setViewSiteProductWayToCookie(closeCommonCachLoginCallBack);
        }
        
        function closeCommonCachLoginCallBack(){
            hiddenCashDiv();
            gotourlWithNewWindow();
        }
        
        
                
    function generateLoginDiv(logdiv,width,height,flag){
        if(flag != null && flag.length > 0){
            loginflag = flag;
            regtype = flag;
        }
        createCoverDiv();
        showLoginDiv(logdiv,width,height);
    }
    
    function closeLoginDiv(logdiv){
        var divScreenBg = document.getElementById("divScreenBg");
        document.body.removeChild(divScreenBg);
        document.getElementById(logdiv).style.display='none';
    }
        
    var loginflag = null;
    var regtype = null;
    function doLoginForCommLogin(){
        var loginname = $('#loginnameAjax').val().trim();
        var password =  $('#passwordAjax').val().trim();
        
        if(loginname == ""){
            alert("请输入用户名称或邮箱。");
            $('#loginnameAjax').focus();
            return false;
        }
        if(password == ""){
            alert("请输入密码。");
            $('#passwordAjax').focus();
            return false;
        }
        loginname = encodeURIComponent(loginname);
        password = encodeURIComponent(password);
        $("#longError_reg").html("正在验证用户信息，请稍后……");
        $.ajax({
            type: "POST",
            url: contextPath+"index.php?con=index",
            data: "act=login"+"&loginname="+loginname+"&password="+password+"&commit=1"+"&inajax=1",
            dataType:  "json",
            success  :  function(data){
                alert(data.message);
                $("#longError_reg").html("");
                if(data.type=='url') 
                {
                    //window.open(gourl);
                    window.location=location.href;
                }
            }
        })    

    }   
    
          function doLoginForCommLoginWithFlag(flag){
              if(flag != null && flag.length >0){
                loginflag = flag;
               }
            doLoginForCommLogin();
      }
      
      function doLoginForCommLoginOnkey(e,flag)
      {
            var keyc;
            if(window.event){
                keyc=e.keyCode;
            }else if(e.which){
                keyc=e.which;
            }
            if(keyc == 13){    
                doLoginForCommLogin(flag);
            }
      }
      
     function  doRegForCommLoginWithFlag(type)
     {
        if(type != null && type.length >0){
            regtype = type;
        }
        doRegisterForCommLogin();
      }
      
            
     function doRegForCommLoginOnkey(e,type)
     {
        var keyc;
        if(window.event){
            keyc=e.keyCode;
        }else if(e.which){
            keyc=e.which;
        }
        if(keyc == 13){    
            doRegForCommLoginWithFlag(type);
        }
      }
      
    //显示登录框，登录后点击进入对应url
    function generateLoginDivToUrl(logdiv,width,height,flag,hrefobj){
        if(jumpstyle)
        {
            if(!loginResult){
                gourl = hrefobj.href;//本站链接，不提示登录
                showLoginDiv(logdiv,width,height);
                createCoverDiv();
                return false;
            }
            return true;
        }
        else
        {
            window.open(hrefobj.href);
            return false;
        }
    }
    
    function doRegisterForCommLogin()
    {
        var loginname  = document.regform.reg_loginname.value.trim();
        var email      = document.regform.reg_email.value.trim();
        var password   = document.regform.reg_password.value.trim();
        var rePassword = document.regform.rePassword.value.trim();     
          
        if(loginname == ""){
            alert("请输入用户名。");
            document.regform.reg_loginname.focus();
            return false;
        }else{
            if(loginname.length < 3){
                alert("用户名格式不正确,请输入不小于6个字符！");
                document.regform.reg_loginname.focus();
                return false;
            }     
            var reg = /^(\w|[\u4E00-\u9FA5])*$/;           
            if(!reg.test(loginname)){
                alert("用户名格式不正确！");
                document.regform.reg_loginname.focus();
                return false;
            }     
        }           
        if(email == ""){
            alert("请输入邮箱。");
            document.regform.reg_email.focus();
            return false;
        }else{
            var re =/^[\-!#\$%&'\*\+\\\.\/0-9=\?A-Z\^_`a-z{|}~]+@[\-!#\$%&'\*\+\\\.\/0-9=\?A-Z\^_`a-z{|}~]+(\.[\-!#\$%&'\*\+\\\.\/0-9=\?A-Z\^_`a-z{|}~]+)+$/;
            if(!re.test(email)){
                alert("邮箱格式不正确。");
                document.regform.reg_email.focus();
                return false;
            }        
        }
        
        if(password == ""){
            alert("请输入密码。");
            document.regform.reg_password.focus();
            return false;
        }else{
            if(password.length < 6){
                alert("密码长度不能小于6个字符。");
                document.regform.reg_password.select();
                return false;
            }
        }
        if(rePassword == ""){
            alert("请输入确认密码。");
            document.regform.rePassword.focus();
            return false;
        }else{
            if(password != rePassword){
                alert("确认密码填写不正确。");
                document.regform.rePassword.select();
                return false;
            }
        }
        $("#longError_reg").html("系统正在注册中，请稍后……");
        loginname = encodeURIComponent(loginname);
        password = encodeURIComponent(password);
        email = encodeURIComponent(email);
        $.ajax({
             type: "GET",
             url: contextPath+"index.php",
             data: "act=registerAjaxMember"+"&loginname="+loginname+"&email="+email+"&password="+password,
             dataType:  "json",
             success   :  checkCommonRegisterCallBack
        })    
    }    

    function checkCommonRegisterCallBack(data)
    {      
        $("#longError_reg").html("");
        if(data.type =='url')
        {
          window.location=location.href;
        }  
        else if(data.type=='aurl')
        {
            window.open(data.message);
        }
        else
        {
          alert(data.message);
          $('#longError_reg').html( data.message );    
        }
    }  
    
    function viewSpeUrl(closediv)
    {
        window.open(gourl);
        closeLoginDiv(closediv);
    }
              
    function generateCommonCashBackDiv(result){
        createCoverDiv();
        setCashBackInfo(result);
        showCachLogin("cashLogin");
    }
    
    function setCashBackInfo(result){
        var siteinfos = result.split(",,");
        if(siteinfos.length == 3)        
            document.getElementById("maxcashdiv").innerHTML    = "<span style='color:red;font-weight:bold;font-size:14px'>"+siteinfos[0]+"</span>";
        else
            document.getElementById("maxcashdiv").innerHTML    = "<span style='color:red;font-weight:bold;font-size:14px'>"+siteinfos[0]+"</span>";
        document.getElementById("cashsitename").innerHTML = "<a target='_blank' href='"+contextPath+"/s_"+siteinfos[2]+"/'>"+siteinfos[1]+"</a>";
        document.getElementById("cashUrl").value = gotoUrl;
    }
    
    
function selthis()
{
    $('.s-nav a').click(function(){
        $('.s-nav a').removeClass().addClass('n');
        $(this).removeClass().addClass('y');
        $('#s-txt').val($(this).attr('value'));
        $('#s-txt').attr('name',$(this).attr('name'));
        $('.box').attr('action',$(this).attr('s'));
    });
}

//自动加载样式
$(function(){
    $('input[type="text"],input[type="password"],textarea,select,radio').focus(function(){$(this).css({borderColor:"#4D90FE",background:"#F8F670"})});
    $('input[type="text"],input[type="password"],textarea,select,radio').blur(function(){$(this).css({borderColor:'',background:''})});
    $('input[type="text"],input[type="password"],textarea,select,radio').mouseover(function(){$(this).css('border-color', '#F00')});
    $('input[type="text"],input[type="password"],textarea,select,radio').mouseout(function(){$(this).css('border-color', '#999')});
    $('input[type="text"],input[type="password"],textarea,select,radio').focus(function(){$(this).addClass('shadow')});
    $('input[type="text"],input[type="password"],textarea,select,radio').blur(function(){$(this).removeClass('shadow')});
})

function killErrors() 
{
    return true;
}
window.onerror = killErrors;

function showLogin()
{
    $('#menu_weibo_login').toggle();
}

function taobaoProdSele(obj){
    var ProdSimilar = document.getElementById("ProdSimilar");
    var ProdDetail = document.getElementById("ProdDetail");
    var ProdDetailpl = document.getElementById("ProdDetailpl");
    var ProdSimilarLi = document.getElementById("ProdSimilarLi");
    var ProdDetailLi = document.getElementById("ProdDetailLi");
    var ProdDetailplLi = document.getElementById("ProdDetailplLi");
    if(obj == "ProdSimilar"){
        ProdSimilar.style.display = "block";
        ProdDetail.style.display = "none";
        ProdDetailpl.style.display = "none";
        ProdSimilarLi.className = "sele";
        ProdDetailLi.className = "";
        ProdDetailLi.className = "";
    }
    else if(obj == "ProdDetail")
    {
        ProdSimilar.style.display = "none";
        ProdDetail.style.display = "block";
        ProdDetailpl.style.display = "none";
        ProdSimilarLi.className = "";
        ProdDetailLi.className = "sele";
        ProdDetailplLi.className = "";
    }
    else
    {
        ProdSimilar.style.display = "none";
        ProdDetail.style.display = "none";
        ProdDetailpl.style.display = "block";
        ProdSimilarLi.className = "";
        ProdDetailLi.className = "";
        ProdDetailplLi.className = "sele";
    }
}

/*以上为新内容*/
 
function tk_search() {
    document.getElementById("searchForm").submit();
}
function scaleSearch(url) {
    var keyword = document.getElementById("keyword");
    var tk_search = document.getElementById("tk_search");
    if(keyword.value == "")
    {
        alert("请输入关键词后，按下回车键快速搜索！");
        return false;    
    }
    if (keyword.value == "请输入宝贝名称，买前搜一搜，是得到返现的保障" || keyword.value == "请输入淘宝卖家的准确昵称" || keyword.value == "请输入淘宝网址搜搜看……" || keyword.value == "我要搜商城^_^如:凡客诚品..."|| keyword.value == "我要搜团购^_^如:拉手网...") 
    {
        alert(keyword.value);
        keyword.focus();
        return false;
    }
    window.location = url;
    return false;
}

function keywordBlur(obj){
    var baobei = document.getElementById("baobei");
    var url = document.getElementById('url');
    var zhanggui = document.getElementById('zhanggui');
    var mall = document.getElementById('mall');
    var tuan = document.getElementById('tuan');   
    if(obj.value==''){
        document.getElementById('keyword').style.color = '#666';    
        if (baobei.className == "sele") {
            if(searchk != "")
            {
                document.getElementById('keyword').value = searchk;
            }
            else
            {
                document.getElementById('keyword').value='请输入宝贝名称，买前搜一搜，是得到返利的保障';
            }
        }else if(url.className == "sele"){
            document.getElementById('keyword').value='请输入淘宝网址搜搜看……';
        }else if(zhanggui.className == "sele"){
            document.getElementById('keyword').value='请输入淘宝卖家的准确昵称';
        }else if(mall.className == "sele"){
            document.getElementById('keyword').value='我要搜商城^_^如:凡客诚品...';
        }else if(tuan.className == "sele"){
            document.getElementById('keyword').value='我要搜团购^_^如:拉手网...';
        }else{
            document.getElementById('keyword').value='请输入淘宝卖家的准确昵称';
        }
    }

}

function keywordFocus(obj){
    if(obj.value == '请输入宝贝名称，买前搜一搜，是得到返利的保障' || (obj.value == searchk  && obj.value == seoSearch )|| obj.value=='请输入淘宝卖家的准确昵称' || obj.value == '请输入淘宝网址搜搜看……' || obj.value == '我要搜商城^_^如:凡客诚品...' || obj.value=='我要搜团购^_^如:拉手网...'){
        obj.value='';
    }
    obj.style.color = '#000';    
}

function taobaoMenu(seleName){
    var baobei = document.getElementById('baobei');
    var url = document.getElementById('url');
    var zhanggui = document.getElementById('zhanggui');
    var mall = document.getElementById('mall');
    var tuan = document.getElementById('tuan');
    var keyword = document.getElementById('keyword');
    var stype = document.getElementById('stype');
    if(seleName == 'baobei'){
        baobei.className = 'sele';
        url.className = 'noSele';
        zhanggui.className = 'noSele';
        mall.className = 'noSele';
        tuan.className = 'noSele';
        keyword.value = '请输入宝贝名称，买前搜一搜，是得到返利的保障';
        keyword.style.color = '#666';
        stype.value = '0';
    }else if(seleName == 'url'){
        url.className = 'sele';  
        baobei.className = 'noSele';
        zhanggui.className = 'noSele';
        mall.className = 'noSele';
        tuan.className = 'noSele';     
        keyword.value = '请输入淘宝网址搜搜看……';    
        keyword.style.color = '#666';
        stype.value = '1';
    }else if(seleName == 'zhanggui'){
        zhanggui.className = 'sele';
        url.className = 'noSele'; 
        baobei.className = 'noSele'; 
        mall.className = 'noSele';   
        tuan.className = 'noSele';
        keyword.value = '请输入淘宝卖家的准确昵称';    
        keyword.style.color = '#666';
        stype.value = '2';
    }else if(seleName == 'mall'){
        mall.className = 'sele';
        zhanggui.className = 'noSele';     
        url.className = 'noSele';    
        baobei.className = 'noSele';
        tuan.className = 'noSele';
        keyword.value = '我要搜商城^_^如:凡客诚品...';    
        keyword.style.color = '#666';
        stype.value = '3';
    }else if(seleName == 'tuan'){
        tuan.className = 'sele';
        mall.className = 'noSele'; 
        zhanggui.className = 'noSele';  
        url.className = 'noSele'; 
        baobei.className = 'noSele';
        keyword.value = '我要搜团购^_^如:拉手网...';    
        keyword.style.color = '#666';
        stype.value = '4';
    }
    else{
        baobei.className = 'sele';
        dianpu.className = 'noSele';
        zhanggui.className = 'noSele';
        mall.className = 'noSele';
        tuan.className = 'noSele';
        keyword.value = '请输入宝贝名称，买前搜一搜，是得到返利的保障';
        keyword.style.color = '#666';
        stype.value = '0';
    }
}

﻿var preload=new Array();
var preHref=new Array();
var rollDelay=5;
var rollTimer=null;
var imgNav=null;
var tempcount=1;

function initpic(){
    var swidth = screen.width;
    for (var i=0;i<photoarray.length;i++){
        preload[i]=new Image();
        preload[i].src=photoarray[i][0];
        preload[i].alt=photoarray[i][1];
        preHref[i]=photoarray[i][2];   
    }
}

function generateslider(){
    
    if(photoarray.length == 0)
        return ;
    
    var navBarHTML="";
    navBarHTML+="<ul id='navBar'>";
    for (var i=0;i<photoarray.length;i++){
        navBarHTML+="<li id='i"+ i +"'><a href='"+ preHref[i] +"' target='_blank'>"+ (i+1) +"</a></li>"
    }
    navBarHTML+="</ul>";

    document.getElementById("barnnerImg").innerHTML+=navBarHTML;
    document.getElementById("currBarnnerimage").innerHTML="<a href='"+ preHref[0] +"' target='_blank'><img src='"+ preload[0].src +"' alt='"+ preload[0].alt +"' class='bannerpic' border='0' style='filter:revealtrans(duration=2,transition=23);CURSOR: pointer;' /></a>";
    document.getElementById("navBar").childNodes[0].className="curr";
    if(photoarray.length > 1){
        
        imgNav=document.getElementById("currBarnnerimage").childNodes[0].childNodes[0];
        rollTimer=setTimeout("goNextSlider(1)",rollDelay*1000);
        for (var i=0;i<photoarray.length;i++){
            document.getElementById("navBar").childNodes[i].onmouseover=function(){
                clearTimeout(rollTimer);goNextSlider(this.id.substr(1,1));clearTimeout(rollTimer);
            };
            document.getElementById("navBar").childNodes[i].onmouseout=function(){
                rollTimer=setTimeout("goNextSlider("+tempcount+")",rollDelay*1000);
            };
        };
        imgNav.onmouseover=function(){
            clearTimeout(rollTimer)
        };
        imgNav.onmouseout=function(){
            rollTimer=setTimeout("goNextSlider("+tempcount+")",rollDelay*1000);
        };
    }
}
function goNextSlider(navIndex){
    clearTimeout(rollTimer);
    if (window.navigator.userAgent.indexOf("MSIE") >= 1 && window.navigator.appVersion<="7.0"){
        imgNav.filters.revealtrans.transition=23;
        imgNav.filters.revealtrans.Apply();
    }
    imgNav.src=preload[navIndex].src;

    if (window.navigator.userAgent.indexOf("MSIE") >= 1 && window.navigator.appVersion<="7.0"){
        imgNav.filters.revealtrans.Play();
    }
    imgNav.alt=preload[navIndex].alt;
    document.getElementById("currBarnnerimage").childNodes[0].href=preHref[navIndex];
    for (var i=0;i<photoarray.length;i++){
        document.getElementById("navBar").childNodes[i].className="";
    }
    document.getElementById("navBar").childNodes[navIndex].className="curr";
    if (++navIndex==photoarray.length){
        navIndex=0;
    }
    rollTimer=setTimeout("goNextSlider("+navIndex+")",rollDelay*1000);
    tempcount=navIndex;
}

//initpic();


(function($) {
    $.fn.ADRoll = function(settings) {
        settings = jQuery.extend({
            speed: "normal",
            num: 4,
            timer: 1000,
            direction: "top",
            imgHeight: "206"
        }, settings);
        return this.each(function() {
            $.fn.ADRoll.scllor($(this), settings);
        });
    };

    $.fn.ADRoll.scllor = function($this, settings) {
        var index = 0;
        var li = $(".flash_item li");
        var showBox = $(".img-box");
         li.hover(function() {
            if (intervalTime) {
                clearInterval(intervalTime);
            }
            index = li.index(this);
            intervalTime = setTimeout(function() {
                ShowText(index);
                ShowAD(index);
               
            }, 100);
        }, function() {
            clearInterval(intervalTime);
            intervalTime = setInterval(function() {
                ShowText(index);
                ShowAD(index); 
               
                index++;
                if (index == settings.num) {
                    index = 0;
                }
            }, settings.timer)
        });
        showBox.hover(function() {
            if (intervalTime) {
                clearInterval(intervalTime);
            }
        }, function() {
            clearInterval(intervalTime);
            intervalTime = setInterval(function() {
                ShowText(index);
                ShowAD(index);
                index++;
                if (index == settings.num) {
                    index = 0;
                }
            }, settings.timer);
        });
        var intervalTime = setInterval(function() {
            ShowText(index);
            ShowAD(index);
            index++;
            if (index == settings.num) {
                index = 0;
            }
        }, settings.timer);
        var ShowAD = function(i) {
           showBox.animate({ "top": -i * settings.imgHeight }, settings.speed);
           $(".flash_item li").eq(i).addClass("on").siblings().removeClass("on");  
        };
        var ShowText = function(i){
            $("#flashText")[0].style.marginTop = -30*i+'px';
        }
    };
})(jQuery);

function parse_url(url){
 var pattern = /(\w+)=(\w+)/ig;
 var parames = {};
 url.replace(pattern, function(a, b, c){
  parames[b] = c;
 });
 return parames;
}

/**公共搜索js**/
function onsearch()
{               
    var keyword = $('#keyword').val().replace(new RegExp(/(&)/g),'@@');
    var stype   = $('#stype').val();
    keyword = encodeURIComponent(keyword);
    if(stype==1 || stype==0)
    {
        var urlss = $('#keyword').val();
        var regExp = /(.*\.?taobao.com(\/|$))|(.*\.?tmall.com(\/|$))/i;
        if (urlss.match(regExp)){
            var parames = parse_url(urlss);
            if (typeof(parames) == 'object'){
                var iid=parames['id'];
                if(iid==null || iid=="undefined"){
                    var iid=parames['item_num_id'];
                    if(iid==null || iid=="undefined"){
                        var iid=parames['default_item_id'];
                    }
                }
                keyword = iid;
                $.get(contextPath+"index.php"+"?act=taosearchurl"+"&iid="+keyword+"&stype="+stype,function(url){
                    $('#keyword').val("系统正在搜索中，请稍后……");
                    scaleSearch(url);
                });      
            }
            return false;
        }
        else
        {
            if(stype==1)
            {
                alert("您输入的淘宝网址非法！");
                return false;
            }
        }
    }                                            
    $.ajax({
         type: "POST",
         url: contextPath+"index.php",           
         data: "con=index&act=getSearchUrl&keyword="+keyword+"&stype="+stype,
         success: function(url){  
            $('#keyword').val("系统正在搜索中，请稍后……");
            scaleSearch(url);
         } 
    }); 
}

function load_initkey(type)
{
    //获得文本框的引用
    $("#keyword").bind('keydown',function(evt){
        evt=evt?evt:window.event;
        if(evt.keyCode==13)
        {
            if(type=='tao')
            {
                onsearch();   
            }
            else
            {
                onGroupSearch();
            }
        } 
    });
}    

function globals_search()
{
    onsearch();  
}
//加载回车搜索项
$(function(){
    load_initkey('tao');
})

/*评论星级*/
function showProdCommChoose(id){

    for(var i=1;i<=id;i++){
        document.getElementById("s"+i).className="starbg star2";
    }
    var msg = "";
    if(id ==1)
        msg = "很差";
    else if(id == 2)
        msg = "较差";
    else if(id == 3)
        msg = "一般";
    else if(id == 4)
        msg = "较好";
    else if(id == 5)
        msg = "很好";                    
    document.getElementById("ProdCommtip").innerHTML=msg;
}

function showProdCommChooseMalls(name,id){

    for(var i=1;i<=id;i++){
        document.getElementById("s"+name+i).className="starbg star2";
    }
    var msg = "";
    if(id ==1)
        msg = "很差";
    else if(id == 2)
        msg = "较差";
    else if(id == 3)
        msg = "一般";
    else if(id == 4)
        msg = "较好";
    else if(id == 5)
        msg = "很好";                    
    document.getElementById("ProdCommtip"+name).innerHTML=msg;
}

function clearProdCommChooseMalls(name,id){
    var cobjv = document.getElementById("stars"+name).value;
    if(cobjv == ""){
        for(var i=1;i<6;i++){
            document.getElementById("s"+name+i).className="starbg star1";
        }
    }else{
        for(var i=1;i<=parseInt(cobjv);i++){
            document.getElementById("s"+name+i).className="starbg star2";
        }
        for(var i=parseInt(cobjv)+1;i<=5;i++){
            document.getElementById("s"+name+i).className="starbg star1";
        }
    }
    document.getElementById("ProdCommtip"+name).innerHTML = "";
}

function clearProdCommChoose(id){
    var cobjv = document.getElementById("stars").value;
    if(cobjv == ""){
        for(var i=1;i<6;i++){
            document.getElementById("s"+i).className="starbg star1";
        }
    }else{
        for(var i=1;i<=parseInt(cobjv);i++){
            document.getElementById("s"+i).className="starbg star2";
        }
        for(var i=parseInt(cobjv)+1;i<=5;i++){
            document.getElementById("s"+i).className="starbg star1";
        }
    }
    document.getElementById("ProdCommtip").innerHTML = "";
}


function saveProdCommChoose(oid){
    document.getElementById("stars").value = oid;
}
function saveProdCommChooseMalls(name,oid){
    document.getElementById("stars"+name).value = oid;
}

