<!--

// onload
function commonOnLoadFunction()
{
	MM_preloadImages(
		'images/menu_home_on.gif'   ,
		'images/menu_company_on.gif',
		'images/menu_column_on.gif' ,
		'images/menu_seminar_on.gif',
		'images/menu_product_on.gif',
		'images/menu_contact_on.gif'
	);
	setMenuImage();
//	setProductPulldown();
}

function getElement(id)
{
    if (document.all) return document.all[id];
    if (document.getElementById) return document.getElementById(id);
}

function setMenuImage()
{
	var obj_home    = getElement('nav_home'   );
	var obj_company = getElement('nav_company');
	var obj_column  = getElement('nav_column' );
	var obj_seminar = getElement('nav_seminar');
	var obj_product = getElement('nav_product');
	var obj_contact = getElement('nav_contact');

	url = document.location.href;
	if(url.indexOf("index.php") != -1) 		obj_home.src    = "images/menu_home_on.gif";
	if(url.indexOf("company.php") != -1) 		obj_company.src = "images/menu_company_on.gif";
	if(url.indexOf("column.php") != -1) 		obj_column.src  = "images/menu_column_on.gif";
	if(url.indexOf("seminar.php") != -1)		obj_seminar.src = "images/menu_seminar_on.gif";
	if(url.indexOf("product.php") != -1)		obj_product.src = "images/menu_product_on.gif";
	if(url.indexOf("contact.php") != -1)		obj_contact.src = "images/menu_contact_on.gif";
	if(url.indexOf("contact_thank.php") != -1)	obj_contact.src = "images/menu_contact_on.gif";
	if(url.indexOf("contact_error.php") != -1) 	obj_contact.src = "images/menu_contact_on.gif";
}



function setProductPulldown()
{
	url = document.location.href;

	if(url.indexOf("product_fire.php") != -1)
		document.product.company.selectedIndex = 2;
	if(url.indexOf("product_blag.php") != -1)
		document.product.company.selectedIndex = 3;
	if(url.indexOf("product_allrisk.php") != -1)
		document.product.company.selectedIndex = 4;
	if(url.indexOf("product_respon.php") != -1)
		document.product.company.selectedIndex = 5;
	if(url.indexOf("products_car.php") != -1)
		document.product.company.selectedIndex = 6;
	if(url.indexOf("product_goods.php") != -1)
		document.product.company.selectedIndex = 7;
	if(url.indexOf("product_expediency.php") != -1)
		document.product.company.selectedIndex = 8;
	if(url.indexOf("product_trust.php") != -1)
		document.product.company.selectedIndex = 9;
 
 	if(url.indexOf("products_mpf.php") != -1)
		document.product.staff.selectedIndex = 2;
 	if(url.indexOf("products_labor.php") != -1)
		document.product.staff.selectedIndex = 3;
 	if(url.indexOf("products_medical.php") != -1)
		document.product.staff.selectedIndex = 4;
 	if(url.indexOf("products_travelaccident.php") != -1)
		document.product.staff.selectedIndex = 5;
 	if(url.indexOf("products_grouplife.php") != -1)
		document.product.staff.selectedIndex = 6;
 	if(url.indexOf("products_houseing.php") != -1)
		document.product.staff.selectedIndex = 7;
 	if(url.indexOf("products_labordisaster.php") != -1)
		document.product.staff.selectedIndex = 8;
 	if(url.indexOf("products_golfer.php") != -1)
		document.product.staff.selectedIndex = 9;
}


function trim(string)
{	
	re = /^\s*(\S*)\s*$/;
	string = string.replace(re, "$1");
	return string;
}

function hasSpace(s)
{
	var checkOK = " ";
	var checkStr = s;
	var hasspace = false;
	for (i = 0;  i < checkStr.length;  i++)
	{
		ch = checkStr.charAt(i);
		if (ch == checkOK.charAt(0))
		{
			hasspace = true;
			i = checkStr.length;
		}
	}
	return hasspace;
}

function hasNumber(s)
{
	var checkOK = "0123456789";
	var checkStr = s;
	var hasNum = false;
	for (i = 0;  i < checkStr.length;  i++)
	{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
		{
			if (ch == checkOK.charAt(j))
			{
				hasNum = true;
				i = checkStr.length;
			}
		}
	}
	return hasNum;
}

function hasSpecialCharacters(s)
{
	var checkOK = '`~!@#$%^*+=|\\{[}]:;/?><"';
	var checkStr = s;
	var hasChar = false;
	for (i = 0;  i < checkStr.length;  i++)
	{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
		{
			if (ch == checkOK.charAt(j))
			{
				hasChar = true;
				i = checkStr.length;
			}
		}
	}
	return hasChar;
}

function validEmail(fieldobject, alertStr)
{
	if(fieldobject.value.indexOf("@") == -1 || fieldobject.value.indexOf(".") == -1)
	{
		alert(alertStr);
		fieldobject.focus();
		return false;
	}
	else
	{
		emailfields = fieldobject.value.split("@");
		username = trim(emailfields[0]);
		domainname = emailfields[1];
		if(username == "" || domainname == "" || domainname.indexOf(".") == -1)
		{
			alert(alertStr);
			fieldobject.focus();
			return false;
		}
		domainfields = domainname.split(".");
		domainpart1 = trim(domainfields[0]);
		domainpart2 = trim(domainfields[1]);
		if(domainpart1 == "" || domainpart2 == "")
		{
			alert(alertStr);
			fieldobject.focus();
			return false;
		}
		fieldobject.value = username + "@" + domainname;
		fieldobject.value = fieldobject.value.replace(/\s*/g,'');
	}

	return true;
}

function emptyTextField(fieldobject, alertStr)
{
	if (trim(fieldobject.value) == "")
	{
		alert(alertStr);
		fieldobject.value = "";
		fieldobject.focus();
		return true;
	}
	return false;
}

function hasAlpha(s)
{
	var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
	var checkStr = s;
	var hasAlp = false;
	for (i = 0;  i < checkStr.length;  i++)
	{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
		{
			if (ch == checkOK.charAt(j))
			{
				hasAlp = true;
				i = checkStr.length;
			}
		}
	}
	return hasAlp;
}

function validPhoneNumber(fieldobject, alertStr)
{
	if(!isNumeric(fieldobject.value))
	{
		alert(alertStr);
		fieldobject.focus();
		return false;
	}
	return true;
}

function isNumeric(s)
{
	// allow ONLY numeric keys, no symbols or punctuation
	// this can be altered for any "checkOK" string you desire
	var checkOK = "0123456789-";
	var checkStr = s;
	var allValid = true;
	for (i = 0;  i < checkStr.length;  i++)
	{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
			if (ch == checkOK.charAt(j))
				break;
		if (j == checkOK.length)
		{
			allValid = false;
			break;
		}
	}
	return allValid;
}

// product pulldown
function showProduct(type, index)
{
	href = eval("document.product." + type).options[index].value;

	if(href != "#")
		document.location = href;
}


// mm functions
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
   var this_pop = window.open(theURL,winName,features);
   this_pop.focus();
}

//-->
