﻿function reset_form(e){
	document.getElementById(e).reset();
}

function reset_v_img(){
	var num=document.getElementById("bookmark").xx.value; 
	if(num%2==0){
		document.getElementById('v_img').src='randimg_r.php?'+Math.random();
		document.getElementById("bookmark").xx.value=num*1+1;
	}else{
		document.getElementById('v_img').src='randimg.php?'+Math.random();	
		document.getElementById("bookmark").xx.value=num*1+1;
	}
}

function register_reset_v_img(){
	document.getElementById('v_img').src='randimg.php?'+Math.random();	
}

function seek_password_reset_v_img(){
	document.getElementById('v_img').src='randimg.php?'+Math.random();	
}

function InitAjax()
{
　var ajax=false; 
　try { 
　　ajax = new ActiveXObject("Msxml2.XMLHTTP"); 
　} catch (e) { 
　　try { 
　　　ajax = new ActiveXObject("Microsoft.XMLHTTP"); 
　　} catch (E) { 
　　　ajax = false; 
　　} 
　}
　if (!ajax && typeof XMLHttpRequest!='undefined') { 
　　ajax = new XMLHttpRequest(); 
　} 
　return ajax;
} 

function checkCard(){
	var str=document.getElementById("bookmark");
	var msg = document.getElementById("div_warning_card");
	var st_radio = document.getElementsByName("type");
	var corrent_value;
	if(str.card_id.value!=""){
　		//获取接受返回信息层
		//for()
		for(var i=0;i<st_radio.length;i++){
			if(st_radio[i].checked==true){
				corrent_value = st_radio[i].value;
			}
		}
	
	　	//接收表单的URL地址
		var url = "check_card.php";
	
		//需要POST的值，把每个变量都通过&来联接
		var postStr = "card_id="+ str.card_id.value+"&type="+corrent_value;
	
		//实例化Ajax
		var ajax = InitAjax();
	　
	　	//通过Post方式打开连接
		ajax.open("POST", url, true); 
	
	　	//定义传输的文件HTTP头信息
		ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
	
		//发送POST数据
		ajax.send(postStr);
	
		//获取执行状态
		ajax.onreadystatechange = function() { 
	　　		//如果执行状态成功，那么就把返回信息写到指定的层里
			if (ajax.readyState == 4 && ajax.status == 200) { 
				if(ajax.responseText==3){
					msg.innerHTML = "卡号类型有误"; 
					str.step.value=0;
				}else if (ajax.responseText==1){
					msg.innerHTML = "<img src='images/correct.gif' />"; 
					str.step.value=2;
				}else if (ajax.responseText==2){					
					msg.innerHTML = "卡号已使用"; 
					str.step.value=0;
				}else{					
					msg.innerHTML = "卡号不存在"; 
					str.step.value=0;
				}
			} 
		} 
	}else{
		//msg.innerHTML = "请输入卡号"; 
		str.step.value=0;		
	}
}

function checkCardpassword(){
	var str=document.getElementById("bookmark");
	var msg = document.getElementById("div_warning_cardpassword");
	if(str.card_password_1.value=="" || str.card_password_2.value==""){
		msg.innerHTML = "请输入密码"; 
		str.step.value=0;
	}else{
		msg.innerHTML = ""; 
		//str.step.value=1;
	}
}

function checkVcode(){
	var str=document.getElementById("bookmark");
	var msg = document.getElementById("div_warning_vcode");
	if(str.vi_code.value==""){
		msg.innerHTML = "请输入验证码"; 
		str.step.value=0;
	}else{
		msg.innerHTML = ""; 
		//str.step.value=1;
	}
}

function bookmark_step1(){	
	var str=document.getElementById("bookmark");	
	checkCard();
	checkCardpassword();
	checkVcode();
	if(str.card_password.value==""){
		checkCard();
		checkCardpassword();
		checkVcode();
	}
	if(str.vi_code.value==""){
		checkCard();
		checkCardpassword();
		checkVcode();
	}
	if(str.step.value==2){
		str.card_password.value=str.card_password_1.value+str.card_password_2.value;
		//alert(str.card_password.value);
		str.submit();	
	}
}

