
// Netscape 4x resize bug handling
function init() {
  setTimeout("window.onresize = redo", 1000);
}

function redo() {
  window.location.reload();
}

if (ns4) window.onload = init;

// END - Netscape 4x resize bug handling




if ( !document.all ) {
	if (document.getElementById){
		var ns6 = true;
	}
}
var ie4 = (document.all);
var ns4 = (document.layers);
var onInvalidMessageText;
var onInvalidMessageTextStem;
var OKtoPost;

var layeron = '';
var xpos = 0;
var ypos = 0;
var xposoffset = 0;
var yposoffset = 0;

//document.onmousemove=mouseTracker;

// Search Engine Tracking - BEGIN


var engines = new Array(
	Array('altavista',	'Alta Vista'),
	Array('aol',		'AOL'),
	Array('ask',		'Ask Jeeves'),
	Array('earthlink',	'Earthlink'),
	Array('google',		'Google'),
	Array('infospace',	'InfoSpace'),
	Array('msn',		'MSN'),
	Array('netscape',	'Netscape'),
	Array('overture',	'Overture'),
	Array('yahoo',		'Yahoo')
);

var thisreferrer = document.referrer;
if(thisreferrer){
	for(var i = 0; i<engines.length; i++){
		if (thisreferrer.indexOf(engines[i][0])>-1){


			var expireDate = new Date;
			var expireYear = parseInt(expireDate.getYear());

			if(expireYear < 2000){
				expireYear = parseInt(expireYear + 1900);
			}

			expireDate.setYear(parseInt(expireYear) + 1);	
	
			var expiresString = expireDate.toGMTString();
			if( getCookie('webreferrerurl') ){
				deleteCookie('webreferrerurl');
			}
			if( getCookie('webreferrername') ){
				deleteCookie('webreferrername');
			}
			setCookie('webreferrerurl',document.referrer,expireDate,'/',null,false);
			setCookie('webreferrername',engines[i][1],expireDate,'/',null,false);

			break;
		}
	}
}

// Search Engine Tracking - END


function CheckKeywords() {
	var thisurl = unescape(document.location.href);
	thisurl = thisurl.substr(thisurl.indexOf("/",8));
	for (i=0;kcturls.length>i;i++) {
		if (thisurl == kcturls[i]) {
			var expireDate = new Date;
			var expireYear = parseInt(expireDate.getYear());

			if(expireYear < 2000){
				expireYear = parseInt(expireYear + 1900);
			}

			expireDate.setYear(parseInt(expireYear) + 1);	
			var expiresString = expireDate.toGMTString();
			if( getCookie('kct') ){
				deleteCookie('kct');
			}
			setCookie('kct',thisurl+'|'+Date()+'|'+document.referrer,expireDate,'/',null,false);
		}
	}
}


if (document.layers) { // Netscape
    document.captureEvents(Event.MOUSEMOVE);
    document.onmousemove = captureMousePosition;
} else if (document.all) { // Internet Explorer
    document.onmousemove = captureMousePosition;
} else if (document.getElementById) { // Netcsape 6
    document.onmousemove = captureMousePosition;
}
// Global variables
xMousePos = 0; // Horizontal position of the mouse on the screen
yMousePos = 0; // Vertical position of the mouse on the screen
xMousePosMax = 0; // Width of the page
yMousePosMax = 0; // Height of the page

function captureMousePosition(e) {
    if (document.layers) {
        // When the page scrolls in Netscape, the event's mouse position
        // reflects the absolute position on the screen. innerHight/Width
        // is the position from the top/left of the screen that the user is
        // looking at. pageX/YOffset is the amount that the user has 
        // scrolled into the page. So the values will be in relation to
        // each other as the total offsets into the page, no matter if
        // the user has scrolled or not.
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
    } else if (document.all) {
        // When the page scrolls in IE, the event's mouse position 
        // reflects the position from the top/left of the screen the 
        // user is looking at. scrollLeft/Top is the amount the user
        // has scrolled into the page. clientWidth/Height is the height/
        // width of the current page the user is looking at. So, to be
        // consistent with Netscape (above), add the scroll offsets to
        // both so we end up with an absolute value on the page, no 
        // matter if the user has scrolled or not.
        xMousePos = window.event.x+document.body.scrollLeft;
        yMousePos = window.event.y+document.body.scrollTop;
        xMousePosMax = document.body.clientWidth+document.body.scrollLeft;
        yMousePosMax = document.body.clientHeight+document.body.scrollTop;
    } else if (document.getElementById) {
        // Netscape 6 behaves the same as Netscape 4 in this regard 
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
    }
}







