
tUrl = document.location
var StrtUrl = new String(tUrl)
var winObject = null;
var checkall_value = 0;

function form_search() 
{ 
	if (document.form1.searchstr.value == "")
	{    		
		alert(txtSelect2);   		
		document.form1.searchstr.focus();	
		return false;	
	} 
	document.form1.submit();                       
}  


function chkall()
{	

	for(i = 0; i < document.PageForm.elements.length; ++i) {
		
		if(document.PageForm.elements[i].name == 'chksong')
		document.PageForm.elements[i].checked = true;

        } 

} 

// vod.asp
function chkall_p()
{	

	for(i = 0; i < parent.down.document.PageForm.elements.length; ++i) {
		
		if(parent.down.document.PageForm.elements[i].name == 'chksong')
		parent.down.document.PageForm.elements[i].checked = true;

        } 

} 


function chkall_sermon()
{	

	for(i = 0; i < document.PageForm.elements.length; ++i) {
		
		if(document.PageForm.elements[i].name == 'chksermon')
		if (checkall_value == 0) {
		    document.PageForm.elements[i].checked = true;
		} else {
		    document.PageForm.elements[i].checked = false;
		}

        } 
	
	if (checkall_value == 0) {
	    checkall_value = 1;	
	} else {
	    checkall_value = 0;
	}
	
} 

function chkall_song()
{	

	for(i = 0; i < document.PageForm.elements.length; ++i) {
		
		if(document.PageForm.elements[i].name == 'chksong')
		if (checkall_value == 0) {
		    document.PageForm.elements[i].checked = true;
		} else {
		    document.PageForm.elements[i].checked = false;
		}

        } 
	
	if (checkall_value == 0) {
	    checkall_value = 1;	
	} else {
	    checkall_value = 0;
	}
	
} 

function chkall_song2()
{	

	for(i = 0; i < document.PageForm2.elements.length; ++i) {
		
		if(document.PageForm2.elements[i].name == 'chksong') {

			if (document.PageForm2.chkitem.checked) {
				document.PageForm2.elements[i].checked = true;
			} else {
				document.PageForm2.elements[i].checked = false;
			}		

        	} 
	
	}

	if (document.PageForm2.chkitem.checked) {
    		checkall_value = 1;	
	} else {
    		checkall_value = 0;
	}
} 


function chkall_sermon2()
{	

	for(i = 0; i < document.PageForm2.elements.length; ++i) {

		if(document.PageForm2.elements[i].name == 'chksermon') {

			if (document.PageForm2.chkitem.checked) {
				document.PageForm2.elements[i].checked = true;
			} else {
				document.PageForm2.elements[i].checked = false;
			}		

        	} 	

        } 
	
	if (document.PageForm2.chkitem.checked) {
    		checkall_value = 1;	
	} else {
    		checkall_value = 0;
	}
	
} 

// ÀüÃ¼¼±ÅÃ (¹Ìµð¾îÃ¢) *********************************
function chkall_sermon3()
{	

	for(i = 0; i < document.PageForm.elements.length; ++i) {
		
		if(document.PageForm.elements[i].name == 'chksermon')
		    document.PageForm.elements[i].checked = true;


        } 

	
} 

function chkall_sermon4()
{	

	for(i = 0; i < document.PageForm2.elements.length; ++i) {
		
		if(document.PageForm2.elements[i].name == 'chksermon')
		    document.PageForm2.elements[i].checked = true;


        } 

	
} 

function chkall_song3()
{	

	for(i = 0; i < document.PageForm.elements.length; ++i) {
		
		if(document.PageForm.elements[i].name == 'chksong')
		    document.PageForm.elements[i].checked = true;
	
	}
	
} 

function chkall_song4()
{	

	for(i = 0; i < document.PageForm2.elements.length; ++i) {
		
		if(document.PageForm2.elements[i].name == 'chksong')
		    document.PageForm2.elements[i].checked = true;
	
	}
	
} 
//-ÀüÃ¼¼±ÅÃ (¹Ìµð¾îÃ¢) *********************************


