var nav2_menu=0; //main page menu - 1, inner page - 0

function swapImage(imageID, currStatus, nextStatus)
{
	var imageObj = document.getElementById(imageID);
	
	if (!imageObj)
		return
	
	var imagePathHead = imageObj.src.substring(0, imageObj.src.indexOf(currStatus+'.'));
	var imagePathTail = imageObj.src.substring(imageObj.src.indexOf(currStatus+'.')+currStatus.length, imageObj.src.length);
	
	imageObj.src = imagePathHead + nextStatus + imagePathTail;
}

function lib_bwcheck()
{	//Browsercheck (needed)
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent
	this.dom=document.getElementById?1:0
	this.opera=this.agent.indexOf("Opera")>-1
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera)?1:0;
	this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera)?1:0;
	this.ie4=(document.all && !this.dom && !this.opera)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6
	this.mac=this.agent.indexOf("Mac")>-1
	//this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0;
	this.ns6=(this.agent.indexOf("Netscape")>-1 && this.dom && !this.opera)?1:0;
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)
	return this
}
var bw=new lib_bwcheck()

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_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 checkEmail(this_formFieldName, this_fieldName)
{
	var errorMsg = "";
	var fieldValue = this_formFieldName.value;
  	
  	var supported = false;
  	var wrongInput = true;
  	
  	if (window.RegExp) {
		var tempStr = "a";
		var tempReg = new RegExp(tempStr);
		if (tempReg.test(tempStr))
			supported = true;
	}

	if (!supported) {
		if(fieldValue.indexOf(".") > 2 && s.indexOf("@") > 0) 
			wrongInput = false;
	}

	var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)")
	var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$")
	if ((!r1.test(fieldValue) && r2.test(fieldValue)))
		wrongInput = false;
	
  	if(wrongInput)
		errorMsg += '\t- ( ' + this_fieldName + ' ) contains invalid character, spaces Or incomplete. \n';
	
	return errorMsg;
}

function checkValid(this_formFieldName, this_fieldName, this_stringType)
{
	var fieldValue = this_formFieldName.value.toUpperCase();
	var fieldLength = fieldValue.toString().length;
	var errorMsg = "";
	var validString = "";
	
	if (this_stringType == "name") {
		validString = "ABCDEFGHIJKLMNOPQRSTUVWXYZ ";
	}
	else if (this_stringType == "number") {
		validString = "0123456789";
	}	
	else if (this_stringType == "phone_number") {
		validString = "0123456789()- ";
	}

	for (i=0; i<fieldLength; i++)
	{
		if (validString.indexOf(fieldValue.charAt(i))==-1 )
		{	
			errorMsg += '\t- ( ' + this_fieldName + ' ) contains invalid character. \n';
			return errorMsg;
		}
	}
	return errorMsg;
}

function checkDate(selected_dd, selected_mm, selected_yy)
{
	var errorDate = false;
	
	if ((selected_yy%4==0) && (selected_mm == 2))
	{
		if (selected_dd > 29)
			errorDate = true;
	}
	else if ((selected_yy%4>0) && (selected_mm == 2))
	{
		if (selected_dd > 28)
			errorDate = true;
	}
	else if ((selected_mm == 4) || (selected_mm == 6) || (selected_mm == 9) || (selected_mm == 11))
	{
		if (selected_dd > 30)
			errorDate = true;
	}
	return errorDate;
}

// added by Denon
var o;
var warningMsgHeading = "Warning:\n========\n\n";
var errMsgHeading = "Error:\n========\n\n";
var curPopupWindow = null;
var errStoredValue = "";
var errHasEmployee = false;
var browser = 'IE4';
if (document.layers) 
	browser = 'NS4';
	

// Open the popup window without scrollbar.
function openPopup(urlStr, width, height) {
	var iMyWidth;
	var iMyHeight;

	closePopup();
	iMyWidth = (top.window.screen.width / 2) - ((width/2) + 10); //half the screen width minus half the new window width (plus 5 pixel borders).
	iMyHeight = (top.window.screen.height / 2) - ((height/2) + 50); //half the screen height minus half the new window height (plus title and status bars).
	curPopupWindow = window.open(urlStr, "PopUp", "width=" + width + ",height=" + height + ",toolbar=no,status=no,directories=no,menubar=no,resizable=no,screenX=" + iMyWidth  + ",left=" + iMyWidth + "screenY=" + iMyHeight + ",top=" + iMyHeight, true);
	curPopupWindow.focus();
}

// Open the popup window with scrollbar.
function openScrollPopup(urlStr, width, height) {
	var iMyWidth; 
	var iMyHeight;

	closePopup();
	iMyWidth = (top.window.screen.width / 2) - ((width/2) + 10); //half the screen width minus half the new window width (plus 5 pixel borders).
	iMyHeight = (top.window.screen.height / 2) - ((height/2) + 50); //half the screen height minus half the new window height (plus title and status bars). 
	curPopupWindow = window.open(urlStr, "PopUp", "width=" + width + ",height=" + height + ",toolbar=no,status=no,directories=no,menubar=no,resizable=no,scrollbars=yes,screenX=" + iMyWidth	+ ",left=" + iMyWidth + "screenY=" + iMyHeight + ",top=" + iMyHeight, true);
	curPopupWindow.focus();
}

// Close the current popup window.
function closePopup()
{
	if (curPopupWindow != null) {
		if (!curPopupWindow.closed) {
			curPopupWindow.close();
		}
		curPopupWindow = null;
	}
}

