<!--
//----------------------------------
// FUNCTIONS to set session 'location' variables for mezzanine flash component.
// mezzanine.asp include holds the other javascripts to set the filters etc
//----------------------------------

function goTo(lid){
	setLocation(lid);
	window.location="mezzanine.asp";
}
function setLocation(value){
	setSession("lid", value);
}
function setSession(varName, value){
	var url = "media/flash/setter.asp?" + varName + "=" + value;
	if (window.XMLHttpRequest){
		req = new XMLHttpRequest();
	} else {
		req = new ActiveXObject("Microsoft.XMLHTTP");
	}
	req.open("POST", url, true);				
	req.send();
}



//----------------------------------


function Trim(varString){

	var strTemp = varString.toString();
		
	if(strTemp.indexOf(" ") >= 0){
	
		// Left Trim
		for (i=0; i < strTemp.length; i++) {
			if(strTemp.charAt(i) == " "){
				strTemp = strTemp.substring(i + 1);
			}
			else{
				break
			}
		}
		
		// Right Trim
		for (i=strTemp.length - 1;  i >= 0; i--) {
			if(strTemp.charAt(i) == " "){
				strTemp = strTemp.substring(0, i);
			}
			else{
				break
			}
		}
	}
	
	return strTemp
}


function openShadowBox(url, name){
    Shadowbox.open({
        content:    url,
        player:     "flv",
        title:      name,
        height:     300,
        width:      500
    });
}

/*
 CheckValidDate Procedure
 This function determines if the date is valid and has been entered in dd/mm/yy
 form. This ensures that the date can be converted to Medium Date
 format on the server without any problems.
*/

function IsDate(strDate){

	var blnResult = true;

	// check that the string is at least 6 characters long ie. 1/1/03.		
	if (strDate.length < 6){ 
		blnResult = false;
	} else {
		// check that there are 3 values separated by forward slashes.
		var arrDate = strDate.split("/")
	
		if(arrDate.length != 3){ 
			blnResult = false;
		} else {
			// check that each of the 3 values are numeric
			for (i = 0; i <= 2; i++){
				if(isNaN(arrDate[i])){
					blnResult = false;
				} else {
					/*
					 check that the month (array element 1) is between 1 and 12
					 and the days (array element 0) do not exceed the number of days in the month
					 */
					if (i == 1) {	// Jan, Mar, May, July, Aug, Oct, Dec
						if (arrDate[i] == 1 || arrDate[i] == 3 || arrDate[i] == 5 || arrDate[i] == 7 ||
							arrDate[i] == 8 || arrDate[i] == 10 || arrDate[i] == 12){
							if(arrDate[0] < 1 || arrDate[0] > 31){
								blnResult = false;
							}
						}			// Apr, Jun, Sep, Nov
						else if(arrDate[i] == 4 || arrDate[i] == 6 || arrDate[i] == 9 || arrDate[i] == 11){
								if(arrDate[0] < 1 || arrDate[0] > 30){
									blnResult = false;
								}
						}
						else if (arrDate[i] == 2){ 		// Feb
							
							if (arrDate[2] % 4 == 0){ 	// leap year
								if(arrDate[0] < 1 || arrDate[0] > 29){
									blnResult = false;
								}
							}
							else{ 						// non leap year
								if(arrDate[0] < 1 || arrDate[0] > 28){
									blnResult = false;
								}
							}
						}
						else{
							blnResult = false;
						}
					}

					/* check that there are either 2 or 4 digits in the year */

					if(arrDate[2].length != 2 && arrDate[2].length != 4){
						blnResult = false;
					}
				}
			}
		}
	}
	
	return blnResult;
}


function IsValidEmail(strEmail) {

	invalidChars = " /:,;"

	if (strEmail == "") {
		return false;
	}

	for (i=0; i<invalidChars.length; i++) {
		badChar = invalidChars.charAt(i)
		if (strEmail.indexOf(badChar,0) > -1) {
			return false;
		}
	}
		
	atPos = strEmail.indexOf("@",1)
	if (atPos == -1) {
		return false;
	}

	periodPos = strEmail.indexOf(".",atPos)
	if (periodPos == -1) {
		return false;
	}

	if (periodPos + 3 > strEmail.length) {
		return false
	}

	return true;
	
}

