﻿ 
  function NewWindow(mypage, myname, w, h, scrolla) {  
	
			 var winl = (screen.availWidth - w) / 2;
 			 var wint = (screen.availHeight - h) / 2;
			 winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scrolla+',resizable=0,toolbar=no,statusbar=no'
			 win = window.open(mypage, myname, winprops)
	} // NewWindow

	 
	function rank_tab(idx,from,to1) { 
			for( i=from ; i <= to1; i++ ) {  
					tmp1 = document.getElementById('showDetails'+i).style;
					 
						if( i == idx && tmp1.display == 'none') {
						tmp1.display = 'block'; 
					} else if(tmp1.display == 'block'){
						tmp1.display = 'none';
					}
				} 
				
		}
		 										
	function view_next_prev(stop1, idx){																
			 var s = stop1 ;  
		     for( i = 0 ; i < s ; i++ ) { 
		  	  	  tmp = document.getElementById('view_tab'+i).style;  
				  
				  if( i == idx ) { 
					  tmp.display = 'block';
				  }
				  else {
						tmp.display = 'none';
				 }
		     } // for
	} // function view_next_prev1
	
	var n1 = 0 
	var n2 = 0 
	
	function next(stop1){
		     var temp = stop1 - 1 ;  
			 if(n1 < temp ){
							  n1 ++ ; 
							  n2 ++ ;
							  view_next_prev(stop1, n1) ;
			 }
	} // next 
																														
	function prev(stop1){
		     var temp = stop1 - 1 ;
			 if(n2 > 0){
					    n2 -- ;
					    n1 -- ;
						view_next_prev(stop1, n2);
		     }			
	} // prev
																			
	// Play media																		
	function playIt(){
						if ((navigator.userAgent.indexOf('IE') > -1) && (navigator.platform == "Win32")) {
							try { MediaPlayer1.Play(); } catch(exception) {  }
						}
	}
	function pauseIt(){
						if ((navigator.userAgent.indexOf('IE') > -1) && (navigator.platform == "Win32")) {			
									try { MediaPlayer1.Pause(); } catch(exception) {}
						} 
	}
	function stopIt(){
						if ((navigator.userAgent.indexOf('IE') > -1) && (navigator.platform == "Win32")) {
									try { MediaPlayer1.Stop(); } catch(exception) { }
									try {MediaPlayer1.CurrentPosition=0; } catch(exception) {  }
						} 
	}	

    function fullIt()
	{
		MediaPlayer1.DisplaySize = 3;
		//hmplayer.Play();
	}
	
	function media_view(med_no,w,h,a) { 
	
	 var med_no;
	 var med_HTML ="";
	 med_flag = med_no;
	  
	med_HTML += ' <object id="MediaPlayer1" name="MediaPlayer1" width='+w+' height='+h+' classid="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,05,0809" standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject" VIEWASTEXT>  ';
	med_HTML += ' <param name="transparentAtStart" value="True">  ';
	med_HTML += ' <param name="transparentAtStop" value="True">  ';
	med_HTML += ' <param name="AnimationAtStart" value="False">   ';
	med_HTML += ' <param name="AutoStart" value="'+a+'">   ';
	med_HTML += ' <param name="AutoRewind" value="false">   ';
	med_HTML += ' <param name="DisplaySize" value="0">    ';
	med_HTML += ' <param name="PlayCount" value="999">    ';
	med_HTML += ' <param name="AutoSize" value="false">   ';
	med_HTML += ' <param name="ShowDisplay" value="false">   ';
	med_HTML += ' <param name="ShowStatusBar" value="false">    ';
	med_HTML += ' <param name="ShowControls" value="false">   ';
	med_HTML += ' <param name="EnableContextMenu" value="False">    ';
    med_HTML += ' <param name="FileName" value="'+med_flag+'">    ';
	med_HTML += ' <param name="Volume" value="0">   ';	 
	med_HTML += ' <param name="bgcolor" value="#000000">';
	med_HTML += ' <embed src="'+med_flag+'" autosize=0 autostart=1 type=application/x-mplayer2 showcontrols=0 showstatusbar=0 autorewind=1 showdisplay=0 width='+w+' height='+h+'></embed></object>   ';
	 
	document.write(med_HTML);
	}
 
