function input_verify_contactus()
{	
	if (document.frmContactUs.txtName.value =='')
    	{
		alert("Harap isi Nama anda");
		document.frmContactUs.txtName.focus();
		return false;
	}
	else
	{
		var strCom = document.frmContactUs.txtName.value;
		if (strCom.length < 3)
		{
			alert('Nama Anda terlalu pendek');
			document.frmContactUs.txtName.focus();
			return false;
		}
		if (!checktags(strCom))
		{
			alert('Nama anda tidak boleh ada script/html tags nya');
			document.frmContactUs.txtName.focus();
			return false;
		}
	}	
	
	if ((document.frmContactUs.txtEmail.value =='')&&(document.frmContactUs.txtHP.value =='')&&(document.frmContactUs.txtPhone.value ==''))
    {		
		alert("Harap isi E-mail/HP/Phone anda");
		document.frmContactUs.txtEmail.focus();
		return false;
	}
	
		if (document.frmContactUs.txtEmail.value != "" && !checkemail(document.frmContactUs.txtEmail.value)){
 			alert("Email yang Anda masukkan tidak valid");
  			document.frmContactUs.txtEmail.focus();
  			return false;
 		}	
	
	if (!(document.frmContactUs.checkbox.checked)&&!(document.frmContactUs.checkbox2.checked)&&!(document.frmContactUs.checkbox3.checked))
	{
		alert("Anda belum memilih cara dihubungi");
		return false;
	}
	else 	
	{
		if (document.frmContactUs.checkbox.checked)
		{
			if (document.frmContactUs.txtEmail.value =='')
			{		
				alert('Checkbox yang dipilih tidak tepat');
				return false;
			}
		}
		if (document.frmContactUs.checkbox2.checked)
		{
			if (document.frmContactUs.txtHP.value =='')
			{		
				alert('Checkbox yang dipilih tidak tepat');
				return false;
			}
		}		
		if (document.frmContactUs.checkbox3.checked)
		{
			if (document.frmContactUs.txtPhone.value =='')
			{		
				alert('Checkbox yang dipilih tidak tepat');
				return false;
			}
		}
	}

	if (document.frmContactUs.txtName2.value!='' && document.frmContactUs.txtBidangUsaha.value=='')
	{
		alert("Anda mengisi Nama Perusahaan tanpa bidang usaha.Pastikan data bidang usaha juga dipilih!");
		document.frmContactUs.txtBidangUsaha.focus();
		return false;
	}

	
	if (document.frmContactUs.select.value=='')
	{
		alert("Anda belum memilih jenis pertanyaan");
		document.frmContactUs.select.focus();
		return false;
	}
	
	if (document.frmContactUs.txtComments.value=='')
	{
		alert("Harap isi Pertanyaan anda");
		document.frmContactUs.txtComments.focus();
		return false;
	}
	else
	{
		var strCom = document.frmContactUs.txtComments.value;
		if (strCom.length < 6) 
		{
			alert('Maaf, Pertanyaan Anda terlalu pendek!');
			document.frmContactUs.txtComments.focus();
			return false;		
		}
		if (!checktags(strCom))
		{
			alert('Komentar anda tidak boleh ada script/html tags nya');
			document.frmContactUs.txtComments.focus();
			return false;
		}
	}
	
	document.frmContactUs.action.value="addguestbook";
	document.frmContactUs.submit();
	return true;
}

// By Hengky I. (5/6/2004)
// validate Time format
function checkdate(intDay,intMonth,intYear) {
	var dtDate = new Date(intMonth + '/' + intDay + '/' + intYear )
    if (dtDate.getDate() != intDay && dtDate.getMonth() != intMonth-1) 
    	return false;
    else
    	return true;
}

// By Setiyo G. (16/7/2004)
// validate Time format
function checkTime(inputTime)
{
	var pos;
	pos=inputTime.indexOf(":");
	if (pos <= 0) {return false;}
	var intMinute=inputTime.substring(pos+1,inputTime.length);
	var intHour=inputTime.substring(0,pos);
	if (intMinute > 59 || intHour > 24)
		return false;
	else
		return true;
}

function textCounter(field, countfield, maxlimit)
{
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else 
countfield.value = maxlimit - field.value.length;
}

