// JavaScript Document
function hide_div(){
	t = setTimeout('hidediv()', 200);
}
function hidediv() { 
	if (document.getElementById) 
	{ // DOM3 = IE5, NS6 
		document.getElementById('hideshow').style.visibility = 'hidden'; 
	} 
	else 
	{ 
		if (document.layers) 
		{ // Netscape 4 
			document.hideshow.visibility = 'hidden'; 
		} 
		else 
		{ // IE 4 
			document.all.hideshow.style.visibility = 'hidden'; 
		} 
	} 
}
function showdiv() { 
	if (document.getElementById) 
		{ // DOM3 = IE5, NS6 
			document.getElementById('hideshow').style.visibility = 'visible'; 
		} 
	else 
		{	if (document.layers) 
			{ // Netscape 4 
				document.hideshow.visibility = 'visible'; 
			} 
			else 
			{ // IE 4 
				document.all.hideshow.style.visibility = 'visible'; 
			} 
		} 
	//timedHeight();
}
function hide_div2(){
	t2 = setTimeout('hidediv2()', 200);
}
function hidediv2() { 
	if (document.getElementById) 
	{ // DOM3 = IE5, NS6 
		document.getElementById('hideshow2').style.visibility = 'hidden'; 
	} 
	else 
	{ 
		if (document.layers) 
		{ // Netscape 4 
			document.hideshow2.visibility = 'hidden'; 
		} 
		else 
		{ // IE 4 
			document.all.hideshow2.style.visibility = 'hidden'; 
		} 
	} 
}
function showdiv2() { 
	if (document.getElementById) 
		{ // DOM3 = IE5, NS6 
			document.getElementById('hideshow2').style.visibility = 'visible'; 
		} 
	else 
		{	if (document.layers) 
			{ // Netscape 4 
				document.hideshow2.visibility = 'visible'; 
			} 
			else 
			{ // IE 4 
				document.all.hideshow2.style.visibility = 'visible'; 
			} 
		} 
	//timedHeight();
}
function hide_div3(){
	t3 = setTimeout('hidediv3()', 200);
}
function hidediv3() { 
	if (document.getElementById) 
	{ // DOM3 = IE5, NS6 
		document.getElementById('hideshow3').style.visibility = 'hidden'; 
	} 
	else 
	{ 
		if (document.layers) 
		{ // Netscape 4 
			document.hideshow3.visibility = 'hidden'; 
		} 
		else 
		{ // IE 4 
			document.all.hideshow3.style.visibility = 'hidden'; 
		} 
	} 
}
function showdiv3() { 
	if (document.getElementById) 
		{ // DOM3 = IE5, NS6 
			document.getElementById('hideshow3').style.visibility = 'visible'; 
		} 
	else 
		{	if (document.layers) 
			{ // Netscape 4 
				document.hideshow3.visibility = 'visible'; 
			} 
			else 
			{ // IE 4 
				document.all.hideshow3.style.visibility = 'visible'; 
			} 
		} 
	//timedHeight();
}



function checking_remove(element_id, def_value)
{
	if(!document.getElementById(element_id).value || document.getElementById(element_id).value == def_value)
	{
		document.getElementById(element_id).value = "";
	}
}


function checking_fill(element_id,fieldtext)
{
	if(document.getElementById(element_id).value=="")
	{
		document.getElementById(element_id).value = fieldtext;
	}
}


function Mandatory(myfield,errmsg,errname){
	if (myfield.value.length == 0 || myfield.value == "" || myfield.value == "0"){
		document.getElementById(errname).innerHTML=errmsg;
		myfield.focus();
		return false;
	}
document.getElementById(errname).innerHTML="";	
return true;
}
function MandatoryRadio(myfield,errmsg,errname){
	var field = GetRadioValue(myfield);
	if (field.length == 0 || field == "" || field == "0"){
		document.getElementById(errname).innerHTML=errmsg;
		return false;
	}
document.getElementById(errname).innerHTML="";	
return true;

}
function CheckNumber(checkStr,errmsg,errname){
var allValid = true;
var string = checkStr.value;
string = delete_min(string);
string = delete_space(string);

if(isNaN(string)){
	allValid = false;
	document.getElementById(errname).innerHTML=errmsg;
	checkStr.focus();
	checkStr.select();
}
return allValid;
}
function CharacterFilter1(checkOK,checkStr,errmsg,errname){
var allValid = true;
var flag = checkStr.value.indexOf(checkOK);
if(flag==-1)
{	allValid = false;
	document.getElementById(errname).innerHTML=errmsg;
	checkStr.focus();
	checkStr.select();
}
return allValid;
}
function CheckMandatory(myfield,errmsg,comparation){
	if (myfield.value.length == 0 || myfield.value == "" || myfield.value == "0" || myfield.value == comparation){
		alert(errmsg);
		myfield.focus();
		return false;
	}
return true;
}
function CheckCheckNumber(checkStr,errmsg){
var allValid = true;
var string = checkStr.value;
string = delete_min(string);
string = delete_space(string);

if(isNaN(string)){
	allValid = false;
	alert(errmsg);
	checkStr.focus();
	checkStr.select();
}
return allValid;
}
function CheckCharacterFilter1(checkOK,checkStr,errmsg){
var allValid = true;
var flag = checkStr.value.indexOf(checkOK);
if(flag==-1)
{	allValid = false;
	alert(errmsg);
	checkStr.focus();
	checkStr.select();
}
return allValid;
}




function GetRadioValue(radioObj) {
	if(!radioObj)
		return false;
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return false;
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return false;
}

function delete_min(string)
{
		for(var i=0;1;i++)
		{
			var char=string.indexOf("-");
			if(char>0)
				{
					string = string.replace("-","");
				}
			else if(char<0)
				{
					break;
				}
		}
	
	return string;
}

function delete_space(string)
{
		for(var i=0;1;i++)
		{
			var char=string.indexOf(" ");
			if(char>0)
				{
					string = string.replace(" ","");
				}
			else if(char<0)
				{
					break;
				}
		}
		return string;
}
//untuk ambil value dari url parameter, var value = gup('paramname');
function gup(name)
{
	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS = "[\\?&]"+name+"=([^&#]*)";
	var regex = new RegExp( regexS );
	var results = regex.exec( window.location.href );
	if( results == null )
		return "";
	else
		return results[1];
}

function FillVerification(value,id,focused)
{
	if(value=="hja82hls2j")
	{
		var value = "Invalid Verification Code";	
		document.getElementById(id).innerHTML=value;
		document.getElementById(focused).focus();
	}
}

function validateForm(formName)
{
	if (!CheckMandatory(formName.first_name,"Please Input Your FIRST NAME","First Name")){
	return false;
	}
	if (!CheckMandatory(formName.last_name,"Please Input Your LAST NAME","Last Name")){
	return false;
	}
	if (!CheckMandatory(formName.email,"Please Input Your EMAIL","Email")){
	return false;
	}
	if (!CheckMandatory(formName.phone,"Please Input Your PHONE","Phone")){
	return false;
	}
	if (!CheckCharacterFilter1('@',formName.email,"Please input VALID EMAIL")){
	return false;
	}
	if (!CheckCharacterFilter1('.',formName.email,"Please input VALID EMAIL")){
	return false;
	}
	if (!CheckCheckNumber(formName.phone,"Please input A VALID NUMBER")){
	return false;
	}
	return true;
	
}