//function mouseTracker() {
//	xposdoc = document.body.scrollLeft + event.x + xposoffset;
//	yposdoc = document.body.scrollTop + event.y + yposoffset;
//}

function showLayer(layername){

	if (ie4){
		if(eval(layername +'.style.visibility=="visible"')){hideLayer(layername);}
		else{
			eval(layername +'.style.visibility="visible"');
			eval(layername +'.style.left=' + xMousePos);
			eval(layername +'.style.top=' + yMousePos);
		}
	}
	else{
		if (ns4){
			if(eval('document.' + layername + '.visibility=="show"')){hideLayer(layername)}
			else{

				eval('document.' + layername + '.visibility="show"');
				eval('document.' + layername + '.left=' + xMousePos);
				eval('document.' + layername + '.top=' + yMousePos);

			}
		}
		else{
			if(eval('document.getElementById("' + layername + '").style.visibility=="visible"')){
				hideLayer(layername)
			}
			else{
				eval('document.getElementById("' + layername + '").style.visibility="visible"');
				eval('document.getElementById("' + layername + '").style.left=' + xMousePos);
				eval('document.getElementById("' + layername + '").style.top=' + yMousePos);
			}
		}
	}
	hideLayer(layeron);
	if(layeron==layername){
		layeron = '';
	}
	else {
		layeron = layername
	}
}


function hideLayer(layername){
	if(layername != ''){
		if (ie4){
			eval(layername + '.style.visibility="hidden"');

		}
		else{
			if (ns4){
				eval('document.' + layername + '.visibility="hide"');
			}
			else{
				eval('document.getElementById("' + layername + '").style.visibility="hidden"');
			}
		}
	}

}



function tellafriend(type) {
	if (type != 1){
	document.location.href='/tellafriend/index.html?pagename=' + document.title + '&amp;url=' + document.location.href;
	}
	else { // popup behaviour
	document.location.href='/tellafriend/index.html?pagename=' + document.title + '&amp;url=' + document.location.href + '&amp;type=' + type;	
	}
}

function tellafriend_ecmvip(type) {
	if (type != 1){
	document.location.href='/tellafriend/index_ecm_vip.html?pagename=' + document.title + '&amp;url=' + document.location.href;
	}
	else { // popup behaviour
	document.location.href='/tellafriend/index_ecm_vip.html?pagename=' + document.title + '&amp;url=' + document.location.href + '&amp;type=' + type;	
	}
}
		
function onSubmitForm(theform) {
		
	OKtoPost = true;
	
	onInvalidMessageText = eval('onInvalidMessageTextStem' + theform.name);
	ValidationArray = eval('arr' + theform.name + 'ValidationTests');
	for (var i=0 ; i < ValidationArray.length; i++) {

		DoValidation(ValidationArray[i],theform);
	}
	//alert(OKtoPost);

	if (OKtoPost == false) {
		alert(onInvalidMessageText);
		//MessageBlock.innerHTML = onInvalidMessageText;
		//showLayer('invalidform' + theform.name);
	}
	else {
		theform.submit();
		//alert('form submit');
	}				
}

