function toLogin(){
    //				document.cookie = "URL=" + document.URL;
    window.location.href = "login.jsp";
}

function toLogout(){
    //window.navigate("logout.jsp?URL="+encodeURIComponent(document.URL));
    window.location.href = "logout.jsp";
    //				alert(encodeURIComponent(document.URL));
    //				window.navigate("boardlogin.do?method=loginout&URL="+encodeURIComponent(document.URL));
}

function doMerchandiseClass(classifyId, classTypeName){


    var urlStr = encodeURI(encodeURI(classTypeName));
    window.location.href = "searchMerchandiseAeassort.do?method=searchMerchandiseAeassort&fromPageId=main&classifyId=" + classifyId + "&className=" + urlStr;
}
/**
*页头关键字搜索画面点击搜索时
*/
function findResultHead(){
 	var urlStr= encodeURI(encodeURI(document.getElementById("headKey").value));
	if (isNull(urlStr)){
	  	//无关键字不用传参
	  	document.getElementById('headKeyForm').action = "./merchandiseSearchResult.do?method=doKey";
	} else {
		//有关键字传参用于统计
		document.getElementById('headKeyForm').action = "./merchandiseSearchResult.do?method=doKey&fromPageId=main&keyword="+urlStr;
	}
    document.getElementById('headKeyForm').submit();
    return true;
}

function enterSubmitForPageHeadKeyWord(){
		var oEvent = window.event ? window.event:arguments[0];
		if(oEvent.keyCode ==13){
			findResultHead();
			return false;
		}
	}

/**
 *页头点击热门关键字链接时
 */
function doSearchHeadHotWord(id, word){
	var urlStr= encodeURI(encodeURI(word));
    document.getElementById("headHotKeyId").value = id;
    document.getElementById("headKey").value = word;
    document.getElementById("headKeyForm").action = "./merchandiseSearchResult.do?method=doKey&fromPageId=main&keyword="+urlStr;
    document.getElementById("headKeyForm").submit();
}
/**
 *专卖店铺点击关键字链接时
 */
