//alert("ddd");
//var testMsg = "i am here ";

function getFlashHtmlstr(){
	 htmlstr = '<embed style="position:relative;top:0px;" src="' + flashurl + '" wmode=' + wmode +
' quality="high" FlashVars="pics='+pics
	+'&links='+links
	+'&texts='+texts+
	'&pic_width='+pic_width+
	'&pic_height='+pic_height+
	'&show_text='+show_text+
	'&txtcolor='+txtcolor+
	'&bgcolor='+bgcolor+
	'&button_pos='+button_pos+
	'&stop_time='+stop_time+
	'" quality="high" width="'+ pic_width +
	'" height="'+ swf_height +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>';
	//alert(htmlstr);
	
}



function prevPage(){
	if(isFirst()){
		goToLast();
	}else{
		currentPage = currentPage - 1;
		displayCurrentPage();
	}
}

function nextPage(){
	if(isLast()){
		goToFirst();
	}else{
		currentPage = currentPage + 1;
		displayCurrentPage();
	}
	
}

function displayCurrentPage(){	
	//alert("currentPage = " + currentPage);
	setAllDivHidden();
	$(aryMenuDiv[currentPage]).style.display="";
}
function goToLast(){
			
			currentPage = totalPage-1;
			displayCurrentPage();
			
}

function goToFirst(){
			
			currentPage = 0;
			displayCurrentPage();
}
function setAllDivHidden(){
	aryMenuDiv.each(
					function(aryVaue){
						$(aryVaue).style.display="none";
					}
		    )
}
function isLast(){
		if(currentPage == (totalPage-1)){
			return true;
		}else{
			return false;
		}
}
function isFirst(){
		if(currentPage == 0){
			return true;
		}else{
			return false;
		}
}

function   loadImg(theImgSrc,theDisplayDivId,theTitleDivId,theTitle){   
	var re = /\{0\}/g;    
	  
	//alert("ddd");
  //var   objImg   =   document.createElement("img")     
  //objImg.src=theImgSrc;  
  //${imgswitch}.appendChild(objImg) 
  var imgtag = '<img   src="{0}" class="guanggao" border="0"/>';
  
 // alert("replace = " + imgtag.replace(re,theImgSrc));
  $(theDisplayDivId).innerHTML   =   imgtag.replace(re,theImgSrc);  
  //$(theTitleDivId).innerHTML = theTitle;
  
  }



function allSel(){
 
  if(checkboxId.length==null){
     		
}else{
//
  for(var i=0;i<checkboxId.length;i++){
   		if(checkboxId[i].checked==true){
			//checkboxId[i].checked=false;
		}else if(checkboxId[i].checked==false){
                  checkboxId[i].checked=true;
                  }
	}
        }
		processCheckbox();
		
		
  }
function processCheckbox(str,strjiaolian){
	
	//aForm.action.value=str;
	var str2="";
	var str3=0;
	var ischecknum = 0;
	if(checkboxId.length==null){
		
	}else{
		for(var i=0;i<checkboxId.length;i++){
		if(checkboxId[i].checked==true){
		   ischecknum =  ischecknum + 1;
		 }
	}
	 var inii = -1;
   
	  for(var i=0;i<checkboxId.length;i++){
		if(checkboxId[i].checked==true){
		 inii = inii + 1;
		  if(inii != (ischecknum - 1)){
		  	
		    tempstr = checkboxId[i].value;
		  	str2=str2 + tempstr +',';
			str3=str3+1;
		  }else{
		     tempstr = checkboxId[i].value;
		  	str2=str2 + tempstr ;
			str3=str3+1;
		  }

		}
	  }
	}
	ids.value = str2;
	if(str2!=""){
	 	
	}

}


function reverseSel(){
 
  if(checkboxId.length==null){
     		
}else{
//
  for(var i=0;i<checkboxId.length;i++){
   		if(checkboxId[i].checked==true){
			checkboxId[i].checked=false;
		}else if(checkboxId[i].checked==false){
                  checkboxId[i].checked=true;
                  }
	}
        }
		processCheckbox();
		
		
  }