function rand(intStart, intEnd) {

	return parseInt(Math.random() * (intEnd - intStart)) + parseInt(intStart);
	
}



function chkrandom()
{	
	
	chkall_none();
	for(i = 0; i < document.PageForm.elements.length; ++i) {
		
		if(document.PageForm.elements[i].name == 'chksong') {
		
			irand = rand(1,3)
			if (irand==1) {
				document.PageForm.elements[i].checked = true;
			}
		
		}

        } 

} 

// vod.asp
function chkrandom_p()
{	
	
	chkall_none_p();
	for(i = 0; i < parent.down.document.PageForm.elements.length; ++i) {

		if(parent.down.document.PageForm.elements[i].name == 'chksong') {
		
			irand = rand(1,3)
			if (irand==1) {
				parent.down.document.PageForm.elements[i].checked = true;
			}
		
		}

        } 

} 


function playcheck(tempVal,tempFlag) 
{
	
	chkall_none();
	
	var iLoop = 0;
	
	for(i = 0; i < document.PageForm.elements.length; ++i) {
	
		if(document.PageForm.elements[i].name == 'chksong') {
		    
		    if (iLoop==tempVal) {
		        document.PageForm.elements[i].checked = true;
		    }
		    iLoop=iLoop+1;
		}

	}
	
	play(5);

}	


function chkall_none()
{	

	for(i = 0; i < document.PageForm.elements.length; ++i) {
		
		if(document.PageForm.elements[i].name == 'chksong')
		document.PageForm.elements[i].checked = false;
		
        } 
} 


function chkall_none_p()
{	

	for(i = 0; i < parent.down.document.PageForm.elements.length; ++i) {
		
		if(parent.down.document.PageForm.elements[i].name == 'chksong')
		parent.down.document.PageForm.elements[i].checked = false;
		
        } 
} 


function chkall_sermon_none()
{	
	
	for(i = 0; i < document.PageForm.elements.length; ++i) {
		
		if(document.PageForm.elements[i].name == 'chksermon')
		document.PageForm.elements[i].checked = false;
		
		if(document.PageForm.elements[i].name == 'chk_all') {
			document.PageForm.elements[i].checked = false;
			if (checkall_value == 0) {
			    checkall_value = 1;	
			} else {
			    checkall_value = 0;
			}		
		}
		
        } 
} 

function chkall_sermon_none2()
{	

	for(i = 0; i < document.PageForm2.elements.length; ++i) {
		
		if(document.PageForm2.elements[i].name == 'chksermon')
		document.PageForm2.elements[i].checked = false;
		
        } 
} 


function chkall_song_none2()
{	

	for(i = 0; i < document.PageForm2.elements.length; ++i) {
		
		if(document.PageForm2.elements[i].name == 'chksong')
		document.PageForm2.elements[i].checked = false;
		
        } 
} 