function bookmark_confirm(){
	document.getElementById("bookmark").submit();
}

function bookmark_cancel(){
	document.getElementById("confirm_infoarea").style.display="none";
	document.getElementById("infoarea").style.display="";
	document.getElementById("step_two").style.display="block";
	document.getElementById("step_three").style.display="none";

}

function bookmark_step2(){
	var str=document.getElementById("bookmark");
	str.address.value="";	
	if(str.area.value!="3"){
		//if(str.downtown_qu.value!="")str.address.value=str.downtown_qu.value+"区";
		if(str.area.value!="")str.address.value=str.area.value;
		if(str.downtown_lu.value!="")str.address.value+=str.downtown_lu.value+"路";
		if(str.downtown_cun.value!="")str.address.value+=str.downtown_cun.value+"村";
		if(str.downtown_long.value!="")str.address.value+=str.downtown_long.value+"弄";
		//if(str.downtown_zhilong.value!="")str.address.value+=str.downtown_zhilong.value+"支弄";
		if(str.downtown_hao.value!="")str.address.value+=str.downtown_hao.value+"号";
		//if(str.downtown_lou.value!="")str.address.value+=str.downtown_lou.value+"楼";
		//if(str.downtown_zuo.value!="")str.address.value+=str.downtown_zuo.value+"座";
		if(str.downtown_shi.value!="")str.address.value+=str.downtown_shi.value+"室";
	}else{
		str.address.value=str.custom_address.value;
	}	
		//str.address.value=str.downtown_qu.value+"区"+str.downtown_lu.value+"路"+str.downtown_long.value+"弄"+str.downtown_zhilong.value+"支弄"+str.downtown_hao.value+"号"+str.downtown_lou.value+"楼"+str.downtown_zuo.value+"座"+str.downtown_shi.value+"室";			
	/*}else if(str.area.value==2){		
		if(str.outskirt_qu.value!="")str.address.value=str.outskirt_qu.value+"区";
		if(str.outskirt_lu.value!="")str.address.value+=str.outskirt_lu.value+"路";
		if(str.outskirt_zhen.value!="")str.address.value+=str.outskirt_zhen.value+"镇";
		if(str.outskirt_cun.value!="")str.address.value+=str.outskirt_cun.value+"村";
		if(str.outskirt_dui.value!="")str.address.value+=str.outskirt_dui.value+"队";
		if(str.outskirt_zu.value!="")str.address.value+=str.outskirt_zu.value+"组";
		if(str.outskirt_hao.value!="")str.address.value+=str.outskirt_hao.value+"号";
		if(str.outskirt_shi.value!="")str.address.value+=str.outskirt_shi.value+"室";
		
		//str.address.value=str.outskirt_qu.value+"区"+str.outskirt_lu.value+"路"+str.outskirt_zhen.value+"镇"+str.outskirt_cun.value+"村"+str.outskirt_dui.value+"队"+str.outskirt_zu.value+"组"+str.outskirt_hao.value+"号"+str.outskirt_shi.value+"室";		
	}else{
		str.address.value=str.custom_address.value;			
	}*/



	if(trim(str.name.value)==""){
		alert("名字");
	}else if(trim(str.phone.value)==""){
		alert("联系电话");
	}else if(trim(str.cellphone.value)==""){
		alert("手机");
	}else if(trim(str.address.value)==""){
		alert("地址");
	}else if(trim(str.zipcode.value)==""){
		alert("邮编");
	/*}else if(str.email.value==""){
		alert("电子邮箱");*/
	}else if(trim(str.zipcode.value).length!=6){
		alert("邮编应该为6位");
		
	}else{
		var gender_value="";
		for(i=0;i<str.gender.length;i++){
			if(str.gender[i].checked)
			gender_value=str.gender[i].value;
		}		
		document.getElementById("infoarea_name").innerHTML=str.name.value;
		document.getElementById("infoarea_gender").innerHTML=gender_value;
		document.getElementById("infoarea_phone").innerHTML=str.phone.value;
		document.getElementById("infoarea_cellphone").innerHTML=str.cellphone.value;
		document.getElementById("infoarea_address").innerHTML=str.address.value;
		document.getElementById("infoarea_zipcode").innerHTML=str.zipcode.value;
		document.getElementById("infoarea_email").innerHTML=str.email.value;
		
		document.getElementById("confirm_infoarea").style.display="";
		document.getElementById("infoarea").style.display="none";
		document.getElementById("step_two").style.display="none";
		document.getElementById("step_three").style.display="block";
		
		//str.submit();	
	}
}

