function getCookie(name)
{
    var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
        if(arr=document.cookie.match(reg)) return unescape(arr[2]);
        else return null;
}
function setCookie(name,value)
{
    //var Days = 30;
    var exp  = new Date();    //new Date("December 31, 9998");
        exp.setTime(exp.getTime() + 30*60*1000);//30minete timeout
        document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
}

String.prototype.Trim = function() {  
  var m = this.match(/^\s*(\S+(\s+\S+)*)\s*$/);  
  return (m == null) ? "" : m[1];  
}  
String.prototype.isMobile = function() {  
  return (/^(?:13\d|15[012345689]|6)-?\d{4,5}(\d{3}|\*{2})$/.test(this.Trim()));  
}
function chkform(){
	if(document.form2.cj_song.value==''){
		alert("您没有选够三首歌");
		return false;
		}
if (document.form2.youname.value!=''&&document.form2.youname.value.length>4){
alert("姓名过长");
document.form2.youname.value='';
document.form2.youname.focus();
return false;
}
if(document.form2.phone.value!=''){
 if (document.form2.phone.value.isMobile())  {  
		document.form2.phone.value=document.form2.phone.value.Trim();  
		 setCookie("cj","1");
	  } else {  
		alert("电话号码不对");
		document.form2.phone.value='';
		document.form2.phone.focus();
	  return false;
	    }  
	  }
}

function getname(a){
return document.getElementsByName(a);
}
function getid(a){
return document.getElementById(a);
}
function switc(b){
var player_str = '<object id="MediaPlayer1" width="242" height="63" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112" align="baseline" border="0" standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject"><param name="URL" value="'+b+'"><param name="autoStart" value="true"><param name="invokeURLs" value="false"><param name="playCount" value="100"><param name="defaultFrame" value="datawindow"><embed src="'+b+'" align="baseline" border="0" width="350" height="68" type="application/x-mplayer2"pluginspage="" name="MediaPlayer1" showcontrols="1" showpositioncontrols="0" showaudiocontrols="1" showtracker="1" showdisplay="0" showstatusbar="1" autosize="0" showgotobar="0" showcaptioning="0" autostart="1" autorewind="0" animationatstart="0" transparentatstart="0" allowscan="1" enablecontextmenu="1" clicktoplay="0" defaultframe="datawindow" invokeurls="0"></embed></object>';
getid("box").innerHTML=player_str;
}
var player_str = '<object id="MediaPlayer1" width="242" height="63" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112" align="baseline" border="0" standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject"><param name="URL" value="02.mp3"><param name="autoStart" value="true"><param name="invokeURLs" value="false"><param name="playCount" value="100"><param name="defaultFrame" value="datawindow"><embed src="02.mp3" align="baseline" border="0" width="350" height="68" type="application/x-mplayer2"pluginspage="" name="MediaPlayer1" showcontrols="1" showpositioncontrols="0" showaudiocontrols="1" showtracker="1" showdisplay="0" showstatusbar="1" autosize="0" showgotobar="0" showcaptioning="0" autostart="1" autorewind="0" animationatstart="0" transparentatstart="0" allowscan="1" enablecontextmenu="1" clicktoplay="0" defaultframe="datawindow" invokeurls="0"></embed></object>';