function gotopage(p) 
			{  
			document.frm1.curpg.value = p ;
			document.frm1.submit();
			}
 function get_value_idcate(){ 
		   document.frm2.submit();
    } 
// --------- Tạo 1 combo  lay gia tri tu 1 combo khac D  ----------- 

   function cleardroplist3(OptionList) {
            OptionList.length = 1;
	}

	function loaddroplist3(Index1,sub_select1,selected_value1,NameArray1,ValueArray1) {
	
	  if (Index1 > 0){	
	  
	    var CurrentName1 = NameArray1[Index1-1].split('||');
		
		var CurrentValue1 = ValueArray1[Index1-1].split('||');
		for (var i1=0; i1<CurrentName1.length; i1++){
			
			sub_select1.options[i1+1] = new Option(CurrentName1[i1], CurrentValue1[i1], false, false);
		 if(CurrentValue1[i1] == selected_value1) {  sub_select1.options[i1+1].selected = true;  }
		 
     	} //for
	} //if
   }
 	function updatedroplist3(main_select1,sub_select1,selected_value1,NameArray1,ValueArray1) {  
		var CurrSub1 = sub_select1.selectedIndex;
		
		    cleardroplist3(sub_select1);
			loaddroplist3(main_select1.selectedIndex,sub_select1,selected_value1,NameArray1,ValueArray1);
					
   }
	 
 
 // canh bao xoa mot lan nhieu mau tin 
 function question_del(){
	         if(confirm('Bạn có chắc là muốn xoá không ?')) return true ;
			 else                                           return false ;
	
 }

 // Nhac nho phuc hoi mau tin 
 function question_res(){
	         if(confirm('Bạn có chắc là muốn phục hồi không ?')) return true  ;
			 else                                          	     return false ;
	
 }
 
 function caculatorchon()
		{
		 var strchon="";
		 var j=0;
		 var alen=document.frm1.elements.length;
		 alen=(alen>=5)?document.frm1.chkid.length:0;
		 if(alen>0)
		   {
			 for(var i=0;i<alen;i++)
				   if(document.frm1.chkid[i].checked==true)
					{
						  j++;
						  if(j==1)
						   strchon+=document.frm1.chkid[i].value;
						  else
							{
						  strchon+=",";
						  strchon+=document.frm1.chkid[i].value;
							}
						  }
		   }
		 else
		   {
			 if(document.frm1.chkid.checked==true)
					 strchon=document.frm1.chkid.value;
		   }
		  document.frm1.chon.value=strchon; 
		}
		
		function checkinput()
		{
		 var alen=document.frm1.elements.length;
		 var ischecked=false;
		 alen=(alen>=5)?document.frm1.chkid.length:0;
		 if(alen>0){		   
			 for(var i=0;i<alen;i++)
				   if (document.frm1.chkid[i].checked==true)
					   ischecked=true;					   
		   }
		 else {
			 if(document.frm1.chkid.checked==true)
					  ischecked=true;
		 }
		if (!ischecked)
		   alert("Chọn ít nhất 1 tin cần thao tác !");
		else{
		    
			 caculatorchon(); 
		     if(!question_del()) return false ;
			 
		}
 
		return ischecked;
		}
		
		function docheckone(){		
			  var ischecked=true;
			  var alen=document.frm1.elements.length;			
			  alen=(alen>=5)?document.frm1.chkid.length:0;
			  
			  if(alen>0){
				  
				  for(var i=0;i<alen;i++)
					if(document.frm1.chkid[i].checked==false)
					   ischecked=false;
			  }
			  else{
				  
				  if(document.frm1.chkid.checked==false)
					 ischecked=false;
			  }
			  document.frm1.chkall.checked=ischecked;
}
		 
	   function docheck(status,from)
				{  
				  var alen=document.frm1.elements.length;
				  alen=(alen>=5)?document.frm1.chkid.length:0;
				  if(alen>0)
					{
						  for(var i=0;i<alen;i++)
							document.frm1.chkid[i].checked=status;
						}
				else
					{
						 document.frm1.chkid.checked=status;
						}
				if (from>0)
				   document.frm1.chkid.checked=status;
				}
				
	 
 <!-- Begin view when upload image