function trim(str){ //删除左右两端的空格
	return str.replace(/(^\s*)|(\s*$)/g, "");
}
function zipcode_info(){
	document.getElementById("zipcode_letter").style.display="block";	
}

function zipcode_info_1(){
	document.getElementById("zipcode_letter").style.display="none";	
}


function bookmark_application(){
	var str=document.getElementById("bookmark");
	str.address.value="";
	if(str.area.value!="3"){
		//if(str.downtown_qu.value!="")str.address.value=str.downtown_qu.value+"区";
		if(str.area.value!="")str.address.value=str.area.value;
		if(str.downtown_lu.value!="")str.address.value+=str.downtown_lu.value+"路";
		if(str.downtown_cun.value!="")str.address.value+=str.downtown_cun.value+"村";
		if(str.downtown_long.value!="")str.address.value+=str.downtown_long.value+"弄";
		//if(str.downtown_zhilong.value!="")str.address.value+=str.downtown_zhilong.value+"支弄";		
		if(str.downtown_hao.value!="")str.address.value+=str.downtown_hao.value+"号";
		//if(str.downtown_lou.value!="")str.address.value+=str.downtown_lou.value+"楼";
		//if(str.downtown_zuo.value!="")str.address.value+=str.downtown_zuo.value+"座";
		if(str.downtown_shi.value!="")str.address.value+=str.downtown_shi.value+"室";
	}else{
		str.address.value=str.custom_address.value;
	}
		//str.address.value=str.downtown_qu.value+"区"+str.downtown_lu.value+"路"+str.downtown_long.value+"弄"+str.downtown_zhilong.value+"支弄"+str.downtown_hao.value+"号"+str.downtown_lou.value+"楼"+str.downtown_zuo.value+"座"+str.downtown_shi.value+"室";			
	/*}else if(str.area.value==2){		
		if(str.outskirt_qu.value!="")str.address.value=str.outskirt_qu.value+"区";
		if(str.outskirt_lu.value!="")str.address.value+=str.outskirt_lu.value+"路";
		if(str.outskirt_zhen.value!="")str.address.value+=str.outskirt_zhen.value+"镇";
		if(str.outskirt_cun.value!="")str.address.value+=str.outskirt_cun.value+"村";
		if(str.outskirt_dui.value!="")str.address.value+=str.outskirt_dui.value+"队";
		if(str.outskirt_zu.value!="")str.address.value+=str.outskirt_zu.value+"组";
		if(str.outskirt_hao.value!="")str.address.value+=str.outskirt_hao.value+"号";
		if(str.outskirt_shi.value!="")str.address.value+=str.outskirt_shi.value+"室";
		
		//str.address.value=str.outskirt_qu.value+"区"+str.outskirt_lu.value+"路"+str.outskirt_zhen.value+"镇"+str.outskirt_cun.value+"村"+str.outskirt_dui.value+"队"+str.outskirt_zu.value+"组"+str.outskirt_hao.value+"号"+str.outskirt_shi.value+"室";		
	}else{
		str.address.value=str.custom_address.value;			
	}*/
	
	if(str.name.value==""){
		alert("名字");
	}else if(str.phone.value==""){
		alert("联系电话");
	}else if(str.cellphone.value==""){
		alert("手机");
	}else if(str.address.value==""){
		alert("地址");
	}else if(str.zipcode.value==""){
		alert("邮编");
	/*}else if(str.email.value==""){
		alert("电子邮箱");*/
	}else{
		var gender_value="";
		for(i=0;i<str.gender.length;i++){
			if(str.gender[i].checked)
			gender_value=str.gender[i].value;
		}	
		//if(str.type.value==1){
		//	document.getElementById("infoarea_type").innerHTML="全年";
		//}else{
		//	document.getElementById("infoarea_type").innerHTML="半年";
		//}
		document.getElementById("infoarea_type").innerHTML=str.date_from.value+"至"+str.date_to.value;
		
		document.getElementById("infoarea_name").innerHTML=str.name.value;
		document.getElementById("infoarea_gender").innerHTML=gender_value;
		document.getElementById("infoarea_phone").innerHTML=str.phone.value;
		document.getElementById("infoarea_cellphone").innerHTML=str.cellphone.value;
		document.getElementById("infoarea_address").innerHTML=str.address.value;
		document.getElementById("infoarea_zipcode").innerHTML=str.zipcode.value;
		document.getElementById("infoarea_email").innerHTML=str.email.value;
		
		document.getElementById("confirm_infoarea").style.display="";
		document.getElementById("infoarea").style.display="none";
		//str.submit();	
	}
}