// By Setiyo G. (16/7/2004)
// Validate email entry
function checkemail(email) {
    if (email.length < 11 || email.indexOf("@")==-1 || email.indexOf(".")==-1 || email.indexOf("!")!=-1 || email.indexOf("..")!=-1 || email.indexOf(".")==0 || email.indexOf(".")==email.length|| email.indexOf("neowed")!=-1 || email.indexOf("menaravisi")!=-1 || email.indexOf("weddingku")!=-1 || email.indexOf("test")!=-1 || email.indexOf("hjkl")!=-1 || email.indexOf("yuio")!=-1 || email.indexOf("zxcv")!=-1 || email.indexOf("asdf")!=-1 || email.indexOf("qwer")!=-1)
		return false;
    else {
		var pos;
		pos = email.indexOf("@");
		var mailbox=email.substring(0,pos);
		var domainname=email.substring(pos+1,email.length);
		var mailboxlast=mailbox.substring(mailbox.length-1,mailbox.length);
		var domainfirst=domainname.substring(0,1);
		var lastdigit=email.substring(email.length-1,email.length);
		var firstdigit=email.substring(0,1)
		if (mailbox.indexOf("-")==-1 && domainname.indexOf("_")==-1 && domainname.indexOf("@")==-1 && lastdigit.indexOf(".")==-1 && lastdigit.indexOf("-")==-1 && firstdigit.indexOf(".")==-1 && firstdigit.indexOf("_")==-1 && mailboxlast.indexOf(".")==-1 && mailboxlast.indexOf("_")==-1 && domainfirst.indexOf(".")==-1 && domainfirst.indexOf("-")==-1)
			return true;
		else
			return false;
    }
}
/*
function checkemail(email) {
    var str =email;
    str = str.toLowerCase( );
    if (str.indexOf("@") > 1) {
        var addr = str.substring(0, str.indexOf("@"));
        var domain = str.substring(str.indexOf("@") + 1, str.length);
        if (domain.indexOf(".") == -1) {
           // alert("Verify the domain portion of the email address.");
            return false;
        }

        for (var i = 0; i < addr.length; i++) {
            oneChar = addr.charAt(i).charCodeAt(0);
            if ((i == 0 && (oneChar == 45 || oneChar == 46))  || 
                (i == addr.length - 1 && oneChar == 46)) {
               // alert("Verify the user name portion of the email address.");
                return false;
            }
			
            if (oneChar == 45 || oneChar == 46 || oneChar == 95 || 
                (oneChar > 47 && oneChar < 58) || (oneChar > 96 && oneChar < 123)) {
                continue;
            } else {
                //alert("Verify the user name portion of the email address.");
                return false;
            }
        }
        for (i = 0; i < domain.length; i++) {
            oneChar = domain.charAt(i).charCodeAt(0);
            if ((i == 0 && (oneChar == 45 || oneChar == 46)) || 
                ((i == domain.length - 1  || i == domain.length - 2) && oneChar == 46)) {
                //alert("Verify the domain portion of the email address.");
                return false;
            }
            if (oneChar == 45 || oneChar == 46 || oneChar == 95 || 
                (oneChar > 47 && oneChar < 58) || (oneChar > 96 && oneChar < 123)) {
                continue;
            } else {
                //alert("Verify the domain portion of the email address.");
                return false;
            }
        }
        return true;
    }
    //alert("The email address may not be formatted correctly. Please verify.");
    return false;
}
*/
// By Setiyo G. (29/7/2004)
// Fill In text field with current Time
function fillTime(timefield) {
	var dtDate = new Date
    	var strTime

 	strTime=dtDate.getHours()
 	strTime=strTime + ':'
 	strTime=strTime + dtDate.getMinutes()
// strTime=strTime + ':' 
// strTime=strTime + dtDate.getSeconds()
 
	timefield.value = strTime
}