function switchMenu2(table,span){


	
	
	
		$("iq_div").style.display="none";
	$("eq_div").style.display="none";
	$("pq_div").style.display="none";
	$("zhunmama_div").style.display="none";
	
	
	
	
	$("iq").className="iq_bg_unhover";
	$("eq").className="eq_bg_unhover";
	$("pq").className="pq_bg_unhover";
	$("zhunmama").className="zhunmama_bg_unhover";

	if(table == 'iq_div'){
		
		$("iq").className="iq_bg_hover";
		 //$("iq_div").style.display="";
		

	}
	if(table == 'eq_div'){
		$("eq").className="eq_bg_hover";
		//$("eq_div").style.display="";
		
	}
	if(table == 'pq_div'){
		$("pq").className="pq_bg_hover";

		
	}
	if(table == 'zhunmama_div'){
		$("zhunmama").className="zhunmama_bg_hover";

		
	}
	
	
	//alert("span classname = " + $(span).className);
	$(table).style.display="";
	

	
	
	
	//$(span).className="tab_hover2";
	
	
}

 



function switchMenu(table,span){

	aryMenuDiv.each(
		function(aryVaue){
			$(aryVaue + "_div").style.display="none";
		}
	)

		aryMenuDiv.each(
		function(aryVaue){
			$(aryVaue).className=aryVaue + "_bg_unhover";
		}
	)
	
	aryMenuDiv.each(
		function(aryVaue){
			if(table == (aryVaue + "_div")){
				$(aryVaue).className=aryVaue + "_bg_hover";
			}
		}
	)

	
	//alert("span classname = " + $(span).className);
	$(table).style.display="";
	

	//$(span).className="tab_hover2";
	
	
}



function switchLink(thelinkid){
	
	aryMenuDiv.each(
		function(aryVaue){
			$(aryVaue + "_link").style.display="none";
		}
	)
	
	$(thelinkid).style.display="";
	

}





/*
player

*/


function playerReady(thePlayer) {
	player = window.document[thePlayer.id];
	
	//addListeners();
}
function wait(){
	
	//tryNnum = tryNnum -1;
	if(player){
		//alert("ddd");
		
	}else{
		setTimeout("wait()",1000);
	}
}


        function createPlayer(theFile,theAutoStart,theWidth,theHeight) {
            var flashvars = {
                    file:theFile, 
                    autostart:theAutoStart, 
                    controlbar:"none",
                    playlist:"none" ,
					bufferlength:"5"
            }
            var params = {
                    allowfullscreen:"true", 
                    allowscriptaccess:"always"
            }
            var attributes = {
                    id:"player1",  
                    name:"player1"
            }
            swfobject.embedSWF("../../javascript/player.swf", "placeholder1", theWidth, theHeight, "9.0.115", false, flashvars, params, attributes);
        }
		
 function createPlayerPreviewImg(theFile,theAutoStart,thePreviewImg,theWidth,theHeight) {
	 
            var flashvars = {
                    file:theFile, 
                    autostart:theAutoStart, 
                    controlbar:"none",
                    playlist:"none" ,
					image:thePreviewImg,
					bufferlength:"5"
            }
            var params = {
                    allowfullscreen:"true", 
                    allowscriptaccess:"always"
            }
            var attributes = {
                    id:"player1",  
                    name:"player1"
            }
            swfobject.embedSWF("../../javascript/player.swf", "placeholder1", theWidth, theHeight, "9.0.115", false, flashvars, params, attributes);
        }
		
		
		
		
		
		function createPlayer2(theFile,theAutoStart,theWidth,theHeight) {
		var flashvars = {
						file:theFile, 
						autostart:theAutoStart, 
						bufferlength:"3"
				}

	var params = {
		allowfullscreen:"false", 
		allowscriptaccess:"always"
	}

	var attributes = {
		id:"player1",  
		name:"player1"
	}

	 swfobject.embedSWF("../../javascript/player.swf", "placeholder1", theWidth, theHeight, "9.0.115", false, flashvars, params, attributes);
}