function DoValidation(strTest,theform) {

	// strTest Format is as follows
	// [fieldname]:[test 1];[test 1 onInvalidText]|[test 2];[test 2 onInvalidText]|[test 3]:[test 3 onInvalidText]|...|[test n]:[test n onInvalidText]

	var arrTest = new Array(2);
	arrTest =  strTest.split(":")
	var fieldname = arrTest[0];
	var arrTests = arrTest[1].split("|");
	marklabelasOK(theform.name + fieldname);
	for (var j=0; j < arrTests.length; j++) {

		var arrThisTest = new Array(2);
		arrThisTest = arrTests[j].split(";");
		var onInvalidText = arrThisTest[1];
		var arrTestDetails = new Array(2);
		arrTestDetails = arrThisTest[0].split("=");
		var thisvalue;
		eval("thisvalue = theform." + fieldname + ".value");
		var testresult;

		switch(arrTestDetails[0]) {

			case "email":
				testresult = IsEmail(thisvalue);
				if (testresult == false) {
					marklabelasinvalid(theform.name + fieldname);
					onInvalidMessageText = onInvalidMessageText + "\n - " + onInvalidText;
				}
				break;


			case "exists":
				
				testresult = DoesExist(thisvalue);
				if (testresult == false) {
					marklabelasinvalid(theform.name + fieldname);
					onInvalidMessageText = onInvalidMessageText + "\n - " + onInvalidText;
				}
				break;


			case "radiochecked":
				
				testresult = HasEnoughChecked(eval('theform.' + fieldname), 1);
				if (testresult == false) {
					marklabelasinvalid(theform.name + fieldname);
					onInvalidMessageText = onInvalidMessageText + "\n - " + onInvalidText;
				}
				break;



			case "length":					

				testresult = IsLongEnough(thisvalue, arrTestDetails[1]);
				if (testresult == false) {
					marklabelasinvalid(theform.name + fieldname);
					onInvalidMessageText = onInvalidMessageText + "\n - " + onInvalidText;
				}
				break;



			case "numchecked":					
				
				testresult = HasEnoughChecked(eval('theform.' + fieldname), arrTestDetails[1]);
				if (testresult == false) {
					marklabelasinvalid(theform.name + fieldname);
					onInvalidMessageText = onInvalidMessageText + "\n - " + onInvalidText;
				}
				break;

			case "maxlength":
				
				testresult = IsShortEnough(thisvalue, arrTestDetails[1]);
				if (testresult == false) {
				   marklabelasinvalid(theform.name + fieldname);
				   onInvalidMessageText = onInvalidMessageText + "\n - " + onInvalidText;
				}
				break;

		}
		OKtoPost = OKtoPost && testresult;
	}
}




function marklabelasOK(fieldname) {
	if (ie4){
		labeldiv = eval('fieldlabel' + fieldname +'.style')
	}
	else{
		if (ns4){
			return true;
			//alert('marklabelasOK - document.fieldlabel' + fieldname);
			//labeldiv = eval('document.fieldlabel' + fieldname);
			
		}
		else{			
			labeldiv = eval('document.getElementById("fieldlabel' + fieldname + '").style');
		}
	}
	labeldiv.color='black';
}


function marklabelasinvalid(fieldname) {
	if (ie4){
		labeldiv = eval('fieldlabel' + fieldname +'.style')
	}
	else{
		if (ns4){
			return true;
			//alert('marklabelasinvalid - document.fieldlabel' + fieldname);
			//labeldiv = eval('document.fieldlabel' + fieldname);
			
		}
		else{			
			labeldiv = eval('document.getElementById("fieldlabel' + fieldname + '").style');
		}
	}
	labeldiv.color='red';
}

function IsEmail(str) {
	if (str.indexOf("@")==-1) {	
		return false;
	}
	return true;
}


function DoesExist(str) {
	if (str=='') {	
		return false;
	}
	return true;
}


function IsLongEnough(str,strlen) {
	if (str.length < strlen) {
		return false;
	}
	return true;
}

function IsShortEnough(str,strlen) {
	if (str.length > strlen) {
		return false;
	}
	return true;
}

