﻿// JScript 文件

// JScript 文件
document.write('<link rel="shortcut icon" href="/images/logo.ico" type="image/x-icon">');
/////////////定义xmlhttp
function createXH(){ 
var A=null; 
try { A=new ActiveXObject('Msxml2.XMLHTTP') } catch(e) { 
 try{A=new ActiveXObject('Microsoft.XMLHTTP') } catch(oc) {  A=null } 
} 
if ( !A && typeof XMLHttpRequest != 'undefined' ) { A=new XMLHttpRequest() } 
return A 
}
function createtype(){ 
var A=null; 
var c=0
try { A=new ActiveXObject('Msxml2.XMLHTTP') } catch(e) { 
 try{A=new ActiveXObject('Microsoft.XMLHTTP') } catch(oc) {  c=1 } 
} 
if ( !A && typeof XMLHttpRequest != 'undefined' ) { A=new XMLHttpRequest() } 
return c 
}
var ietype=createtype();
var if_show;
var bar="";

var $ = function (id) {
//获取对象
	return document.getElementById(id);
};

var $A=function(id)
{
var out="";
var q=document.getElementsByName(id); 
for(var p=0;p<q.length;p++)
{
if (q[p].checked)
{
if(out=="")
{
out=out+q[p].value;

}
else 
{
out=out+","+q[p].value;

}

}


}

return out;
}



///////////////
////////////////璺彐版?
function get_datavalue(url,id)
{
db_in = createXH();
if(ietype==0) 
{
db_in.onreadystatechange= function()
{
if (db_in.readyState=="4")
    {   
var show_text=$(id);
var show=db_in.responseText;
//alert(show);
if(show_text != null){
    show_text.value=show; 
}
}
};

}
else if(ietype==1)
{
db_in.onload=function()
{
  
 
    var show_text=$(id);
var show=db_in.responseText;
    show_text.value=show; 
     
   
    
}
}

db_in.open("Get",url,false);
db_in.send(null);

}
////////////////////
////////////////获取数据
function get_database(url,id)
{
//alert(0);
db_in = createXH();
if(ietype==0) 
{
db_in.onreadystatechange= function()
{
if (db_in.readyState=="4")
    {   
var show_text=$(id);
var show=db_in.responseText;
    show_text.innerHTML=show; 
    }
};

}
else if(ietype==1)
{
        db_in.onload=function()
        {
        var show_text=$(id);
        var show=db_in.responseText;
        show_text.innerHTML=show; 
        }
}

db_in.open("Get",url,false);
db_in.send(null);

}
function get_database_value(url,id,show_count)
{
db_in = createXH();
if(ietype==0) 
{
db_in.onreadystatechange= function()
{
if (db_in.readyState=="4")
    {   
var show_text=$(id);
var show=db_in.responseText;
    show_text.value=show; 
    $(show_count).innerHTML=show;
    }
};

}
else if(ietype==1)
{
        db_in.onload=function()
        {
        var show_text=$(id);
        var show=db_in.responseText;
        show_text.value=show; 
          $(show_count).innerHTML=show;
        }
}

db_in.open("Get",url,false);
db_in.send(null);

}
/////注册验证
function affirm(name,typename,typename2)
{
//alert(typename);
var values2;
var values;
if ($(typename2)!=null)
{
values2=$(typename2).value;
//alert(values2);
}
else 
{
values2="";
}
if (typename=="reg_success_show"||typename=="reg_edit_show")
{

values=name;


}
else 
{
    if ($(name)!=null)
    {
    values=$(name).value;
    //alert(values);
    }
    else 
    {
    values="";
    }
}
var reg_url="affirm.aspx?typename="+typename+"&values="+values+"&values2="+values2+"";
//alert(reg_url);
db_in = createXH();
if(ietype==0) 
{
db_in.onreadystatechange= function()
{
if (db_in.readyState=="4")
    {   
var show_text=$(typename);
if (show_text!=null)
{
var show=db_in.responseText;
    show_text.innerHTML=show;
    //alert(show); 
    }
    }
};

}
else if(ietype==1)
{
db_in.onload=function()
{
  
 
    var show_text=$(typename);
var show=db_in.responseText;
    show_text.innerHTML=show; 
     
   
    
}
}

db_in.open("Get",reg_url,false);
db_in.send(null);

//}


}
//---------------------
function check()
{
	var pass1 = $("ctl00_ContentPlaceHolder1_password1").value;
	var pass2 = $("ctl00_ContentPlaceHolder1_password_reg").value;
	
	
	if( (pass1.length != 0 || pass1 != "" || pass2.length != 0 || pass2 != "") && (pass1 != pass2) )
	{		
		alert("2次密码输入的不一致,请重新输入 或 默认不修改密码");
		$("ctl00_ContentPlaceHolder1_password_reg").value = "";
		$("ctl00_ContentPlaceHolder1_password1").value = "";
		$("ctl00_ContentPlaceHolder1_password1").blur();
		$("ctl00_ContentPlaceHolder1_password_reg").blur();		
		return 1;
	}else
	{
		return 2;
	}
	
}
//////
/////注册确认
function reg_affirm(type_name1)
{

if(check()==1){ return;}
else{	
	
    if (type_name1!="reg_edit_show")
    {
     var char_i="name,user_id,user_card_id,password1,password_reg,mobile_phone,E_MAIL,birthday,contact_address,contact_phone,contact_fox,sex";
    }
    else
    {
     var char_i="name,password1,password_reg,mobile_phone,E_MAIL,birthday,contact_address,contact_phone,contact_fox,sex";

    }
    //alert(char_i);
    var char_j=char_i.split(",");
    var i;
    var reg_text="";
    for (i=0;i<char_j.length;i++)
    {
   // alert(char_j[i]);
        if (char_j[i]=="sex")
        {
            if ($("ctl00_ContentPlaceHolder1_"+char_j[i]).checked)
            {
             reg_text=reg_text+","+"0";
            }
            else
            {    
             reg_text=reg_text+","+"1";
            }
        }
        else 
        {

         reg_text=reg_text+","+$("ctl00_ContentPlaceHolder1_"+char_j[i]).value;

        }

//        if (char_j[i]=="password_reg")
//        {
//         affirm("ctl00_ContentPlaceHolder1_"+char_j[i],char_j[i]+"_show","ctl00_ContentPlaceHolder1_"+char_j[i-1]);
//        }
//        else 
//        {
//         affirm("ctl00_ContentPlaceHolder1_"+char_j[i],char_j[i]+"_show",'');
//        }
    }
    if ($("error")!=null)
    {
     alert('有必填项错误!请你重新填写');
    }
    else 
    {

  affirm(reg_text,type_name1,'');
    if (type_name1=="reg_edit_show")
    {
    setTimeout("location.href='member_edit_done.aspx'",1000);  
    }
    else
    {
    setTimeout("location.href='registration_done.aspx'",1000);  

    }

    }

}
}
var t = 15;