function doSearchInFranchised(classId, word){
	document.getElementById("classId").value = classId;
    document.getElementById("key1").value = word;
    document.getElementById("franchisedForm").action = "./merchandiseSearchResult.do?method=doKey";
    document.getElementById("franchisedForm").submit();
}
function getClassOnDetail() {
	try{
	var bigClassIdDetail = document.getElementById("bigClassIdDetail").value;
	if (isNull(bigClassIdDetail)) {
		return true;
	}
	 if (bigClassIdDetail == 4) {
                document.getElementById('imgStationery').src = "./images/pageHead/pageHead/stationery_Pd.jpg";
                // 文具/事务用品
                document.getElementById('colorBorder5px-1').style.borderBottomColor = '#006DBC';
                //document.getElementById('topSearch-box').style.backgroundColor = '#006DBC';
                return "class0";
            }
            else 
                if (bigClassIdDetail == 6) {
                    // 文件夹
                    document.getElementById('imgFolder').src = "./images/pageHead/pageHead/folder_Pd.jpg";
                    
                    document.getElementById('colorBorder5px-1').style.borderBottomColor = '#9FC732';
                    //document.getElementById('topSearch-box').style.backgroundColor = '#9FC732';
                    
                    return "class4";
                }
                else 
                    if (bigClassIdDetail == 9) {
                        document.getElementById('imgSupply').src = "./images/pageHead/pageHead/supply_Pd.jpg";
                        
                        // 耗材/OA用纸
                        document.getElementById('colorBorder5px-1').style.borderBottomColor = '#E53228';
                        //document.getElementById('topSearch-box').style.backgroundColor = '#E53228';
                        return "class6";
                    }
                    else 
                        if (bigClassIdDetail == 5) {
                            document.getElementById('imgPcProduct').src = "./images/pageHead/pageHead/pcProduct_Pd.jpg";
                            
                            // PC用品
                            document.getElementById('colorBorder5px-1').style.borderBottomColor = '#1C995F';
                            //document.getElementById('topSearch-box').style.backgroundColor = '#1C995F';
                            return "class9";
                        }
                        else 
                            if (bigClassIdDetail == 7) {
                                document.getElementById('imgOfficeAppliance').src = "./images/pageHead/pageHead/officeAppliance_Pd.jpg";
                                
                                // 办公家电
                                document.getElementById('colorBorder5px-1').style.borderBottomColor = '#8E42A6';
                                //document.getElementById('topSearch-box').style.backgroundColor = '#8E42A6';
                                return "class5";
                            }
                            else 
                                if (bigClassIdDetail == 1) {
                                    document.getElementById('imgPackage').src = "./images/pageHead/pageHead/package_Pd.jpg";
                                    
                                    // 包装/作业用品
                                    document.getElementById('colorBorder5px-1').style.borderBottomColor = '#977155';
                                    //document.getElementById('topSearch-box').style.backgroundColor = '#977155';
                                    return "class7";
                                }
                                else 
                                    if (bigClassIdDetail == 8) {
                                        document.getElementById('imgDailyNecessity').src = "./images/pageHead/pageHead/dailyNecessity_Pd.jpg";
                                        
                                        // 生活用品
                                        document.getElementById('colorBorder5px-1').style.borderBottomColor = '#EF7726';
                                        //document.getElementById('topSearch-box').style.backgroundColor = '#EF7726';
                                        return "class1";
                                    }
                                    else 
                                        if (bigClassIdDetail == 11) {
                                            document.getElementById('imgFood').src = "./images/pageHead/pageHead/food_Pd.jpg";
                                            
                                            // 食品/饮料
                                            document.getElementById('colorBorder5px-1').style.borderBottomColor = '#00B3EF';
                                            //document.getElementById('topSearch-box').style.backgroundColor = '#00B3EF';
                                            return "class8";
                                        }
                                        else 
                                            if (bigClassIdDetail == 12) {
                                                document.getElementById('imgFuriture').src = "./images/pageHead/pageHead/furiture_Pd.jpg";
                                                
                                                // 家具/收纳
                                                document.getElementById('colorBorder5px-1').style.borderBottomColor = '#4F59B7';
                                                //document.getElementById('topSearch-box').style.backgroundColor = '#4F59B7';
                                                return "class11";
                                            }
                                            else 
                                                if (bigClassIdDetail == 13) {
                                                    document.getElementById('imgElectrical').src = "./images/pageHead/pageHead/electrical_Pd.jpg";
                                                    
                                                    // 办公电器
                                                    document.getElementById('colorBorder5px-1').style.borderBottomColor = '#FD81B7';
                                                    //document.getElementById('topSearch-box').style.backgroundColor = '#FD81B7';
                                                    return "class12";
                                                }
                                               	}catch(e){
												// 错误情况直接不校验礼品
												return true;
												}
}