function clear(){
var obj=document.getElementById("foo");
var his=obj.getElementsByTagName("INPUT");
for(k=0;k<his.length;k++){
his[k].checked=false;
document.getElementById("box").value="";
}
}
var ii=0;
function chk(){


//alert(event.srcElement.checked)
if(event.srcElement.checked==true){
ii++;

}else if(event.srcElement.checked==false){
if(ii>0){
ii--;}
}
//this.innerHTML+="!";
if(ii>2){
//alert(ii);
document.getElementById("addgif").style.display="none";
getid('inp').style.display='none';
var obj=document.getElementById("foo");
var his=obj.getElementsByTagName("INPUT");
//alert(his.length);
for(b=0;b<his.length;b++){
his[b].style.visibility="hidden";
if(his[b].checked){
//alert(his[b].nextNode.length);
if(document.getElementById("so").value==''){
document.getElementById("so").value=his[b].value
}else{
document.getElementById("so").value+=","+his[b].value;
}
}
}
}
}
function clear(){
var obj=document.getElementById("foo");
var his=obj.getElementsByTagName("INPUT");
for(k=0;k<his.length;k++){
his[k].checked=false;
document.getElementById("so").value="";
}
}
function openbox(){
	var dk=getid("dctable");
	var dcbg=getid("dcbg");
	var box1=getid("box1");
	//alert(box2.nodeName);
	//alert(getCookie("cj"));
	if(getCookie("cj")=='1'){
		alert("参与速度过快，稍候再参与");
		
		}else{
			clear();
			box1.style.height=Math.max(document.documentElement.scrollHeight, document.documentElement.clientHeight) + 'px';
			box1.style.width=document.documentElement.clientWidth+"px";
box1.style.display="block";
dcbg.style.left=(document.documentElement.clientWidth/2-581/2)+"px";
dk.style.left=dcbg.style.left;
			dcbg.style.display="block";
			dk.style.display="block";
			}
	}
	
	
	//////////////////////////////
	function SetString(str,len)
{
 var strlen = 0; 
 var s = "";
for(var i = 0;i < str.length;i++)
{
        if(str.charCodeAt(i) > 128)
         strlen += 2;
        else 
        strlen++;
        s += str.charAt(i);
        if(strlen >= len) 
        return s;
}
return s;
}

function ckf3(){
	if(document.form3.pl_msg.value.Trim()==''){
		alert("评论内容不能为空");
		return false;
		}else{
			setCookie("pl","1");
			document.form3.submit();
			}
	}

function OpenBox(){
	//alert(unescape(getCookie("pl")));
	if(getCookie("pl")=="1"){
		alert("您刚评论过了 请稍后再来评论");
		}else{
var box1=document.getElementById("box1");
var box2=document.getElementById("box2");
box1.style.width=document.documentElement.clientWidth+"px";
box1.style.height=Math.max(document.documentElement.scrollHeight, document.documentElement.clientHeight) + 'px';
box1.style.display="block";
box2.style.display="block";
cccc=165+document.documentElement.scrollTop;
box2.style.top=cccc+"px";
document.getElementById("msag").value='';
		}
}
function chkp(){
	var fm=document.form1;
	if(fm.dp_num.value==''||fm.dp_num.value.search("^-?\\d+(\\.\\d+)?$")!=0){
		alert("订票张数不能为空而其不能为非数字");
		fm.dp_num.focus();
		fm.dp_num.value='';
		return false;
		}
	if(fm.dp_name.value==''||fm.dp_name.value.length>5){
		alert("请填写正确的姓名");
		fm.dp_name.focus();
		fm.dp_name.value='';
		return false;
		}
	if(fm.dp_phone.value==''||!fm.dp_phone.value.isMobile()){
		alert("请填写正确的电话号码");
		fm.dp_phone.focus();
		fm.dp_phone.value='';
		return false;
		}
	if(fm.dp_add.value==''||fm.dp_add.value.length<3){
		alert("请填写您详细的收票地址\r市区免费送票");
		fm.dp_add.focus();
		fm.dp_add.value='';
		return false;
		}
		else{
			fm.submit();
			}
		}
		function hk(){
			var text="个人购票汇款账户：<br>全称：董景浩<br>开户行：交通银行洛阳市涧西支行<br>账号：6222600830000111680";
getid("tdd").innerHTML=text;
getid("hid").style.display="block";
			}
			function yh(){
			var text="团购：<br>一次购票10张(含10张)—29张，9.5折优惠<br>一次购票30张(含30张)—49张，9折优惠<br>一次购票50张以上(含50张)，8.5折优惠<br>";
getid("tdd").innerHTML=text;
getid("hid").style.display="block";
			}
			var i=0;
function addge(){
	
	song=getid("addge");
	inpge=document.form2.addgege.value;
	if(inpge.Trim()!=''){
		if(i<5){
		song.innerHTML+="<input type='checkbox' name='checkbox14232' value="+inpge.Trim()+" onClick='chk()'>"+inpge.Trim()+"  ";
		i++;
		}else{
			alert("你添加太多了");
			return false;
			}
		}else{
			return false;
			}
	}