function bookmarkAddressChange(num){
	/*if(num==1){
		bookmarkAddressHide();
		document.getElementById("downtown").style.display='';
	}else if(num==2){
		bookmarkAddressHide();
		document.getElementById("outskirt").style.display='';*/
	if(num!=3){	
		bookmarkAddressHide();
		document.getElementById("downtown").style.display='';
	}else{
		bookmarkAddressHide();
		document.getElementById("custom").style.display='';
	}
	
}

function bookmarkAddressHide(){
	document.getElementById("downtown").style.display='none';
	//document.getElementById("outskirt").style.display='none';
	document.getElementById("custom").style.display='none';
}

<!-- 设为首页兼容Firefox IE -->
function addFavor(title, url){ 
if (document.all) 
window.external.AddFavorite(url, title); 
else if (window.sidebar) 
window.sidebar.addPanel(title, url, "") 
}


<!-- 加入收藏兼容FFIE -->
function AddFavorite(sURL, sTitle)
{
     try
     {
         window.external.addFavorite(sURL, sTitle);
     }
     catch (e)
     {
         try
         {
             window.sidebar.addPanel(sTitle, sURL, "");
         }
         catch (e)
         {
             alert("加入收藏失败，麻烦您手动添加。");
         }
     }
}

function pageto(element){
	document.getElementById(element).submit();
}

function DrawImage(ImgD,x_L,y_L){ 
	var image=new Image(); 
	image.src=ImgD.src; 
	if(image.width>0 && image.height>0){ 
		flag=true; 
		if(image.width/image.height>= x_L/y_L){ 
			if(image.width>x_L){
				ImgD.width=x_L; 
				ImgD.height=(image.height*x_L)/image.width; 
			}else{ 
				ImgD.width=image.width;
				ImgD.height=image.height; 
			} 
			ImgD.alt=image.width+"x"+image.height; 
		}else{ 
			if(image.height>y_L){
				ImgD.height=y_L; 
				ImgD.width=(image.width*y_L)/image.height; 
			}else{ 
				ImgD.width=image.width;
				ImgD.height=image.height; 
			} 
			//ImgD.alt=image.width+"x"+image.height; 
		} 
	}
}

