//KVersionID=1
//KProgramID=514
var K_ProgramID;
d=window.document;
var myWinOpen = eval("win" + "dow.o" + "pen");
function EmbedParmInString(p_St,p_P1,p_P2,p_P3){
s=p_St;r=/%1/g;s=s.replace(r,p_P1);r=/%2/g;s=s.replace(r,p_P2);r=/%3/g;return(s.replace(r,p_P3));}

function Trim(p_s){
	fi=0;la=p_s.value.length-1;
	while(fi<p_s.value.length&&p_s.value.charAt(fi)==" "){
		fi++
	};
	if(fi<p_s.value.length){
		while(la>0&&p_s.value.charAt(la)==" "){
			la--;
		};
		p_s.value=p_s.value.substr(fi,((la-fi)+1));
	} else 
		p_s.value="";
	return p_s;
}

String.prototype.trim = function(){
	return this.replace(/^\s*/,"").replace(/\s*$/,"");
}

function DisplayPopupMessage(f){if(f.Popup_Message){if(f.Popup_Message.value)alert(f.Popup_Message.value)}}
//==== same as in navigation.js
//function OpenPopupWindow(p_name,p_URL,p_w,p_h,p_x,p_y){
//x=50;y=50;popupwin=myWinOpen(p_URL,p_name,"scrollbars=yes,width="+x+",height="+y+",screenX="+p_x+",left="+p_x+",screenY="+p_y+",top="+p_y+",status=yes,menubar=no,resizable");
//popupwin.focus();if(p_w>650)if(window.screen.width>820){if (p_h>=K_MainPopupHeight768){p_w=K_MainPopupWidth1024;p_h=K_MainPopupHeight768;}
//}else{if (p_h>=K_MainPopupHeight600){p_w=K_MainPopupWidth800;p_h=K_MainPopupHeight600;}}
//while(x<p_w||y<p_h){x=x+220;y=y+220;if(x>p_w)x=p_w;if(y>p_h)y=p_h;popupwin.resizeTo(x,y);};}

function OpenPopupWindow(p_name,p_URL,p_w,p_h,p_x,p_y){p_h=parseInt(p_h)-50;
popupwin=myWinOpen(p_URL,p_name,"scrollbars=yes,width="+p_w+",height="+p_h+",screenX="+p_x+",left="+p_x+",screenY="+p_y+",top="+p_y+",status=yes,menubar=no,resizable");
if (window.focus) {
	popupwin.focus();
}
}
//====