var ta=0;tb="";
function $B(){
    ta = t-1;
    tb = t+"000";

  $("rest").innerHTML=t;
    setInterval("go_to()",1000);
}
window.onload=function()
{
if ( $("rest")!=null)
{
$B();
}
}
function go_to(){
    $("rest").innerHTML=ta--;
    if(ta<0){
 history.go(-3);
    }
    else{
    return;
    }
}
function count_pay(count,id)
{
if (getCookieByName("shoppingcart")!=null)
{
     var i,j,k=0,strTemp;
     strTemp="0123456789";  
     for (i=0;i<count.value.length;i++)
     {
          j=strTemp.indexOf(count.value.charAt(i)); 
          if (j==-1)
          {
               var array_i=getCookieByName("shoppingcart").split("&");
                var array_value=array_i[0].split("=");
                var array_count=array_i[1].split("=");
                var array_value_i=array_value[1].split(",")
                var array_count_i=array_count[1].split(",")
                 alert("数量必须为数字！");   
                for (var i=0;i<array_value_i.length;i++)
                {
              
                    if (array_value_i[i]==id)
                    {
                    count.value=array_count_i[i];
                    }
                }
               
              
                count.focus(); 
                k=1;
          }
      }
     
     if (k==0)
     {
        
        get_database_value("get_money.aspx?"+getCookieByName("shoppingcart")+"&change_count="+count.value+"&change_id="+id,"pay_count","pay")

      }
 }
 else
 {
 delCookie("shoppingcart");
 alert("数据问题");
 location.href='/shopping_cart.aspx';
 }
 
}

function getCookieByName(name)

{

  var strCookie=document.cookie;

  var arrCookie=strCookie.split("; ");

  for(var i=0;i<arrCookie.length;i++)

  {

     var arr=arrCookie[i].split("=");

     if(arr[0]==name)

     {

      

      return unescape(arrCookie[i].replace(name+"=",""));
	  

     }

  }

  return false;

 }
function delCookie(name){//为了删除指定名称的cookie，可以将其过期时间设定为一个过去的时间
   var date = new Date();
   date.setTime(date.getTime() - 10000);
   document.cookie = name + "=a; expires=" + date.toGMTString();
}  
function pay_count(id1,id2)
{

get_database_value("pay_count.aspx?id="+$A("id"), id1,id2)
}
function error()
{
if($("back")!=null)
{
$("show_out").innerHTML="如不能正常播放，<a  href='javascript:void(0);' onclick='error()'>请点击这里</a>";

}
else 
{

$("show_out").innerHTML="如无法正常播放，请下载Flash9.0播放器。<a href='/swf/GetFlash9.rar'>点此下载</a> <a id='back' href='javascript:void(0);' onclick='error()'>请点击这里关闭</a>";
}

}
function copy(id)
{


clipboardData.setData( "Text","www.magicyourlife101.com/video_play.html?id="+id+" ");
alert( "本帖标题和地址已复制到剪贴板，您可按下 Ctrl+V 在任何软 件如：QQ、MSN中进行粘贴发送给好友");

}

///-------------------------------------------
//新版首页表格标签切换的脚本
function hotCarOver(obj)
{
	for (var i=1; i<=2; i++)
	{
		document.getElementById("table"+i).style.display = "none";
		document.getElementById("td"+i).className = "leftdown1";
	}
	document.getElementById("table"+obj.id.replace(/td/i,"")).style.display = "";
	obj.className = "bgimages";
}
function hotCarOver1(obj)
{
	for (var i=3; i<=5; i++)
	{
		document.getElementById("table"+i).style.display = "none";
		document.getElementById("td"+i).className = "leftdown1";
	}
	document.getElementById("table"+obj.id.replace(/td/i,"")).style.display = "";
	obj.className = "bgimages";
}
///---------------------课程show
function collapse(img,objName)
{
	//alert("main.js");
	var q=document.getElementsByName('id1');

	for (var i=0;i<q.length;i++)
	{
		if (objName!=q[i].value)
		{
			if ($('img_'+q[i].value)!=null)
			{
				$('img_'+q[i].value).src = $('img_'+q[i].value).src.replace('open', 'close');
			}
		}
		$(q[i].value).style.display = 'none';
	}

	if (img.src.indexOf('close') != -1)
	{
		img.src = img.src.replace('close', 'open');
		$(objName).style.display = '';
	}
	else if (img.src.indexOf('open') != -1)
	{
		img.src = img.src.replace('open', 'close');
		$(objName).style.display = 'none';
	}
	else 
	{
		$(objName).style.display = '';
	}
}