function getClassId1(){



    //先获取浏览器地址
    var url = window.top.location.toString();
    var index = url.indexOf("&classifyId=");
    
    var bigClassId = url.indexOf("&bigClassId");
    
    var gNaviNo = document.getElementById("gNaviNo").value;
    if (index == -1) {
        return null;
    }
    else 
        if (bigClassId == -1) {
            var queryString = url.substr(index + 1);
            
            if (queryString.indexOf("classifyId=4&") != -1 || gNaviNo == 4) {
                document.getElementById('imgStationery').src = "./images/pageHead/pageHead/stationery_Pd.jpg";
                
                // 文具/事务用品
                document.getElementById('colorBorder5px-1').style.borderBottomColor = '#006DBC';
                document.getElementById('topSearch-box').style.backgroundColor = '#006DBC';
                return "class0";
            }
            else 
                if (queryString.indexOf("classifyId=6&") != -1 || gNaviNo == 6) {
                    // 文件夹
                    document.getElementById('imgFolder').src = "./images/pageHead/pageHead/folder_Pd.jpg";
                    
                    document.getElementById('colorBorder5px-1').style.borderBottomColor = '#9FC732';
                    document.getElementById('topSearch-box').style.backgroundColor = '#9FC732';
                    
                    return "class4";
                }
                else 
                    if (queryString.indexOf("classifyId=9&") != -1 || gNaviNo == 9) {
                        document.getElementById('imgSupply').src = "./images/pageHead/pageHead/supply_Pd.jpg";
                        
                        // 耗材/OA用纸
                        document.getElementById('colorBorder5px-1').style.borderBottomColor = '#E53228';
                        document.getElementById('topSearch-box').style.backgroundColor = '#E53228';
                        return "class6";
                    }
                    else 
                        if (queryString.indexOf("classifyId=5&") != -1 || gNaviNo == 5) {
                            document.getElementById('imgPcProduct').src = "./images/pageHead/pageHead/pcProduct_Pd.jpg";
                            
                            // PC用品
                            document.getElementById('colorBorder5px-1').style.borderBottomColor = '#1C995F';
                            document.getElementById('topSearch-box').style.backgroundColor = '#1C995F';
                            return "class9";
                        }
                        else 
                            if (queryString.indexOf("classifyId=7&") != -1 || gNaviNo == 7) {
                                document.getElementById('imgOfficeAppliance').src = "./images/pageHead/pageHead/officeAppliance_Pd.jpg";
                                
                                // 办公家电
                                document.getElementById('colorBorder5px-1').style.borderBottomColor = '#8E42A6';
                                document.getElementById('topSearch-box').style.backgroundColor = '#8E42A6';
                                return "class5";
                            }
                            else 
                                if (queryString.indexOf("classifyId=1&") != -1 || gNaviNo == 1) {
                                    document.getElementById('imgPackage').src = "./images/pageHead/pageHead/package_Pd.jpg";
                                    
                                    // 包装/作业用品
                                    document.getElementById('colorBorder5px-1').style.borderBottomColor = '#977155';
                                    document.getElementById('topSearch-box').style.backgroundColor = '#977155';
                                    return "class7";
                                }
                                else 
                                    if (queryString.indexOf("classifyId=8&") != -1 || gNaviNo == 8) {
                                        document.getElementById('imgDailyNecessity').src = "./images/pageHead/pageHead/dailyNecessity_Pd.jpg";
                                        
                                        // 生活用品
                                        document.getElementById('colorBorder5px-1').style.borderBottomColor = '#EF7726';
                                        document.getElementById('topSearch-box').style.backgroundColor = '#EF7726';
                                        return "class1";
                                    }
                                    else 
                                        if (queryString.indexOf("classifyId=11&") != -1 || gNaviNo == 11) {
                                            document.getElementById('imgFood').src = "./images/pageHead/pageHead/food_Pd.jpg";
                                            
                                            // 食品/饮料
                                            document.getElementById('colorBorder5px-1').style.borderBottomColor = '#00B3EF';
                                            document.getElementById('topSearch-box').style.backgroundColor = '#00B3EF';
                                            return "class8";
                                        }
                                        else 
                                            if (queryString.indexOf("classifyId=12&") != -1 || gNaviNo == 12) {
                                                document.getElementById('imgFuriture').src = "./images/pageHead/pageHead/furiture_Pd.jpg";
                                                
                                                // 家具/收纳
                                                document.getElementById('colorBorder5px-1').style.borderBottomColor = '#4F59B7';
                                                document.getElementById('topSearch-box').style.backgroundColor = '#4F59B7';
                                                return "class11";
                                            }
                                            else 
                                                if (queryString.indexOf("classifyId=13&") != -1 || gNaviNo == 13) {
                                                    document.getElementById('imgElectrical').src = "./images/pageHead/pageHead/electrical_Pd.jpg";
                                                    
                                                    // 办公电器
                                                    document.getElementById('colorBorder5px-1').style.borderBottomColor = '#FD81B7';
                                                    document.getElementById('topSearch-box').style.backgroundColor = '#FD81B7';
                                                    return "class12";
                                                }
            return queryString;
        }
        else 
            if (bigClassId != -1) {
                var queryString = url.substr(index + 1);
				
				var bigClassIdString = url.substr(bigClassId + 1);
                
                if (url.indexOf("&bigClassId=4") != -1) {
                    document.getElementById('imgStationery').src = "./images/pageHead/pageHead/stationery_Pd.jpg";
                    
                    // 文具/事务用品
                    document.getElementById('colorBorder5px-1').style.borderBottomColor = '#006DBC';
                    document.getElementById('topSearch-box').style.backgroundColor = '#006DBC';
                    return "class0";
                }
                else 
                    if (url.indexOf("&bigClassId=6") != -1) {
                        // 文件夹
                        document.getElementById('imgFolder').src = "./images/pageHead/pageHead/folder_Pd.jpg";
                        
                        document.getElementById('colorBorder5px-1').style.borderBottomColor = '#9FC732';
                        document.getElementById('topSearch-box').style.backgroundColor = '#9FC732';
                        
                        return "class4";
                    }
                    else 
                        if (url.indexOf("&bigClassId=9") != -1 ) {
                            document.getElementById('imgSupply').src = "./images/pageHead/pageHead/supply_Pd.jpg";
                            
                            // 耗材/OA用纸
                            document.getElementById('colorBorder5px-1').style.borderBottomColor = '#E53228';
                            document.getElementById('topSearch-box').style.backgroundColor = '#E53228';
                            return "class6";
                        }
                        else 
                            if (url.indexOf("&bigClassId=5") != -1 ) {
                                document.getElementById('imgPcProduct').src = "./images/pageHead/pageHead/pcProduct_Pd.jpg";
                                
                                // PC用品
                                document.getElementById('colorBorder5px-1').style.borderBottomColor = '#1C995F';
                                document.getElementById('topSearch-box').style.backgroundColor = '#1C995F';
                                return "class9";
                            }
                            else 
                                if (url.indexOf("&bigClassId=7") != -1 ) {
                                    document.getElementById('imgOfficeAppliance').src = "./images/pageHead/pageHead/officeAppliance_Pd.jpg";
                                    
                                    // 办公家电
                                    document.getElementById('colorBorder5px-1').style.borderBottomColor = '#8E42A6';
                                    document.getElementById('topSearch-box').style.backgroundColor = '#8E42A6';
                                    return "class5";
                                }
                                else 
                                    if (url.indexOf("&bigClassId=1") != -1 && url.indexOf("&bigClassId=11") == -1 && url.indexOf("&bigClassId=12") == -1&& url.indexOf("&bigClassId=13") == -1) {
                                        document.getElementById('imgPackage').src = "./images/pageHead/pageHead/package_Pd.jpg";
                                        
                                        // 包装/作业用品
                                        document.getElementById('colorBorder5px-1').style.borderBottomColor = '#977155';
                                        document.getElementById('topSearch-box').style.backgroundColor = '#977155';
                                        return "class7";
                                    }
                                    else 
                                        if (url.indexOf("&bigClassId=8") != -1 ) {
                                            document.getElementById('imgDailyNecessity').src = "./images/pageHead/pageHead/dailyNecessity_Pd.jpg";
                                            
                                            // 生活用品
                                            document.getElementById('colorBorder5px-1').style.borderBottomColor = '#EF7726';
                                            document.getElementById('topSearch-box').style.backgroundColor = '#EF7726';
                                            return "class1";
                                        }
                                        else 
                                            if (url.indexOf("&bigClassId=11") != -1 ) {
                                                document.getElementById('imgFood').src = "./images/pageHead/pageHead/food_Pd.jpg";
                                                
                                                // 食品/饮料
                                                document.getElementById('colorBorder5px-1').style.borderBottomColor = '#00B3EF';
                                                document.getElementById('topSearch-box').style.backgroundColor = '#00B3EF';
                                                return "class8";
                                            }
                                            else 
                                                if (url.indexOf("&bigClassId=12") != -1 ) {
                                                    document.getElementById('imgFuriture').src = "./images/pageHead/pageHead/furiture_Pd.jpg";
                                                    
                                                    // 家具/收纳
                                                    document.getElementById('colorBorder5px-1').style.borderBottomColor = '#4F59B7';
                                                    document.getElementById('topSearch-box').style.backgroundColor = '#4F59B7';
                                                    return "class11";
                                                }
                                                else 
                                                    if (url.indexOf("&bigClassId=13") != -1) {
                                                        document.getElementById('imgElectrical').src = "./images/pageHead/pageHead/electrical_Pd.jpg";
                                                        
                                                        // 办公电器
                                                        document.getElementById('colorBorder5px-1').style.borderBottomColor = '#FD81B7';
                                                        document.getElementById('topSearch-box').style.backgroundColor = '#FD81B7';
                                                        return "class12";
                                                    }
                return queryString;
            }
    
}

