$.ajax({ url: "http://"+window.location.host+"/ajax.php?ajax_id=1",
              type:"get",
              dataType:"html",
              data: "location="+escape(window.location.pathname+window.location.search),
              success:function(msg){ 
              $("div#js").html(msg);
              }});
$.ajax({ url: "http://"+window.location.host+"/ajax.php?ajax_id=2",
              type:"get",
              dataType:"html",
              data: "",
              success:function(msg){ 
              $("div#cart_content").html(msg);
              }});
			  
			  
	 var showmua=false;
//var l;
function showmenu(a,b){
//强制hide()
showmua=true;
var e=$('#'+a);
if (e.css("display")=="none"){e.fadeIn('slow');e.css("visibility",'visible'); };
if(b){//默认不传入b参数
   var mc_left = document.getElementById(b).offsetLeft;
   e.css("left",mc_left);
}
}
function hidemenu(a){
showmua=false
setTimeout('hid("'+a+'")',100)
//hid(a)
}
function hid(a){
var e=$('#'+a)
if (e.css("display")=="block" && showmua==false){e.fadeOut('normal')}
showmua=true;
}
//购物车js
	var timer2=null;
    $("#cart_a").hover(function(){
		
		showmenu('cart_content');
		clearTimeout(timer2);
	},function(){
		timer2=setTimeout(function(){hidemenu('cart_content');},600);
	})
	$("#cart_content").hover(function(){
		clearTimeout(timer2);
		showmenu('cart_content');
	},function(){
		timer2=setTimeout(function(){hidemenu('cart_content');},600);
	})
//留言板ajax

   function submit_()
        { 
			$("#msg_table span").remove();
			if($("#customer_id").val()=='0'){
				if(isnotEmail($("#user_email").val())) {
					$("#user_email").after('<br/><span style="color:#FF0000">Email is not correct!</span>');
					return false;
				}
			}
			if($("#msg_content").val().length<6) {
				$("#msg_content").after('<br/><span style="color:#FF0000">Content is too short!</span>');
				return false;
			}
			$("#message_tip").fadeOut('normal');
           $.ajax({ url: "http://"+window.location.host+"/index.php?controller=message",
              type:"post",
              dataType:"html",
              data: "product_id="+$("#product_id").val()+"&user_name="+$("#user_name").val()+"&user_email="+$("#user_email").val()+"&user_tel="+$("#user_tel").val()+"&msg_content="+$("#msg_content").val()+"&checkcode="+$("#checkcode").val(),
              success:function(msg){ 
             $("#message_tip").fadeIn('normal');
		     $("#message_tip").html(msg.slice(1));
			 $("#checkcode").val("");
			$("#img_checkcode").attr({src:$("#img_checkcode").attr("src").slice(0,35)+"?a="+Math.random()});
			 if(msg.slice(0,1)=='1'){
			 $("#msg_table").fadeOut('normal');
			 $("#msg_content").val("");
			 }
			 
              }});
			 
			  return false;
        }
function isnotEmail(strEmail) {
	//if(strEmail=="") return true;
	if (strEmail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
	return false;
	else
	return true;
}

function fucCheckTEL(TEL){
var i,j,strTemp;
	strTemp="0123456789+-()# ";
	for (i=0;i<TEL.length;i++){
		j=strTemp.indexOf(TEL.charAt(i));
		if (j==-1){
		return 0;
		}
	}
	return 1;
} 


//刷新验证码
$("#img_checkcode").click(function(){
	$("#img_checkcode").attr({src:$("#img_checkcode").attr("src").slice(0,35)+"?a="+Math.random()});
	});
$("#hit_to_message").click(function(){
	$("#msg_table").fadeIn('normal');
	});
$("#msg_content").focus(function(){
	$("#div_checkcode").fadeIn('normal');							 
	});

function AutoScroll(obj){
        $(obj).find("ul:first").animate({
                marginTop:"-25px"
        },200,function(){
                $(this).css({marginTop:"0px"}).find("li:first").appendTo(this);
        });
}
$(document).ready(function(){
setInterval('AutoScroll("#scrolldiv")',4000)
});