function play_songs(tmp) 
{

	var songlist = ""
	var chk = false
	var PrevCheck = ""; //¹Ì¸® Ã¼Å©µÇ¾îÀÖ´Â Ç×¸ñ
	
	if (tmp == 6) {

		for(i = 0; i < parent.down.document.PageForm.elements.length; ++i) {
		var chksong=parent.down.document.PageForm.elements[i]            
		   if(chksong.name == 'chksong') {
			   if(chksong.checked == true) {
				   chk = true;
				   songlist = songlist + chksong.value + ",";
			   }
		   }
		}

	} else {
		
		for(i = 0; i < document.PageForm.elements.length; ++i) {
		var chksong=document.PageForm.elements[i]            
		   if(chksong.name == 'chksong') {
			   if(chksong.checked == true) {
				   chk = true;
				   songlist = songlist + chksong.value + ",";
			   }
		   }
		}
		
	}
	

	if(chk == true ) {

		if (tmp==6) { //"¼±ÅÃµè±â" 

			winObject = window.open('','fms','left=0,top=0,width=1024,height=700,status=no,scrollbars=no,resizable=no');
			parent.down.document.PageForm.target='fms';
			parent.down.document.PageForm.action='/KO/Media/Viewer/fms.asp?PlayType=wmv';
			
			if ( parent.getCookie("win_open") == 'open' ) {
				parent.down.document.PageForm.PrevCheck.value = winObject.document.all.chksong.value;
			}
			
			parent.down.document.PageForm.submit();
			
		} else if (tmp==7) {

			var obj = document.PageForm;

			var target_play_type = obj.PlayType.value;

			parent.sizeCtrl_tot('wmv');
			parent.resize0(320);
			var target = "top.ifr_tp";  //ÀÓÀÇ·Î Á¤ÇØÁØ´Ù.
			parent.name = target;  //ºÎ¸ðÀÌ¸§Àº target ÀÓÀ» ¼±¾ðÇÏ°í
			obj.target = "ifr_tp";  //ÇöÀç ÀÚ½ÄÃ¢ ÆûÀÇ Å¸°ÙÀº, ¼±¾ðÇÑ ºÎ¸ðÃ¢ ÀÓÀ» ¾Ë·ÁÁØ´Ù.
			document.PageForm.target='ifr_tp';
			obj.action='/KO/Media/Viewer/vod_player.asp?PlayType=wmv';
			
			document.PageForm.submit();
				
		}
		
		

	}
	else {

	        alert("ÇÑ°³ÀÌ»óÀº ¼±ÅÃÇØÁÖ¼¼¿ä.");	
	        
	}


}

function play_songs_en(tmp) 
{
	
	var songlist = ""
	var chk = false
	
	if (tmp == 6) {

		for(i = 0; i < parent.down.document.PageForm.elements.length; ++i) {
		var chksong=parent.down.document.PageForm.elements[i]            
		   if(chksong.name == 'chksong') {
			   if(chksong.checked == true) {
				   chk = true;
				   songlist = songlist + chksong.value + ",";
			   }
		   }
		}

	} else {
		
		for(i = 0; i < document.PageForm.elements.length; ++i) {
		var chksong=document.PageForm.elements[i]            
		   if(chksong.name == 'chksong') {
			   if(chksong.checked == true) {
				   chk = true;
				   songlist = songlist + chksong.value + ",";
			   }
		   }
		}
		
	}
	

	if(chk == true ) {

		if (tmp==6) { //"¼±ÅÃµè±â" 

			winObject = window.open('','mediaVOD','left=0,top=0,width=320,height=313,status=no,scrollbars=no,resizable=no');
			document.PageForm.target='mediaVOD';
			document.PageForm.action='/EN/Media/VodFile.asp?PlayType=CHKSONG';
			document.PageForm.submit();
			
		} 
		

	}
	else {

	        alert("Please check!");	
	        
	}


}

function play_songs2(tmp) 
{

	var songlist = ""
	var chk = false
       
	for(i = 0; i < document.PageForm2.elements.length; ++i) {
	var chksong=document.PageForm2.elements[i]            
	   if(chksong.name == 'chksong') {
		   if(chksong.checked == true) {
			   chk = true;
			   songlist = songlist + chksong.value + ",";
		   }
	   }
	}
	
	if(chk == true ) { 
		
		if (tmp==6) {

			window.open('','fms','left=0,top=0,width=1024,height=700,status=no,scrollbars=no,resizable=no');
			document.PageForm2.target='fms';
			
			if(tmp == 6) {
				document.PageForm2.action='/KO/Media/Viewer/fms.asp?PlayType=wmv';
				
			}
			document.PageForm2.submit();

		} 

	}
	else {

	        alert("ÇÑ°³ÀÌ»óÀº ¼±ÅÃÇØÁÖ¼¼¿ä.");	
	        
	}
	

}