function createPlayer3(theFile,theAutoStart,theWidth,theHeight) {
		var flashvars = {
						file:theFile, 
						autostart:theAutoStart, 
						bufferlength:"5",
						 playlistsize:"170",
                   		 playlist:"bottom",
						 repeat:"always"
				}

	var params = {
		 wmode:"opaque", 
		allowfullscreen:"false", 
		allowscriptaccess:"always"
	}

	var attributes = {
		id:"player2",  
		name:"player2"
	}

	 swfobject.embedSWF("../../javascript/player.swf", "placeholder2", theWidth, theHeight, "9.0.115", false, flashvars, params, attributes);
}

function createPlayer4(theFile,theAutoStart,theWidth,theHeight) {
		var flashvars = {
						file:theFile, 
						autostart:theAutoStart, 
						bufferlength:"5"
						
				}

	var params = {
		wmode:"transparent", 
		allowfullscreen:"false", 
		allowscriptaccess:"always"
	}

	var attributes = {
		id:"player1",  
		name:"player1"
	}

	 swfobject.embedSWF("../../javascript/player.swf", "placeholder1", theWidth, theHeight, "9.0.115", false, flashvars, params, attributes);
}

function deletePlayer(theWrapper, thePlaceholder, thePlayerId) { 
        //swfobject.removeSWF(thePlayerId);
        var tmp=document.getElementById(theWrapper);
        if (tmp) { 
			tmp.innerHTML = "<div id=" + thePlaceholder + "></div>"; 
		}
}

function playmp3(theFile) { 
        deletePlayer('wrapper', 'placeholder1', 'player1'); 
        //createPlayer('placeholder1', 'player1', theFile);createPlayer2('',false,'250','19');//playmp3 
		createPlayer2(theFile,true,'250','19');
}

function playvideo(theFile) { 
        player.sendEvent('STOP');
		player.sendEvent('LOAD',theFile);
		player.sendEvent('PLAY');
}

function  showlist(theHeight) { 
			document.getElementById("wrapper2").style.height=theHeight+"px";
 }
 
 function playonemp3(theChecjboxid){
	  player.sendEvent('STOP');
	   showlist(19);
	 for(var i=0;i<checkboxId.length;i++){
   		if(checkboxId[i].checked==true){
			checkboxId[i].checked=false;
		}
	}
	 
	 $(theChecjboxid).checked=true;
	
	 playmp3lst();
 }



function playmp3lst() { 
	//alert("ddd");
	//createPlayer3('',false,'250','190','170');//playlistsize 170
	
	//alert("aaa");
	if (currentPlaylist) { 
		var j = 0; 
		//var k = 0;
		var lst = new Array();
		
		//alert(currentPlaylist.length);
		for( k = 0;k < currentPlaylist.length;k++){
			//alert("checkboxId obj " + $('checkboxId' + k));
			//alert("currentPlaylist[i].file " + currentPlaylist[i].file);
			if(document.getElementById('checkboxId' + k).checked) {
				//alert("currentPlaylist[i].file " + currentPlaylist[k].file);
				//alert("i = " + k);
				lst[j] = {
					
					file:currentPlaylist[k].file,
					title:currentPlaylist[k].title,
					type:currentPlaylist[k].type,
					//image:currentPlaylist[k].image,
					description:currentPlaylist[k].description
				}
				j++;
				//k++;
			}
		}
		if(lst.length > 0) { 
		//alert("play");
		if(player){
			player.sendEvent('LOAD', lst); 
			player.sendEvent('PLAY');
			//showlist(190);	
			if(lst.length > 1){
				showlist(190);	
			}
			
			
		}else{
			alert("init player error");
		}
		}else{
			alert("player list length = 0");
		}
	}else{
		alert("no currentPlaylist");
	}
	//alert("checkboxId obj " + $("checkboxId" + 0));
}