function OpenPopupWindowExt(p_name,p_URL,p_w,p_h,p_x,p_y){p_h=parseInt(p_h)-50;
popupwin=myWinOpen(p_URL,p_name,"scrollbars=yes,width="+p_w+",height="+p_h+",screenX="+p_x+",left="+p_x+",screenY="+p_y+",top="+p_y+",status=yes,menubar=no,resizable");}
//====
function OpenChromePopupWindow(p_name,p_URL,p_w,p_h,p_x,p_y){
x=50;y=50;popupwin=myWinOpen(p_URL,p_name,"scrollbars=yes,width="+x+",height="+y+",screenX="+p_x+",left="+p_x+",screenY="+p_y+",top="+p_y+",status=yes,toolbar=yes,location=yes,menubar=yes,resizable");
popupwin.focus();if(p_w>650)if(window.screen.width>820){if (p_h>=K_MainPopupHeight768){p_w=K_MainPopupWidth1024;p_h=K_MainPopupHeight768;}}else{if (p_h>=K_MainPopupHeight600){
p_w=K_MainPopupWidth800;p_h=K_MainPopupHeight600;}}while(x<p_w||y<p_h){x=x+220;y=y+220;if(x>p_w)x=p_w;if(y>p_h)y=p_h;popupwin.resizeTo(x,y);}}
function OpenChromePopupWindowExt(p_name,p_URL,p_w,p_h,p_x,p_y){
popupwin=myWinOpen(p_URL,p_name,"scrollbars=yes,width="+p_w+",height="+p_h+",screenX="+p_x+",left="+p_x+",screenY="+p_y+",top="+p_y+",status=yes,toolbar=yes,location=yes,menubar=yes,resizable");}
//====
function myClose(p_w,p_h,x,y){
	wi=130;hi=130;xi=0;yi=0;
	sn=parseInt(Math.random()*8)+1;
	if(sn==1)yi=0;if(sn==2)wi=0;if(sn==3)hi=0;if(sn==4)xi=120;if(sn==5)yi=100;
	while(!done(sn,p_w,p_h,x,y)){
		p_w-=wi;p_h-=hi;if(p_w<50)p_w=50;if(p_h<50)p_h=50;
		window.resizeTo(p_w,p_h);
		if(xi>0||yi>0){x+=xi;y+=yi;window.moveTo(x,y);}
	}
	window.close();
}
function done(sn,w,h){
	if(sn==1)if(w>50||h>50)return 0;
	if(sn==2)if(h>50)return 0;
	if(sn==3)if(w>50)return 0;
	if(sn==4)if(w>50||h>50)return 0;
	if(sn==5)if(w>50||h>50)return 0;
	return 1;
}
function confirmDelete(p_msg){	return confirm(p_msg);}
function setCookie(name,value,domain,path,expi){
curCookie=name+"="+escape(value)+((expi)?"; expires="+expi.toGMTString():"")+((path)?"; path="+path:"")+((domain)?"; domain="+domain:"")
d.cookie=curCookie
}   
function AddZeros(p_s,p_sz){z="000000000000000";return z.substring(0,(p_sz-p_s.length))+p_s;}
var iconStatusIsVisible=false;
var theBrowser=navigator.appName;
var mouseX=0;
var mouseY=0;
function updateMousePos(e){
	if (theBrowser == 'Netscape'){mouseX = e.pageX;mouseY = e.pageY;}
		else{mouseX = e.clientX;mouseY = e.clientY;}
		//====== UnComment this line when debugging - the values will show up in the browser status bar
		//window.status = "MOUSE[" + mouseX + "," + mouseY + "]";
     		window.status = ""; 
	}