function play_sermons(tmp) 
{

	var songlist = ""
	var chk = false
       
	for(i = 0; i < document.PageForm.elements.length; ++i) {
	var chksong=document.PageForm.elements[i]            
	   if(chksong.name == 'chksermon') {
		   if(chksong.checked == true) {
			   chk = true;
			   songlist = songlist + chksong.value + ",";
		   }
	   }
	}
	
	if(chk == true ) { 
		
		if (tmp==6) {

			winObject = window.open('','fms','left=0,top=0,width=1024,height=700,status=no,scrollbars=no,resizable=no');
			document.PageForm.target='fms';
			document.PageForm.action='/KO/Media/Viewer/fms.asp?PlayType=wmv';

			if ( getCookie("win_open") == 'open' ) {
				document.PageForm.PrevCheck.value = winObject.document.all.chksermon.value;
			}

		} else if (tmp==7) { // media Ã¢ ÀüÃ¼µè±â

			var obj = document.PageForm;
			
			var target_play_type = obj.PlayType.value;

			parent.sizeCtrl_tot('wmv');
			parent.resize0(320);
			var target = "top.ifr_tp";  //ÀÓÀÇ·Î Á¤ÇØÁØ´Ù.
			parent.name = target;  //ºÎ¸ðÀÌ¸§Àº target ÀÓÀ» ¼±¾ðÇÏ°í
			obj.target = "ifr_tp";  //ÇöÀç ÀÚ½ÄÃ¢ ÆûÀÇ Å¸°ÙÀº, ¼±¾ðÇÑ ºÎ¸ðÃ¢ ÀÓÀ» ¾Ë·ÁÁØ´Ù.
			document.PageForm.target='ifr_tp';
			obj.action='/KO/Media/Viewer/vod_player.asp?PlayType=wmv';
			
		}
		
		document.PageForm.submit();

	}
	else {

	        alert("ÇÑ°³ÀÌ»óÀº ¼±ÅÃÇØÁÖ¼¼¿ä.");	
	        
	}
	

}


function play_sermons2(tmp) 
{

	var songlist = ""
	var chk = false
       
	for(i = 0; i < document.PageForm2.elements.length; ++i) {
	var chksong=document.PageForm2.elements[i]            
	   if(chksong.name == 'chksermon') {
		   if(chksong.checked == true) {
			   chk = true;
			   songlist = songlist + chksong.value + ",";
		   }
	   }
	}
	
	if(chk == true ) { 
		
		if (tmp==6) {

			window.open('','fms','left=0,top=0,width=1024,height=700,status=no,scrollbars=no,resizable=no');
			document.PageForm2.target='fms';
			
			if(tmp == 6) {
				document.PageForm2.action='/KO/Media/Viewer/fms.asp?PlayType=wmv';
				
			}
			document.PageForm2.submit();

		} 

	}
	else {

	        alert("ÇÑ°³ÀÌ»óÀº ¼±ÅÃÇØÁÖ¼¼¿ä.");	
	        
	}
	

}