function getClassId2(){
    getClassId('colorBorder5px-2');
}

function getClassId3(){
    getClassId('midashi-colorBorder-1');
}

function getClassId4(){
    getClassId('head1');
}


function getClassId(elementById){
    var gNaviNo;
    if (document.getElementById("gNaviNo") == null) {
        gNaviNo = "";
    }
    else {
        gNaviNo = document.getElementById("gNaviNo").value;
    }
    
    
    //先获取浏览器地址
    var url = window.top.location.toString();
    var index = url.indexOf("&");
    
    var bigClassId = url.indexOf("&bigClassId");
    
    if (index == -1) {
        return null;
    }
    else 
        if (bigClassId == -1) {
            var queryString = url.substr(index + 1);
            
            if (queryString.indexOf("classifyId=4&") != -1 || gNaviNo == 4) {
                // 文具/事务用品
                document.getElementById(elementById).style.borderBottomColor = '#006DBC';
                return "class0";
            }
            else 
                if (queryString.indexOf("classifyId=6&") != -1 || gNaviNo == 6) {
                    document.getElementById(elementById).style.borderBottomColor = '#9FC732';
                    return "class4";
                }
                else 
                    if (queryString.indexOf("classifyId=9&") != -1 || gNaviNo == 9) {
                        document.getElementById(elementById).style.borderBottomColor = '#E53228';
                        
                        return "class6";
                    }
                    else 
                        if (queryString.indexOf("classifyId=5&") != -1 || gNaviNo == 5) {
                            document.getElementById(elementById).style.borderBottomColor = '#1C995F';
                            
                            return "class9";
                        }
                        else 
                            if (queryString.indexOf("classifyId=7&") != -1 || gNaviNo == 7) {
                                document.getElementById(elementById).style.borderBottomColor = '#8E42A6';
                                
                                return "class5";
                            }
                            else 
                                if (queryString.indexOf("classifyId=1&") != -1 || gNaviNo == 1) {
                                    document.getElementById(elementById).style.borderBottomColor = '#977155';
                                    
                                    return "class7";
                                }
                                else 
                                    if (queryString.indexOf("classifyId=8&") != -1 || gNaviNo == 8) {
                                        document.getElementById(elementById).style.borderBottomColor = '#EF7726';
                                        
                                        return "class1";
                                    }
                                    else 
                                        if (queryString.indexOf("classifyId=11&") != -1 || gNaviNo == 11) {
                                            document.getElementById(elementById).style.borderBottomColor = '#00B3EF';
                                            
                                            return "class8";
                                        }
                                        else 
                                            if (queryString.indexOf("classifyId=12&") != -1 || gNaviNo == 12) {
                                                document.getElementById(elementById).style.borderBottomColor = '#4F59B7';
                                                
                                                return "class11";
                                            }
                                            else 
                                                if (queryString.indexOf("classifyId=13&") != -1 || gNaviNo == 13) {
                                                    document.getElementById(elementById).style.borderBottomColor = '#FD81B7';
                                                    
                                                    return "class12";
                                                }
            return queryString;
        }
        else 
            if (bigClassId != -1) {
                var queryString = url.substr(index + 1);
                
                var bigClassIdString = url.substr(bigClassId + 1);
                
                if (url.indexOf("&bigClassId=4") != -1) {
                    document.getElementById(elementById).style.borderBottomColor = '#006DBC';
                    return "class0";
                }
                else 
                    if (url.indexOf("&bigClassId=6") != -1) {
                        // 文件夹
                        document.getElementById(elementById).style.borderBottomColor = '#9FC732';
						return "class4";
                    }
                    else 
                        if (url.indexOf("&bigClassId=9") != -1) {
							document.getElementById(elementById).style.borderBottomColor = '#E53228';
							return "class6";
                        }
                        else 
                            if (url.indexOf("&bigClassId=5") != -1) {
								document.getElementById(elementById).style.borderBottomColor = '#1C995F';
                                return "class9";
                            }
                            else 
                                if (url.indexOf("&bigClassId=7") != -1) {
									document.getElementById(elementById).style.borderBottomColor = '#8E42A6';
                                    return "class5";
                                }
                                else 
                                    if (url.indexOf("&bigClassId=1") != -1 && url.indexOf("&bigClassId=11") == -1 && url.indexOf("&bigClassId=12") == -1 && url.indexOf("&bigClassId=13") == -1) {
                                        document.getElementById(elementById).style.borderBottomColor = '#977155';
										return "class7";
                                    }
                                    else 
                                        if (url.indexOf("&bigClassId=8") != -1) {
											document.getElementById(elementById).style.borderBottomColor = '#EF7726';
											return "class1";
                                        }
                                        else 
                                            if (url.indexOf("&bigClassId=11") != -1) {
												document.getElementById(elementById).style.borderBottomColor = '#00B3EF';
                                                return "class8";
                                            }
                                            else 
                                                if (url.indexOf("&bigClassId=12") != -1) {
													document.getElementById(elementById).style.borderBottomColor = '#4F59B7';
                                                    return "class11";
                                                }
                                                else 
                                                    if (url.indexOf("&bigClassId=13") != -1) {
														document.getElementById(elementById).style.borderBottomColor = '#FD81B7';
                                                        return "class12";
                                                    }
                return queryString;
            }
}

