var FrontProduct_list={
	//分页使用此方法 
	//参数1 compid 	组件id
	//参数2 总页数 
	//参数3 input的name 输入的页数
	//参数4 action地址  跳转地址
checkpage:function (totalPages,pageNo,form,href,compId){
		var frm=_getElementById(compId,"input",pageNo).value;
		var marketexhibitlistForm = document.getElementById(form);
		var checknumber=/^[1-9][0-9]*$/;
		if( frm!=null && trim(frm)!=""){
			if(!checknumber.test(trim(frm))){
				alert(i18n_product_error_001);
				_getElementById(compId,"input",pageNo).focus();
				return false;
			}else {
				var maxpage=eval(totalPages);
				var inputNum=eval(frm);
				if(inputNum.length>5){
					alert(i18n_product_error_001);
					_getElementById(compId,"input",pageNo).focus();
					return false;
				}
				if(inputNum>maxpage){
					alert(i18n_product_error_001);
					_getElementById(compId,"input",pageNo).focus();
					return false;
				}else{
					var pageNo = trim(frm);
					href=href.replace("this.no",pageNo);
					var action = href;
					marketexhibitlistForm.action=action;
					marketexhibitlistForm.submit();
				}
			}
		}else{
			alert(i18n_product_error_001);
			_getElementById(compId,"input",pageNo).focus();
			return false;
			//document.location.replace(action1);
		}
	},	
		//校验购买按钮响应事件  参数1：组件Id  参数2：跳转连接
		checkbuy:function(compId,actionURL){
			var formId=compId+"_marketexhibitlistForm";
			var productFrom = document.getElementById(formId);
			var checkboxes = document.getElementsByName(compId+"compareCheckbox");
			var ids="";
		   for(var i=0;i<checkboxes.length;i++)
             {
                 if(checkboxes[i].checked==true)
				 {					
				 ids=ids+checkboxes[i].value+",";
				 }
             }
			 if(ids==null||ids=="")
			{
				 alert(i18n_product_error_110);
				 return false;
			}
			 productFrom.action=actionURL.replace("abcde",ids);			 
			 productFrom.submit();	
	        
        },
        //改变排列方式  参数1：下拉列表对象  参数2：跳转连接  参数3：form对象
	changeOrderby:function (dom,href,form){
		var order_str = dom.value;
		href=href.replace("this.order_str",order_str);
		var action = href;
		var marketexhibitlistForm = document.getElementById(form);
		marketexhibitlistForm.action=action;
		marketexhibitlistForm.submit();

	},
	//写入cookie  参数1：cookie名称  参数2：待对比id  参数3：checkbox id  参数4：组件Id
	doWriteCookie:function (cookieName,idToCompare,idCheckbox,compId){
	    var cookieValue = idToCompare;
	    var cookieString = document.cookie;
        var start = cookieString.indexOf(cookieName + '=');
        if (start == -1){ // 找不到这个cookie，那么新增一个
             document.cookie = cookieName+'=' + escape(cookieValue)+';path=/';
        }else{//找到了那就提取出来
            start += cookieName.length + 1;
            var end = cookieString.indexOf(';', start);
            var cookieContentWrited = '';
            if (end == -1){  //cookieName所对应的项已经在cookie字符串的最后了
                cookieContentWrited = unescape(cookieString.substring(start));
            }else{    //cookieName所对应的项不在cookie字符串的最后
                cookieContentWrited = unescape(cookieString.substring(start, end));
            }

            if(cookieContentWrited.indexOf(cookieValue)==-1 && _getElementById(compId,"input",idCheckbox).checked==true){
                //如果用户是选中并且用户选择的内容没有被保存过,那么把记录保存
             	if(cookieContentWrited=="")
				{
                document.cookie = cookieName+'=' + escape(cookieValue)+';path=/';
				}else
				{   
					document.cookie = cookieName+'=' + escape(cookieContentWrited+':'+cookieValue)+';path=/';
				}
            }
            if(cookieContentWrited.indexOf(cookieValue)!=-1 && _getElementById(compId,"input",idCheckbox).checked==false){
                //如果checked==false但是用户选择的内容已经被保存过,那么把记录保存移出

                //如果在cookie里只有一个ID了，并且这个ID还要被删除，那么也一并删除cookie的名称
                if(cookieContentWrited==cookieValue){
                    cookieContentWrited='';
                }else if(cookieContentWrited.indexOf(cookieValue)!=0){//如果这个cookie不排在第一位
                    cookieContentWrited = cookieContentWrited.replace(':'+cookieValue,'');
                }else{//如果这个cookie排在第一位，直接去掉cookieValue+':'
                     cookieContentWrited = cookieContentWrited.replace(cookieValue+':','');
                }
                document.cookie = cookieName+'=' + escape(cookieContentWrited)+';path=/';
            }

        }

	},
			//tablelist加alt样式
		    striptr:function(){
	        $(".tablelist tr:even").addClass("alt");
        },
        //checkbox全选  参数1：cookie名称  参数2：组件Id 
        onCheckall:function(cookieName,compId){
        var checkboxFlag = document.getElementById(compId+"checkbox");
        if(checkboxFlag!=null){
            var checkboxes = document.getElementsByName(compId+"compareCheckbox");
            for(var i=0;i<checkboxes.length;i++){
                if(checkboxFlag.checked==true){
                    checkboxes[i].checked=true;
                }else{
                    checkboxes[i].checked=false;
                }
                FrontProduct_list.doWriteCookie(cookieName,checkboxes[i].value,checkboxes[i].id,compId);
            }
        }
    },
    //提交对比  参数1：cookie名称  参数2：连接地址
	toCompareAction:function(cookieName,href){
	    var cookieString = document.cookie;

        var start = cookieString.indexOf(cookieName + '=');
        if (start == -1){ // 找不到这个cookie，那么新增一个
             alert(i18n_product_productsToCa);
        }else{
            start += cookieName.length + 1;
            var end = cookieString.indexOf(';', start);
            if(start==end){
                alert(i18n_product_productsToCa);
                return;
            }
            var cookieContentWrited = '';
            if (end == -1){
                cookieContentWrited = unescape(cookieString.substring(start));
            }else{
                cookieContentWrited = unescape(cookieString.substring(start, end));
            }
			href=href.replace("this.cookieContentWrited",cookieContentWrited);
            window.open(href);
        }
	},
	//加载组件状态  参数1：是否进行商品对比  参数2：组件Id
	laodComp:function (show_compare,compId){
        if(show_compare!='1'){
            return;
        }
        var cookieString = document.cookie;

        var starIndex = cookieString.indexOf('showCompare=');
        if(starIndex ==-1){
            return ;
        }

        var endIndex = cookieString.indexOf(';',starIndex);
		if(endIndex == -1)
		{
            endIndex=cookieString.length;

		}
        starIndex = 'showCompare'.length+1+starIndex;
        var cookieContent = unescape(cookieString.substring(starIndex,endIndex));
        var cookieArray = cookieContent.split(':');
        for(var i=0;i<cookieArray.length;i++){
            var checkID = cookieArray[i];

            if(_getElementById(compId,'input','checkbox'+checkID)!=null){
                _getElementById(compId,'input','checkbox'+checkID).checked=true;
            }
        }
    },
    //读取会员价
	laodmemberPrice:function (){
		var memberlvid=document.getElementsByName("memberlvid");
		var cookieString = document.cookie;

		var starIndex = cookieString.indexOf('c_memberInfo=');
		if(starIndex ==-1){
			for(var i=0; i<memberlvid.length;i++){
				memberlvid[i].parentNode.style.display="none";
			}
			return;
		}

		var endIndex = cookieString.indexOf(';',starIndex);
		if(endIndex == -1){
			endIndex=cookieString.length;
		}
		starIndex = 'c_memberInfo'.length+1+starIndex;
        var cookieContent = unescape(cookieString.substring(starIndex,endIndex));
        for(var i=0; i<memberlvid.length;i++){
			if(memberlvid[i].value!=cookieContent){
				memberlvid[i].parentNode.style.display="none";
			}
		}
	}
}