/*
Created by: Abraham Joffe :: http://www.abrahamjoffe.com.au/ */
/***** CUSTOMIZE THESE VARIABLES *****/
  // width to resize large images to
    
	//var maxWidth=60;
	  // height to resize large images to
	//var maxHeight=60;
	  // valid file types
	var fileTypes=["bmp","BMP","gif","GIF","png","PNG","jpg","JPG","jpeg","JPEG","emf","EMF"];
	  // the id of the preview image tag
	//var outImage="previewimage";
	//var outImage=id;
	  // what to display when the image is not valid
	var defaultPic="spacer.gif";
	/***** DO NOT EDIT BELOW *****/
	function preview(what,id,w,h){
	  var source=what.value; 
	  var ext=source.substring(source.lastIndexOf(".")+1,source.length).toLowerCase();
	  for (var i=0; i<fileTypes.length; i++) if (fileTypes[i]==ext) break;
	  globalPic=new Image();
	  if (i<fileTypes.length) globalPic.src=source;
	  else {
		//globalPic.src=defaultPic;
		//alert("File này không là file hình. Bạn hãy chọn lại:\n\n"+fileTypes.join(", "));
		return false ;
	  }
	  setTimeout("applyChanges('"+id+"','"+w+"','"+h+"')",200);
	}
	var globalPic;
	function applyChanges(id,w,h){ 
	  var maxWidth  = w ;
	  var maxHeight = h ;
	  var outImage=id;  
	  var field=document.getElementById(outImage);
	 // var field=document.getElementById(id);
	  var x=parseInt(globalPic.width);
	  var y=parseInt(globalPic.height);
	  if (x>maxWidth) {
		y*=maxWidth/x;
		x=maxWidth;
	  }
	  if (y>maxHeight) {
		x*=maxHeight/y;
		y=maxHeight;
	  }
	  field.style.display=(x<1 || y<1)?"none":"";
	  field.src=globalPic.src;
	  field.width=x;
	  field.height=y;
	}
	
 function view_image(img,id,w,h){	
	      preview(img,id,w,h) ;
 } // view_image
 
    // Cac ham chuyen mau khi re chuot
    var ns6=document.getElementById&&!document.all
	var ie=document.all
	var highlightbehavior="TR"
	
	
	function changeto(e,highlightcolor){
	source=ie? event.srcElement : e.target
	if (source.tagName=="TABLE")
	return
	while(source.tagName!=highlightbehavior && source.tagName!="HTML")
	source=ns6? source.parentNode : source.parentElement
	if (source.style.backgroundColor!=highlightcolor&&source.id!="ignore")
	source.style.backgroundColor=highlightcolor
	}
	
	function contains_ns6(master, slave) { //check if slave is contained by master
	while (slave.parentNode)
	if ((slave = slave.parentNode) == master)
	return true;
	return false;
	}
	
	function changeback(e,originalcolor){
	if (ie&&(event.fromElement.contains(event.toElement)||source.contains(event.toElement)||source.id=="ignore")||source.tagName=="TABLE")
	return
	else if (ns6&&(contains_ns6(source, e.relatedTarget)||source.id=="ignore"))
	return
	if (ie&&event.toElement!=source||ns6&&e.relatedTarget!=source)
	source.style.backgroundColor=originalcolor
	}