function save_sermon(tmp) 
{

	var sermonlist = ""
	var chk = false
       
	for(i = 0; i < document.PageForm.elements.length; ++i) {
	var chksermon=document.PageForm.elements[i]            
	   if(chksermon.name == 'chksermon') {
		   if(chksermon.checked == true) {
			   chk = true;
			   sermonlist = sermonlist + chksermon.value + ",";
		   }
	   }
	}
	
	if(chk == true ) { 
		
		var win_sermon = window.open('','saveSermon', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=385,height=400');
		document.PageForm.target='saveSermon';
		
		if(tmp == 6) {
			document.PageForm.action='../../Media/saveMyList.asp';
		}

		document.PageForm.submit();
		
		win_sermon.focus();

	}
	else {

	        alert("¼³±³¸¦ ¼±ÅÃÇØÁÖ¼¼¿ä.");	
	        
	}
	

}


function save_media_sermon(tmp_filenum)
{

	var win_sermon = window.open('../../Media/saveMyList.asp?c_type=CHKSERMON&chksermon='+tmp_filenum,'saveSermon', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=385,height=400');
	win_sermon.focus();
	
}


function save_song(tmp) 
{

	var songlist = ""
	var chk = false
       
	for(i = 0; i < document.PageForm.elements.length; ++i) {
	var chksong=document.PageForm.elements[i]            
	   if(chksong.name == 'chksong') {
		   if(chksong.checked == true) {
			   chk = true;
			   songlist = songlist + chksong.value + ",";
		   }
	   }
	}
	
	if(chk == true ) { 
		
		var win_song = window.open('','saveSong', 'left=0,top=0,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=385,height=530');
		document.PageForm.target='saveSong';
		
		if(tmp == 6) {
			document.PageForm.action='../../Media/saveMyList.asp';
		}

		document.PageForm.submit();
		
		win_song.focus();

	}
	else {

	        alert("Ç×¸ñÀ» ¼±ÅÃÇØÁÖ¼¼¿ä.");	
	        
	}
	

}


function save_song_p(tmp) 
{

	var songlist = ""
	var chk = false
       
	for(i = 0; i < parent.down.document.PageForm.elements.length; ++i) {
	var chksong=parent.down.document.PageForm.elements[i]            
	   if(chksong.name == 'chksong') {
		   if(chksong.checked == true) {
			   chk = true;
			   songlist = songlist + chksong.value + ",";
		   }
	   }
	}
	
	if(chk == true ) { 
		
		var win_song = window.open('','saveSong', 'left=0,top=0,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=385,height=520');
		parent.down.document.PageForm.target='saveSong';
		
		if(tmp == 6) {
			parent.down.document.PageForm.action='../../Media/saveMyList.asp';
		}

		parent.down.document.PageForm.submit();
		
		win_song.focus();

	}
	else {

	        alert("Ç×¸ñÀ» ¼±ÅÃÇØÁÖ¼¼¿ä.");	
	        
	}
	

}


function remove_item(tmp_gubun) {
	
	var itemlist = ""
	var chk = false
	var total_itemcnt = 0;
	var status = 0;
	var del_itemcnt = 0;
	
	if (tmp_gubun == 'CHKSERMON') {
	
			for(i = 0; i < document.PageForm.elements.length; ++i)
			{
				if(document.PageForm.elements[i].name == 'chksermon')
				{
					if(document.PageForm.elements[i].checked == true) // »èÁ¦ÇÒ Ç×¸ñ
					{
						status = 1;
						del_itemcnt = del_itemcnt + 1;
						
					} else { // »èÁ¦¾ÈÇÒ Ç×¸ñÀ» ÀúÀå
						itemlist = itemlist + document.PageForm.elements[i].value + ",";
						
					}
					total_itemcnt = total_itemcnt + 1;
				}
		    	}
		       
		
	} else {
	
			for(i = 0; i < document.PageForm.elements.length; ++i)
			{
				if(document.PageForm.elements[i].name == 'chksong')
				{
					if(document.PageForm.elements[i].checked == true) // »èÁ¦ÇÒ Ç×¸ñ
					{
						status = 1;
						del_itemcnt = del_itemcnt + 1;
						
					} else { // »èÁ¦¾ÈÇÒ Ç×¸ñÀ» ÀúÀå
						itemlist = itemlist + document.PageForm.elements[i].value + ",";
						
					}
					total_itemcnt = total_itemcnt + 1;
				}
		    	}
		       
	}
	
	
    	if(status)
	{
		
		//if(confirm("»èÁ¦ÇÏ½Ã°Ú½À´Ï±î?"))
		//{
			if (total_itemcnt == 1) {
				alert("¸ñ·ÏÀÌ ÇÑ°³¹Û¿¡ ¾øÀ»¶§´Â »èÁ¦¸¦ ÇÒ ¼ö ¾ø½À´Ï´Ù.");
			} else if (total_itemcnt == del_itemcnt) {
			        alert("ÀüÃ¼Ç×¸ñÀ» »èÁ¦ ÇÒ ¼ö ¾ø½À´Ï´Ù.");
			} else {
				document.PageForm.total_check_num.value = itemlist;
				document.PageForm.action="juke_del.asp";
	        		document.PageForm.submit();
        		}
        	//}
        	
    	} else {
		alert("¸ñ·ÏÀ» ¼±ÅÃÇØ ÁÖ¼¼¿ä!");  
	}	
	
}


function check_item(c_type,item_seq,t_filenum) {
	
	var nCnt = 0
	var PrevCheck = "";
	//var winObject = null;
	
	//document.PageForm.target='fms';
	//document.PageForm.action='/KO/Media/Viewer/fms.asp?PlayType=wmv';


	if ( parent.getCookie("win_open") == 'open' ) {
		winObject = window.open('','fms','left=0,top=0,width=753,height=645,status=no,scrollbars=no,resizable=no');
		PrevCheck = winObject.document.all.chksong.value;
	}

	winObject = window.open('/KO/Media/Viewer/fms.asp?c_type=CHKSONG&PlayType=wmv&chksong=' + t_filenum + '&PrevCheck='+PrevCheck,'fms','left=0,top=0,width=753,height=645,status=no,scrollbars=no,resizable=no');
	winObject.focus();
	
}

function check_item_low(c_type,item_seq,t_filenum,speed) {
	var nCnt = 0
	var PrevCheck = "";
	//var winObject = null;
	
	//document.PageForm.target='fms';
	//document.PageForm.action='/KO/Media/Viewer/fms.asp?PlayType=wmv';


	if ( parent.getCookie("win_open") == 'open' ) {
		winObject = window.open('','fms','left=0,top=0,width=753,height=645,status=no,scrollbars=no,resizable=no');
		PrevCheck = winObject.document.all.chksong.value;
	}

	winObject = window.open('/KO/Media/Viewer/fms.asp?c_type=CHKSONG&PlayType=wmv&chksong=' + t_filenum + '&PrevCheck='+PrevCheck + "&speed=2",'fms','left=0,top=0,width=753,height=645,status=no,scrollbars=no,resizable=no');
	winObject.focus();
	
}

function manage_mylist(tmp,t_gubun,t_width,t_height)
{
	var win_m = window.open('/KO/Media/manageMyList.asp?arg1='+tmp+'&c_type='+t_gubun,'manage','left=0,top=0,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width='+t_width+',height='+t_height);
	win_m.focus();
}

function manage_mylist_song(tmp,t_gubun,t_width,t_height,t_seq)
{
	var win_m = window.open('/KO/Media/manageMyList.asp?arg1='+tmp+'&c_type='+t_gubun+'&cat_seq='+t_seq,'manage','left=0,top=0,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width='+t_width+',height='+t_height);
	win_m.focus();
}


function play(tmp) 
{

	var songlist = ""
	var chk = false
       
	for(i = 0; i < document.PageForm.elements.length; ++i) {
	var chksong=document.PageForm.elements[i]            
	   if(chksong.name == 'chksong') {
		   if(chksong.checked == true) {
			   chk = true;
			   songlist = songlist + chksong.value + ",";
		   }
	   }
	}
	if(chk == true ) { 
		document.PageForm.target = 'frame_viewer';
		
		if(tmp == 6)
		{document.PageForm.action='../C1/JB_playerV5/JB_player.asp';}
		else if(tmp == 'P')
		{document.PageForm.action='../C1/JB_playerV5_P/JB_player.asp';}
		else if(tmp == 5)
		{document.PageForm.action='../_Common/vod_viewer.asp';}
		else { }
		document.PageForm.submit();
	}
	else {
	   alert("°îÀ» ¼±ÅÃÇØ ÁÖ¼¼¿ä!");	
	}

}