function HasEnoughChecked(checkboxfield,strlen) {
	var NumChecked = 0;
	for (var i=1; i <= checkboxfield.length; i++) {
		if (checkboxfield[i-1].checked) {NumChecked++}
	}
	
	if (NumChecked < strlen) {return false}
	return true;
}

function launchforce( loginurl, url )
{

	window.moveTo(0,0);
	window.resizeTo(screen.width,screen.height);
	
	properid = url.split("?ID=")
	properid2 = properid[1].split(".View&U=1080078118015")
	
	ecs_OpenPresentation('https://launchforce.opentext.com/ecs/ecs', properid2[0], 'livelinkupguest', 'livelinkupguest')
	if(history.length > 0)
	{
		history.go(-1)
	} else
	{
		window.opener=self
		window.close()		
	}	
	

	//window.open( loginurl, 'launchforce','toolbar=no,height=680,width=600,resizable=yes');
	//self.setTimeout("window.open( '"+url+"', 'launchforce','toolbar=no,height=680,width=600,resizable=yes')", 2000)
}
 

universalDate = new Date();


function imagerotator(arg,imgname ) {
	
	argsplit = arg.split("|");
	numimages = argsplit.length - 1;
	s = universalDate.getSeconds();
	p = 60/numimages;
	
	for(i=1;i<numimages+1;i++){
	
		if(s >=(i-1)*p ){
			if (s < i*p){

				imgsplit = argsplit[i-1].split("%#%");
	

				eval('document.' + imgname + '.src=imgsplit[0]');

				eval('document.'+ imgname +'.src=imgsplit[0]');
				eval('document.'+ imgname +'.width=imgsplit[2]');
				eval('document.'+ imgname +'.height=imgsplit[3]');
				eval('document.'+ imgname +'.alt=imgsplit[1]');
				
			}
		}
	}	

}


function gotolocation(arg,imgname ) {
	
	argsplit = arg.split("|");
	numimages = argsplit.length - 1;
	s = universalDate.getSeconds();
	p = 60/numimages;
	
	for(i=1;i<numimages+1;i++){
	
		if(s >=(i-1)*p ){
			if (s < i*p){

				imgsplit = argsplit[i-1].split("%#%");
	

				if (imgsplit[4] != ""){
					document.location = imgsplit[4];
				}
			}
		}
	}	

}

//////////////////////
// COOKIE FUNCTIONS //
//////////////////////

function getCookie(name) {
	var cookies=document.cookie.split("; ");
	for (var i=0; i<cookies.length; i++) {
		var cookie=cookies[i].split("=");
		if (cookie[0]==name) {
			return unescape(cookie[1]);
		}
	}
	return null;
}

function setCookie(name, value, expires, path, domain, secure) {
	var cookie=name+"="+escape(value);
	if (expires) {
		cookie+="; expires="+expires.toGMTString();
	}
	if (path) {
		cookie+="; path="+path;
	}
	if (domain) {
		cookie+="; domain="+domain;
	}
	if (secure) {
		cookie+="; secure";
	}
	document.cookie=cookie;
}

function deleteCookie(name) {
	setCookie(name,'null',new Date(0),null,null,true);
}


//////////////////////////
// END COOKIE FUNCTIONS //
//////////////////////////

//////////////////////////
// DISCLAIMER FUNCTION  //
//////////////////////////

// this function interposes a javascript Confirmation in front of a URL for which a disclaimer is necessary.
// url = string containing the "disclaimed" url. Could be a download link to a PDF.
// type = disclaimer type. 0=investor disclaimer, 1=???, etc.

function disclaim(url, type)
{
var disclaimer
switch(type){ //type in the text for the disclaimer here
	case 0: // investor disclaimer
		disclaimer = "Legal Disclaimer: The information presented here is drawn from publicly available materials and materials produced by Open Text Corporation. However, due to the possibility of inadvertent errors in input, transmission or editing, Open Text cannot warrant its accuracy, and advises you to refer to the original published documents. Continue?";	
		break;
	case 1:
		break;
	}
if (confirm(disclaimer))
	{
	location.href(url);
	}
}




