﻿$(document).ready(function(){
	/*category*/
	var cat_Totggle = false;
	if(cat_Totggle)
	{
	  $('#categorybox').removeClass('hcategory').addClass('hcategory2');
	  totggleCategory(); 
	}else{
	  $('#categorybox').removeClass('hcategory2').addClass('hcategory');
	  var category_barHeight = $('#category_bar').height()+10;
	  $('.c_left:first').prepend("<div style='height:"+category_barHeight+"px'>&nbsp;</div>"); 
	}
	function totggleCategory()
	{
		$('#categorybox').hover(
			function(){
	     		$(this).find('#category_bar').show();
         		$(this).find('#cate_tit').removeClass('cate-tit').addClass('cate-tit-hover');
	 		},
	 		function(){
	     		$(this).find('#cate_tit').removeClass('cate-tit-hover').addClass('cate-tit');
	     		$(this).find('#category_bar').hide();
	 		}
		); 	
  }
    $('.cate_item').hover(
	function(){
	   var id = $(this).index(this);
	   $(this).addClass('hover');
	   $(this).find('.citem').show();
	   var uid=$(this).attr("uid");
	   if (uid!=undefined && uid!=""){
	   	   var citem=$(this).find(".citem_left");
	   	   if (citem.find("div").length==1){
	   	   		$.ajax({
               		url: "/servlet/async.do",
               		type: 'POST',
               		data: "do=category_store&id="+uid,
               		dataType: "xml",
               		cache: false,
               		success: function(data){
            	   		property = $(data).find("content");
            	   		citem.html(citem.html()+$("value",property[0]).text());
               		}
           		});
           }
       }
	   $(this).find('b').hide();//隐藏箭头
	   $(this).siblings().find('.citem').hide();
	 },
	 function(){
	   $(this).removeClass('hover');
	   $(this).find('b').show();//显示箭头
	   $(this).find('.citem').hide();
	 }
	);
	/*end category*/
    $("#searchcategory li").mousedown(
  		function()
  		{
    		$("#searchcategory li").removeClass("select");
    		$(this).addClass("select");
    		$("#searchcontent01").hide();
    		$("#searchcontent02").hide();
    		$("#searchcontent03").hide();
    		$("#searchcontent0" + $(this).attr("tabindex")).show();
  		}
  	);
  	$("#contentmenu li").mousedown(
  		function()
  		{
    		$("#contentmenu li").removeClass("select");
    		$(this).addClass("select");
    		for (i=1;i<=$("#contentmenu").find("ul").attr("id");i++){
    			$("#introcontent0" + i).hide();
    		}
    		$("#introcontent0" + $(this).attr("tabindex")).show();
			if ($(this).attr("tabindex")=='1'){
    			introcontent();
    		}
  		}
  	);
})
function search(id){
	var q=document.getElementById(id);
	if(q.value.replace(/\s/g,"")==""){
		alert("搜索内容不能为空");
		return false;
	}else if (q.value==q.defaultValue){
		alert(q.defaultValue);
		return false;
	}
}
function logout(){
	$.ajax({
               url: "/servlet/passport.do",
               type: 'GET',
               cache: false,
               success: function(data){
                   $("#logininfo").html(data);
               }
           });
}
function check_login(){
	$.ajax({
               url: "/servlet/check.do?do=login",
               type: 'GET',
               cache: false,
               success: function(data){
                   $("#logininfo").html(data);
               }
           });
}
function verifycode(){
	$("#verifycode").attr("src","/servlet/verifycode.do?"+Math.random());
}
is=function(n,s){
		var p={number:/^[\d|\.|,]+$/,int:/^\d+$/,email:/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/,mobile:/^(((1[3|4|5|8]{1}[0-9]{1}))[0-9]{8})$/,tel:/^((0\d{2,3})-)?(\d{7,8})(-(\d{3,}))?$/,fax:/^((0\d{2,3})-)?(\d{7,8})(-(\d{3,}))?$/,zip:/^\d{6}$/,qq:/^\d{4,}$/,http:/^(http:\/\/)?[-A-Za-z0-9]+\.[-A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"\"])*$/,date:/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/,zhcn:/^[\u0391-\uFFE5]+$/,nick:/^[\u0391-\uFFE5a-zA-Z0-9_]+$/,price:/^(([1-9]\d*)|0)(\.\d{1,2})?$/,letter:/^[A-Za-z]+$/}
		return p[n].test(s);
};
function addFavorite(tourl, title)
{
    var url, urltitle;
    if (typeof(tourl) == "string" && tourl.length > 0 ){
        url = tourl; 
    }else{
        url = location.href;
    }
    if (typeof(title) =="string" && title.length > 0 )
      urltitle = title;
    else
      urltitle = "鸥乐网 - 海外购物返现,优惠折扣全攻略";
    if ( window.sidebar && 'object' == typeof( window.sidebar ) && 'function' == typeof( window.sidebar.addPanel ) ){
        window.sidebar.addPanel( urltitle , url  , '');
    }else if ( document.all && 'object' == typeof( window.external ) ){
        window.external.AddFavorite(url, urltitle);
    }else if(window.opera && window.print){}else{
        //safri
        alert('请按Ctrl+D之后按“确定”完成收藏!'); 
    }
}
function setHomepage(){
    if (document.all){
        document.body.style.behavior='url(#default#homepage)';
          document.body.setHomePage(window.location.href);
    }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;
            }
        }
        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);
        prefs.setCharPref('browser.startup.homepage',window.location.href);
    }else{
        alert('您的浏览器不支持自动自动设置首页, 请使用浏览器菜单手动设置!');
    }
}
function img_hover(element){
	element.addClass("goods_list_img_hover");
	var $slideDiv=element.parent().find('.info');
	if ($slideDiv.length === 0) {
		return;
	}
	$slideDiv.css("top",element.offset().top+100);
	$slideDiv.css("left",element.offset().left-220);
	$slideDiv.show();
}
function img_out(element){
	element.removeClass("goods_list_img_hover");
	var $slideDiv=element.parent().find('.info');
	if ($slideDiv.length === 0) {
		return;
	}
	$slideDiv.hide();
}