/*

 bookmark v2


*/
function showCardcontent(n){

	var str=document.getElementById("bookmark");
	target_div=document.getElementById("card_content");
	if(n==1){
		target_div.innerHTML='<img width="208" height="278" style="float: right;" src="images/dingka/quan.jpg">';
	}else if(n==2){
		target_div.innerHTML='<img width="208" height="278" style="float: right;" src="images/dingka/ban.jpg">';
	}else if(n==3){
		target_div.innerHTML='<img width="208" height="278" style="float: right;" src="images/dingka/ji.jpg">';
	}else if(n==4){
		target_div.innerHTML='<img width="208" height="278" style="float: right;" src="images/dingka/yue.jpg">';
	}else if(n==5){
		target_div.innerHTML='<img width="208" height="278" style="float: right;" src="images/dingka/nv.jpg">';
	}
    checkCard();
}


function getCookie(name){   
    var arg = name+ "=";   
    var alen = arg.length;   
    var clen = document.cookie.length;   
    var i = 0;   
    var j = 0;   
    while(i < clen){   
        j = i + alen;   
        if (document.cookie.substring(i, j) == arg) 
            return Cookies.getCookieVal(j);
        i = document.cookie.indexOf(" ", i) + 1;   
        if(i == 0)   
            break;   
    }   
    return null;   
}


    var http_request = false;
    function makeRequest(url) {

        http_request = false;

        if (window.XMLHttpRequest) { // Mozilla, Safari,...
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
            }
        } else if (window.ActiveXObject) { // IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }

       http_request.onreadystatechange = alertContents;
        http_request.open('GET', url, true);
        http_request.send(null);

    }

    function alertContents() {
		var die = document.getElementById('fdcsd');
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
                //alert(http_request.responseText);
				//alert(die.innerHTML);
				die.innerHTML = http_request.responseText;
            } else {
            }
        }

    }
	function index_goods(){

$(".productshow:eq(0)").Xslider({
		unitdisplayed:3,
		numtoMove:2,
	   loop:"cycle"	
	});
	
	//二、左右切换：最后一个显示在最右侧;
	$(".productshow:eq(1)").Xslider({
		unitdisplayed:3,
		numtoMove:3,
		autoscroll:2000  //自动移动间隔时间     默认null不自动移动;
	});
	
	//三、自动切换;
	$(".productshow:eq(2)").Xslider({
		unitdisplayed:3,
		numtoMove:3,
		autoscroll:2000  //自动移动间隔时间     默认null不自动移动;
	});
	
	//四、循环切换;
	$(".productshow:eq(3)").Xslider({
		unitdisplayed:3,
		numtoMove:2,
		loop:"cycle"
	});
	
	//五、文本的上下滚动;
	$(".vscroll").Xslider({//.productshow是要移动对象的外框;
		unitdisplayed:6,//可视的单位个数   必需项;
		numtoMove:3,//要移动的单位个数    必需项;
		viewedSize:120,//可视宽度或高度    默认查找要移动对象外层的宽或高度;
		scrollobj:".vscrollobj",//要移动的对象     默认查找productshow下的ul;
		unitlen:20,//移动的单位宽或高度     默认查找li的尺寸;
		scrollobjSize:$(".vscrollobj").height(),//移动最长宽或高（要移动对象的宽度或高度）   默认由li个数乘以unitlen所得的积;
		dir:"V"//水平移动还是垂直移动，默认H为水平移动，传入V则表示垂直移动;
	});
	
	//六、上下切换;
	$(".videolistwraper").Xslider({//.productshow是要移动对象的外框;
		unitdisplayed:2,//可视的单位个数   必需项;
		numtoMove:1,//要移动的单位个数    必需项;
		//loop:"cycle",
		dir:"V"//水平移动还是垂直移动，默认H为水平移动，传入V则表示垂直移动;
	});
	
	//七、上下自动循环切换;
	$(".newslistwraper").Xslider({
		unitdisplayed:1,
		numtoMove:1,
		loop:"cycle",
		dir:"V",
		autoscroll:2500,
		speed:300
	});
	
	
	$("a").focus(function(){this.blur();});


	}