function IsNumeric(varValue) {
	
	varValue = varValue.toString();

	if (varValue.length == 0){
		return false;
	}
	
	for (var n = 0; n < varValue.length; n++){
	
		if (isNaN(varValue.substring(n, n+1)) && (varValue.substring(n, n+1) != "."))
			return false;
		}
		
	return true;
}

function SQLInjection(strText) {

	var	arrBadChars = new Array("&", "'", "\"", "+", ",", "(", ")");

	for (i=0; i < arrBadChars.length; i++) {
		if (strText.indexOf(arrBadChars[i], 0) > -1) {
			return true;
			break;
		}
	}
	return false;
}

function Popup(strWindowName, strURL, intWidth, intHeight){
	
	var posX = (screen.width / 2) - (intWidth / 2);
	
	window.open(strURL, strWindowName ,"height="+ intHeight +",width="+ intWidth +",left="+ posX +",top=100,toolbar=0,scrollbars=0,resizable=yes");

}

function PopupScroll(strWindowName, strURL, intWidth, intHeight){
	
	var posX = (screen.width / 2) - (intWidth / 2);
	
	window.open(strURL, strWindowName ,"height="+ intHeight +",width="+ intWidth +",left="+ posX +",top=100,toolbar=0,scrollbars,resizable=yes");

}

function PopupDynamic(strWindowName, strURL, intWidth, intHeight, intTop, blnToolbar, blnScrollBar, strResize, blnStatusBar){
	
	var intTop = (intTop == null) ? 100 : intTop;
	var blnToolbar = (blnToolbar == null) ? 0 : blnToolbar;
	var blnScrollBar = (blnScrollBar == null) ? 0 : blnScrollBar;
	var blnStatusBar = (blnStatusBar == null) ? 1 : blnStatusBar;
	var strResize = (strResize == null) ? 'yes' : strResize;

	var posX = (screen.width / 2) - (intWidth / 2);
	
	window.open(strURL, strWindowName ,"height="+ intHeight +",width="+ intWidth +",left="+ posX +",top="+ intTop +",toolbar="+ blnToolbar +",scrollbars="+ blnScrollBar +",statusbar="+ blnStatusBar +",resizable="+ strResize);

}

function AbsolutePosition(strObjectName, strAxis){
	
	if (document.getElementById) {	//  IE 5+, NS6+, Mozilla
		objHTMLObject = document.getElementById(strObjectName);
	} else if(document.all) { 
		objHTMLObject = document.all.item(strObjectName);
	}
	
	if (strAxis.toUpperCase() == 'Y'){
	
		var intTempPos = objHTMLObject.offsetTop;
		var strTagName = objHTMLObject.tagName;
					
		while(strTagName != "BODY"){
			
			objHTMLObject = objHTMLObject.offsetParent;
			intTempPos = intTempPos + objHTMLObject.offsetTop;
			strTagName = objHTMLObject.tagName;
		} 
		
	} else if (strAxis.toUpperCase() == 'X'){
	
		var intTempPos = objHTMLObject.offsetLeft;
		var strTagName = objHTMLObject.tagName;
					
		while(strTagName != "BODY"){
			
			objHTMLObject = objHTMLObject.offsetParent;
			intTempPos = intTempPos + objHTMLObject.offsetLeft;
			strTagName = objHTMLObject.tagName;
		} 
		
	} else {
		
		var intTempPos = 0;
		
	}
	
	return intTempPos;
	
}

function ShowSubMenu(MenuID){
	
	var objMenu = document.getElementById("SubMenu"+ MenuID);
	var intPosY = AbsolutePosition("Menu" + MenuID , "Y") + 21;
	var intPosX = AbsolutePosition("Menu" + MenuID , "X") - 6;
				
	objMenu.style.left = intPosX + "px";
	objMenu.style.top = intPosY + "px";
	objMenu.style.display = "block";
	
	objMenu = null;
		
}

function HideSubMenu(MenuID){
	
	var objMenu = document.getElementById("SubMenu"+ MenuID);
	objMenu.style.display = "none";
	objMenu = null;
}

// -->