// By Setiyo G. (7/9/2004)
// validate phone entry, no repetition more than maxrep
function checkphone(strphone,maxrep)
{
    var i = 0;
    var j = 0;
    var repdigit = new Array(14);
    var digit= new Array(14);
    var repcnt=0;

    if (strphone.indexOf("12345")!=-1 || strphone.indexOf("00000")!=-1 || strphone.indexOf("11111")!=-1 || strphone.indexOf("22222")!=-1 || strphone.indexOf("33333")!=-1 || strphone.indexOf("44444")!=-1 || strphone.indexOf("55555")!=-1 || strphone.indexOf("66666")!=-1 || strphone.indexOf("77777")!=-1 || strphone.indexOf("88888")!=-1 || strphone.indexOf("99999")!=-1)
		return false;
    else {
	
    for (i = 0; i < strphone.length; i++) {
        repdigit[i] = 0;
	digit[i] = 0;
    }
    for (i = 0; i < strphone.length; i++) {
	digit[i]=strphone.substring(i,i+1);
    	for (j = 0; j <= i; j++) {
	    if (digit[j]==digit[i]) {
		repdigit[j]=repdigit[j]+1;
	    }
        }
    }
    for (i = 0; i < strphone.length; i++) {
	if (repdigit[i]>=maxrep) {
		repcnt=repcnt+1;
	}
    }
    if (repcnt>0)
		return false;
	else
		return true;   
    }
}

// By Setiyo G. (1/12/2005)
// Validate Script/HTML Tags
function checktags(chkstr) {
		if (chkstr.indexOf("i>")==-1 && chkstr.indexOf("b>")==-1 && chkstr.indexOf("p>")==-1 && chkstr.indexOf("h1>")==-1 && chkstr.indexOf("h2>")==-1 && chkstr.indexOf("h3>")==-1 && chkstr.indexOf("h4>")==-1 && chkstr.indexOf("h5>")==-1 && chkstr.indexOf("h6>")==-1 && chkstr.indexOf("body>")==-1 && chkstr.indexOf("html>")==-1 && chkstr.indexOf("br>")==-1 && chkstr.indexOf("hr>")==-1 && chkstr.indexOf("font>")==-1 && chkstr.indexOf("'")==-1 && chkstr.indexOf("script>")==-1 && chkstr.indexOf("-->>")==-1 && chkstr.indexOf("<!--")==-1 && chkstr.indexOf("form>")==-1 && chkstr.indexOf("div>")==-1 && chkstr.indexOf("u>")==-1 && chkstr.indexOf("ol>")==-1 && chkstr.indexOf("ul>")==-1 && chkstr.indexOf("select>")==-1 && chkstr.indexOf("<input")==-1 && chkstr.indexOf("location.href")==-1 && chkstr.indexOf("response.redirect")==-1 && chkstr.indexOf("<%")==-1 && chkstr.indexOf("%>")==-1)
		{
			return true;
		}
		else
		{
			return false;
		}

}
function cekKeyEnter(evt,sFunc){
	evt = (evt) ? evt : event;
	var target = (evt.target) ? evt.target : evt.srcElement;
	var form = target.form;
	var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : ((evt.which) ? evt.which : 0));
	if(charCode==13){
		eval(sFunc);
		return false;
	}
}
//add trim function to String object
String.prototype.trim = function()
{
  return( this.replace(/^\s*([\s\S]*\S+)\s*$|^\s*$/,'$1') );   
}

function input_verify_discount()
{	
	if (document.getElementById("FreeListingTxtName").value =='')
   {
		alert("Merchant harus diisi");
		document.getElementById("FreeListingTxtName").focus();
		return false;
	}
   if (document.getElementById("BrandName").value =='' && document.getElementById("CategoryName").value =='')
   {
		alert("Brand atau Kategori harus diisi");
      document.getElementById("BrandName").focus();
		return false;
	}
      
   if (document.getElementById("DiscountTitle").value =='')
   {
		alert("Judul harus diisi");
		document.getElementById("DiscountTitle").focus();
		return false;
	}
   if (document.getElementById("DiscountDescription").value =='')
   {
		alert("Deskripsi tidak boleh kosong");
		document.getElementById("DiscountDescription").focus();
		return false;
	}
   if (document.getElementById("txtdate").value =='')
   {
		alert("Start date harus diisi");
		document.getElementById("txtdate").focus();
		return false;
	}
   if (document.getElementById("txtdate2").value =='')
   {
		alert("End date harus diisi");
		document.getElementById("txtdate2").focus();
		return false;
	}
   document.frmDiscount.submit();
	return true;
}