function iconSelectMenuShow(p_divName, e){
	if (iconStatusIsVisible == true){
		modifyDIV(p_divName, "visibility", "hidden");
		iconStatusIsVisible = false;
	}else{
		document.getElementById(p_divName).style.left = mouseX - 10;
		document.getElementById(p_divName).style.top = (d.body.scrollTop + mouseY) + 15;
		modifyDIV(p_divName, "visibility", "visible");
		iconStatusIsVisible = true;
	}
}
function iconSelectMenuExit(p_divName, e){
	popupDivMenuExit(p_divName, e);
	iconStatusIsVisible = false;
}
function popupDivMenuExit(p_divName, e){	
	if (document.getElementById(p_divName)){
		var divLeft = parseInt(document.getElementById(p_divName).style.left);
		var divTop  = parseInt(document.getElementById(p_divName).style.top) - parseInt(d.body.scrollTop);
		var divWidth = parseInt(document.getElementById(p_divName).style.width);
		var divHeight  = parseInt(document.getElementById(p_divName).style.height);
		var xOffSet = (mouseX - divLeft);
		var yOffSet = (mouseY - divTop);
	//	window.status = "MOUSE[" + mouseX + "," + mouseY + "]  divSize["+ divWidth + "," + divHeight + "] OffSet["+ xOffSet + "," + yOffSet + "]";  
		if ((xOffSet > divWidth) || (xOffSet < 0) || (yOffSet > divHeight) || (yOffSet < -30)){
			modifyDIV(p_divName, "visibility", "hidden");
		}
	}
}
function modifyDIV(p_divName, p_property, p_value){
	if (document.getElementById){
		eval("document.getElementById('" + p_divName + "').style." + p_property + "='" + p_value + "'");
		if ( p_property == "visibility"){
			if ( p_value == "visible")
				eval("document.getElementById('" + p_divName + "').style.display=''");
			else
				eval("document.getElementById('" + p_divName + "').style.display='none'");
		}
	} else
		eval("document.layers['" + p_divName + "']." + p_property + "='" + p_value + "'");
}	
//-----------------
//  stuff for the popup div menus
//----------------
var delay  = 300; 
var active_layer_id = -1;
var on_layer_id  = -1;
var buff_id  = -1;
function layer_enter(id){on_layer_id = id;}
function layer_exit(id){
	on_layer_id = - 1;
	setTimeout ('hide("'+ id +'")', delay);
}
function menu_enter(id, e, xOff, yOff){
	if (buff_id >= 0)
		hide(buff_id);
	show (id, e, xOff, yOff);
	active_layer_id = id;
}
function menu_exit(id){
	setTimeout ('hide("'+ id +'")', delay);
	buff_id = active_layer_id;
	active_layer_id = -1;
}
function show(id, e, xOffSet, yOffSet){
	if (theBrowser == 'Netscape'){mouseX = e.pageX;mouseY = e.pageY;}
	else{mouseX = e.clientX;mouseY = e.clientY;}
	if(window.document.getElementById){
			var doc = document.getElementById("divMenu"+id);
		 	doc.style.top = mouseY+yOffSet+(document.body.scrollTop);
			doc.style.left = mouseX+xOffSet;
		 	doc.style.visibility = "visible";
			doc.style.display = "";
	}
	//else if(document.layers){
	//	document.layers[id].visibility = "show";
	//}
}
function hide(id){
	if (active_layer_id != id && on_layer_id != id){
		if(window.document.getElementById){
			//document.all['moreIcons' + id].style.visibility = "hidden";
 			 document.getElementById("divMenu"+id).style.visibility = "hidden";
			 document.getElementById("divMenu"+id).style.display = "none";
		//}else{
		//	document.layers[id].visibility = "hide"; /* don't support any more as id's can now be names
		}
	}
}
function ReplaceQuotes(p_ss){
var r,re;re=/QquoteQ/g;
r = p_ss.replace(re,"'");
return(r);};
function CalledFromExternalDomain(p_URL, p_CurrentDomain){
var l_NoHttpURL, l_ReferrerDomain;
l_NoHttpURL	= p_URL.substring((p_URL.indexOf("//") + 2));
l_ReferrerDomain = l_NoHttpURL.substring(0, (l_NoHttpURL.indexOf("/")));
if ((l_ReferrerDomain == '') || (l_ReferrerDomain == p_CurrentDomain ) 
|| (l_ReferrerDomain == 'www.ezi123.com') || (l_ReferrerDomain == '192.168.0.100') || (l_ReferrerDomain == '192.168.0.201') || (l_ReferrerDomain == 'www.stratapay.com.au')
|| (p_CurrentDomain == 'www.ezi123.com') || (p_CurrentDomain == '192.168.0.100') || (p_CurrentDomain == '192.168.0.201')){
	//need to check for www.ezi123.com, 192.168.0.100, 192.168.0.201 for when going to and from ewebeditpro programs
	return false;
}else{
	return true;
}
}
//==========FOR MULTILINGUAL =============
function GetParentWindowsClass(p_CallingWindow){
	var l_NumIntermediateWin	= 0
	this.FramedWindowFoundFlag 	= false;
	if (p_CallingWindow.top.topnav || p_CallingWindow.top.nav ){
		this.FramedWindowFoundFlag = true;
		this.FrameWindow			= p_CallingWindow.top;
	}else {
		var OpenerWindow = p_CallingWindow.opener;
		while ((OpenerWindow!=null) && (this.FramedWindowFoundFlag==false)) {
			if (OpenerWindow.top.topnav || OpenerWindow.top.nav ){
		   		this.FramedWindowFoundFlag = true;
				this.FrameWindow = OpenerWindow.top;
			}else{
				OpenerWindow = OpenerWindow.opener; 
				l_NumIntermediateWin++;
			}
		};
	}
	this.NumIntermediateWin = l_NumIntermediateWin;		
}

function doChangeLanguage(p_LangID){
ChangeLanguage1(self, p_LangID, '')
}

