// JavaScript Document
/************************************************************/
/***** 	Project 	  : CHF Media    	 		                *****/
/***** 	File Name 	: ajax_process 			                *****/
/***** 	Writtent by : Nguyen Duc Manh           	      *****/
/***** 	Email 		  : ducmanh11hn@gmail.com  	          *****/
/***** 	Y!M 		    : ducmanh11hn 			                *****/
/***** 	Skype 		  : ducmanh11hn 			                *****/
/***** 	Date		    : 05/12/2007 			                  *****/
/************************************************************/

function guihoidap(){
   if ( document.hoidap.email.value == "" ) {
	 alert( "Hãy nhập email của bạn vào!" );		
	 document.hoidap.email.focus();
   } else if (( document.hoidap.email.value.search("@") == -1 ) || ( document.hoidap.email.value.search("[.*]" ) == -1 )){
	 alert( "Địa chỉ Email không hợp lệ" );	
	 document.hoidap.email.focus();
   } else if ( document.hoidap.cauhoi.value == "" ) {
	 alert( "Hãy nhập câu hỏi của bạn vào!" );		
	 document.hoidap.cauhoi.focus();
   } else {
	     var email = encodeURIComponent(document.getElementById("email").value);
	     var cauhoi = encodeURIComponent(document.getElementById("cauhoi").value);
	     var code = encodeURIComponent(document.getElementById("code").value);
	     var param = "email="+email+"&cauhoi="+cauhoi+"&code="+code;
 	     window.location.href='index.php?mod=hoidap&submit=1&'+param;	    
    }
    return false;
}
function guigopy(){
   if ( document.gopy.email.value == "" ) {
	 alert( "Hãy nhập email của bạn vào!" );		
	 document.gopy.email.focus();
   } else if (( document.gopy.email.value.search("@") == -1 ) || ( document.gopy.email.value.search("[.*]" ) == -1 )){
	 alert( "Địa chỉ Email không hợp lệ" );	
	 document.gopy.email.focus();
   } else if ( document.gopy.gycont.value == "" ) {
	 alert( "Hãy nhập câu hỏi của bạn vào!" );		
	 document.gopy.gycont.focus();
   } else {
	     var email = encodeURIComponent(document.getElementById("email").value);
	     var gycont = encodeURIComponent(document.getElementById("gycont").value);
	     var code = encodeURIComponent(document.getElementById("code").value);
	     var param = "email="+email+"&gycont="+gycont+"&code="+code;
 	     window.location.href='index.php?mod=gopyduthaovanban&submit=1&'+param;	    
    }
    return false;
}
function lienhe(){
    if ( document.contact.fullname.value == "" ) {
	 alert( "Hãy nhập tên của bạn vào!" );
	 document.contact.fullname.focus();
    } else if ( document.contact.email.value == "" ) {
	 alert( "Hãy nhập email của bạn vào!" );		
	 document.contact.email.focus();
    } else if (( document.contact.email.value.search("@") == -1 ) || ( document.contact.email.value.search("[.*]" ) == -1 )){
	 alert( "Địa chỉ Email không hợp lệ" );	
	 document.contact.email.focus();
    } else if ( document.contact.subject.value == "" ) {
	 alert( "Hãy nhập tiêu đề vào!" );		
	 document.contact.subject.focus();
    } else if ( document.contact.content.value == "" ) {
	 alert( "Hãy nhập nội dung vào!" );		
	 document.contact.content.focus();
    } else if (document.contact.code.value == "" ){
	 alert( "Hãy nhập mã xác nhận vào!" );	
	 document.contact.code.focus();
    } else {
    	 var fullname = encodeURIComponent(document.getElementById("fullname").value);
	     var email = encodeURIComponent(document.getElementById("email").value);
	     var phone = encodeURIComponent(document.getElementById("phone").value);
	     var subject = encodeURIComponent(document.getElementById("subject").value);
	     var content = encodeURIComponent(document.getElementById("content").value);
	     var code = encodeURIComponent(document.getElementById("code").value);
	     var param = "fullname="+fullname+"&email="+email+"&phone="+phone+"&subject="+subject+"&content="+content+"&code="+code;
 	     window.location.href='index.php?mod=lienhe&submit=1&'+param;
	    
    }
    return false;
}
/****************  Tim kiem *****************/

function search(){  
	 var tv = document.getElementById("tv").checked;
	 var tt = document.getElementById("tt").checked;
	 var kwd = document.getElementById("kwd").value;
	 if(tv==true) tinvien = 1;
	 if(tt==true) tinvien = 0;
	 if (kwd=="" || kwd.length<3){
	     alert('Từ khóa tìm kiếm phải lớn hơn 3 ký tự!');
	 } else {	
	     kwd = kwd.replace(/&/g,'%26');
	     kwd = kwd.replace(/"/g,'%22');	     	     
 	     window.location.href='./index.php?mod=timkiem&submit=1&tv='+tinvien+'&kwd='+kwd;     
	 }
}

sfHover = function() {
	if (document.getElementById("suckerfish2")) {
		var sfEls = document.getElementById("suckerfish2").getElementsByTagName("LI");
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className+=" sfhover";
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			}
		}
		
		/* keeps parent element highlighted when mouseover on a child UL. only works for single-level */	
		var sfUls = document.getElementById("suckerfish2").getElementsByTagName("UL");
		for (var i=0; i<sfUls.length; i++) {
			if ( sfUls[i].id != 'suckerfish2' ) {
				sfUls[i].onmouseover=function() {
					this.parentNode.className += " childhover";
				}
				sfUls[i].onmouseout=function() {
					this.parentNode.className = this.parentNode.className.replace(/ childhover/g, '');
				}
			}
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
function writeTime(s) {
    var mydate = new Date(s)

    var year = mydate.getYear()
    if (year < 1000)
        year += 1900
    var month = mydate.getMonth() + 1
    if (month < 10)
        month = "0" + month
    var day = mydate.getDate()
    if (day < 10)
        day = "0" + day

    var dayw = mydate.getDay()

    var hour = mydate.getHours()
    if (hour < 10)
        hour = "0" + hour

    var minute = mydate.getMinutes()
    if (minute < 10)
        minute = "0" + minute
        
    var dayarray = new Array("Ch&#7911; Nh&#7853;t", "Th&#7913; Hai", "Th&#7913; Ba", "Th&#7913; T&#432;", "Th&#7913; N&#259;m", "Th&#7913; S&#225;u", "Th&#7913; B&#7843;y")
    document.write(dayarray[dayw] + ", " + day + "/" + month + "/" + year + ",&nbsp;" + hour + ":" + minute + " (GMT+7)")
}