function ChangeLanguage1(p_CallingWindow, p_LangID, p_AlternateAction){
	RedisplayPageInDifferentLanguage(p_CallingWindow, p_LangID, p_AlternateAction);//change caller
	if (CalledFromEwebeditproPage(p_CallingWindow)== false){ 
		var l_ParentWindows	= new GetParentWindowsClass(p_CallingWindow);
		//change all intermediate opened windows
		var l_IntermediateWindow = p_CallingWindow.opener;
		var l_IWin;
		for(l_IWin=0;l_IWin < l_ParentWindows.NumIntermediateWin; l_IWin++){
			RedisplayPageInDifferentLanguage(l_IntermediateWindow, p_LangID, '');
			l_IntermediateWindow = l_IntermediateWindow.opener;
		}
		//change all framed windows
		if (l_ParentWindows.FramedWindowFoundFlag == true){
			if (self != l_ParentWindows.FrameWindow.content ) {
				RedisplayPageInDifferentLanguage(l_ParentWindows.FrameWindow.content, p_LangID,'');
			}
			if (self != l_ParentWindows.FrameWindow.topnav ) 
				RedisplayPageInDifferentLanguage(l_ParentWindows.FrameWindow.topnav, p_LangID,'');
			if (self != l_ParentWindows.FrameWindow.nav ) 
				RedisplayPageInDifferentLanguage(l_ParentWindows.FrameWindow.nav, p_LangID,'');
			if (self != l_ParentWindows.FrameWindow.footerframe ) 
				RedisplayPageInDifferentLanguage(l_ParentWindows.FrameWindow.footerframe, p_LangID,'');
		}
		l_ParentWindows = '';
	}
}

function RedisplayPageInDifferentLanguage(p_Window, p_LangID, p_AlternateAction){
	if ( p_Window ) {
		var K_Display = 'Display';
		if (p_Window.location.href.indexOf("?") > 0){ //Url has parameters
			ChangeThisURL(p_Window, p_LangID);
		}else{
			//for pages that do not have a complete URL because they got there through a form submit then need to resubmit the form 
			//without doing any updates therefore prepend "Display" to the Action and submit it again.
			if (p_AlternateAction==''){
				p_Window.document.Form1.Action.value = K_Display + p_Window.document.Form1.Action.value;
			}else{
				p_Window.document.Form1.Action.value = p_AlternateAction;
			}
			p_Window.document.Form1.LanguageSelected.value = p_LangID;
			p_Window.document.Form1.submit();
		}
	}
}


function CalledFromEwebeditproPage(p_window){
//if its an ewebeditpro page then the url will be www.ezi123.com and the other frames will have a different url and
// therefore will get an access denied javascript error 
	if (typeof(p_window.editorname) == "undefined")
		return false;
	else
		return true;
}

function ChangeThisURL(p_Window, p_langID){
var l_LangParmStartPosition, l_LangParmEndPosition, l_NewLocationHref, l_windowURL;
	if (p_Window){
		l_windowURL 			= p_Window.location;
		l_LangParmStartPosition = l_windowURL.href.indexOf("&L=",0);
		if (l_LangParmStartPosition > 0){
			l_LangParmEndPosition 	= l_windowURL.href.indexOf("&",(l_LangParmStartPosition + 1));
			l_NewLocationHref  		= l_windowURL.href.substring(0, l_LangParmStartPosition) + "&L=" + p_langID + "&" ;
			if (l_LangParmEndPosition > -1 && l_LangParmEndPosition < l_windowURL.href.length)
				l_NewLocationHref	=  l_NewLocationHref  + l_windowURL.href.substring((l_LangParmEndPosition + 1), l_windowURL.href.length);
			l_windowURL.href	= l_NewLocationHref;
		}else{
			if (l_windowURL.href.charAt(l_windowURL.href.length -1) == "&")
				l_windowURL.href = l_windowURL.href + "L=" + p_langID + "&";
			else
				l_windowURL.href = l_windowURL.href + "&L=" + p_langID + "&";
		}
	}
}

