<!--
/**
 * (c) Copyright 2001-2002 netdecisions Limited.  This file is the copyright
 * and confidential information of netdecisions Limited or one of its
 * group of companies ("netdecisions") and may not be used in whole or in
 * part without the prior written consent of netdecisions or pursuant to
 * a licence granted by netdecisions allowing such use.
 **/

//global.js - global scripts for presentation mode

if (document.getElementById && document.createTextNode && document.createElement){canDOM=true}

// Major navigation 
function showMenu(n) {
		if(canDOM){
			u=n.getElementsByTagName('div')[0];
			u.style.visibility=u.style.visibility=='visible'?'hidden':'visible';
			}
		}
		
// Search and dropdown onchange function		
function quickFinder(n) {
if(canDOM){
	node=n.parentNode.getElementsByTagName('select')[0];
	location.href = node.value
	}
}

// Show/hide product description (T18 template)
function showDesc(n) {
	if(canDOM){
		node=n.parentNode.parentNode.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div');
		a=node[0];
		var num=n.parentNode.id;
		var num_split = num.split("_");
		b=node[num_split[4]];
		a.style.display=a.style.display=='none'?'block':'none';
		b.style.display=b.style.display=='block'?'none':'block';
	}
}	
function fetch_object(idname)
{
	if (document.getElementById)
	{
		return document.getElementById(idname);
	}
	else if (document.all)
	{
		return document.all[idname];
	}
	else if (document.layers)
	{
		return document.layers[idname];
	}
	else
	{
		return null;
	}
}
function nullLink(){
}
function CheckForm() {
	if (document.forms[0].Title.value =="") {
		alert("You must enter a Title!");
		document.forms[0].Title.focus();
		return ( false );
	}
	else if (document.forms[0].Subject.value =="") {
		alert("You must enter a Subject!");
		document.forms[0].Subject.focus();
		return ( false );
	}
	
	else {			
		return ( true );
	}
}

function GetSelectedButton(ButtonGroup) {
	for (var i = 0; i < ButtonGroup.length; i++) {
		if (ButtonGroup[i].checked) {
			return i
		}
	}
	return 0
}

function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

function GetItinerary(userID,weekdate,tHeight,tWidth){
		TempAttributes = 'width='+ tWidth +',height='+ tHeight +',left=20,top=100,resizable=yes,menubar=no,toolbar=no';
		TempString ='/itinerary/edit_itinerary.cfm?UserID='+userID+'&WeekDate='+weekdate;
		aPopUp= window.open(TempString ,"GetItineraryWindow", TempAttributes);
}


function GetPrint(weekdate,subGroupID){
		TempAttributes = 'width=1020,height=640,scrollbars,left=20,top=100,resizable=yes,menubar=yes,toolbar=yes';
		TempString ='/itinerary/print_schedule.cfm?WeekDate='+weekdate+'&SubGroupID='+subGroupID;
		aPopUp= window.open(TempString ,"GetPrintWindow", TempAttributes);
}

function ChangePassword() {
		aPopUp= window.open('/password_change.cfm' ,"Password", 'width=300,height=250,scrollbars=no,resizable=No');
}

function EditLocation() {
		aPopUp= window.open('/profile_edit_location.cfm' ,"EditLocation", 'width=300,height=250,scrollbars=no,resizable=No');
}


function EditManager(){
	TempAttributes = 'width=250,height=200,left=100,top=100,resizable=yes,menubar=no,toolbar=no';
	TempString ='/profile_manager_edit.cfm';
	aPopUp= window.open(TempString ,"EditManager", TempAttributes);
}

function AuthorizeBrowser(){
	TempAttributes = 'width=350,height=200,left=100,top=100,resizable=yes,menubar=no,toolbar=no';
	TempString ='/authorize_browser.cfm';
	aPopUp= window.open(TempString ,"AuthorizeBrowser", TempAttributes);
}


function SwitchPortal(portalID) {
	TempString ='/portal_switch.cfm?PortalID=' + portalID;
	aPopUp= window.open(TempString ,"SwitchPortal", 'width=400,height=270,scrollbars=no,resizable=yes');
}

function EditContactInfo(nagFlag) {
		TempString ='/contact_info_edit.cfm?NagFlag=' + nagFlag;
		aPopUp= window.open(TempString ,"EditContact", 'width=410,height=520,scrollbars=no,resizable=yes');
}
function EditContactInfo2(nagFlag) {
		TempString ='/contact_info_edit.cfm?NagFlag=' + nagFlag;
		ExpandingWindow(TempString,410,530);
}
function ContactInfoViewAll() {
		aPopUp= window.open('/contact_info_view_all.cfm' ,"ContactInfoViewAll", 'width=580,height=520,scrollbars=yes,resizable=yes');
}
function RetrieveAccountInfo() {
		aPopUp= window.open('/retrieve_account_info.cfm' ,"RetrieveAccountInfo", 'width=430,height=175,scrollbars=no,resizable=yes');
}

function EditEmailPreference() {
		aPopUp= window.open('/profile_email_preference_edit.cfm' ,"EditEmailPreference", 'width=460,height=380,scrollbars=no,resizable=yes');
}
function EditProductPreference() {
		aPopUp= window.open('/profile_product_matrix_edit.cfm' ,"EditProductPreference", 'width=730,height=480,scrollbars=yes,resizable=yes');
}
function OpenMP3Player() {
		aPopUp= window.open('/mp3_player.cfm' ,"OpenMP3Player", 'width=340,height=285,left=100,top=100,scrollbars=no,resizable=yes');
}

function OpenVideoPlayer() {
		aPopUp= window.open('/video_player.cfm' ,"OpenVideoPlayer", 'width=400,height=400,left=100,top=100,scrollbars=no,resizable=yes');
}

function ViewLoggedUsers() {
		aPopUp= window.open('/admin/users/logged_users_view.cfm' ,"ViewLoggedUsers", 'width=600,height=460,left=200,top=200,resizable=yes,menubar=yes,toolbar=yes');
}

function OpenDropBoxLink() {
		aPopUp= window.open('/profile_link_dropbox.cfm?Init=1' ,"OpenDropBoxLink");
}

function EditItineraryPreference(userID) {
	TempAttributes = 'width=460,height=380,scrollbars=no,resizable=yes';
	TempString ='/profile_itinerary_preference_edit.cfm?UserID=' + userID;
	aPopUp= window.open(TempString ,"EditItineraryPreference", TempAttributes);		
}

function EditPDMetrics(requestID,reload){
		TempAttributes = 'width=400,height=460,left=20,top=100,resizable=yes,menubar=no,toolbar=no';		
		TempString ='metrics_edit.cfm?RequestID=' + requestID + '&Reload=' + reload;
		aPopUp= window.open(TempString ,"EditPDMetrics", TempAttributes);		
}

function ViewPhases(installationID){
		TempAttributes = 'width=600,height=360,left=20,top=100,resizable=yes,menubar=no,toolbar=no';
		TempString ='phases_view.cfm?InstallationID=' + installationID;
		aPopUp= window.open(TempString ,"PhasesWindow", TempAttributes);		
}

function AddPhase(installationID){
		TempAttributes = 'width=600,height=360,left=20,top=100,resizable=yes,menubar=no,toolbar=no';
		TempString ='phase_add.cfm?InstallationID=' + installationID;
		aPopUp= window.open(TempString ,"PhasesWindow", TempAttributes);		
}

function ViewLocations(installationID){
		TempAttributes = 'width=600,height=360,left=20,top=100,resizable=yes,menubar=no,toolbar=no';
		TempString ='locations_view.cfm?InstallationID=' + installationID;
		aPopUp= window.open(TempString ,"LocationsWindow", TempAttributes);		
}

function AddLocation(installationID){
		TempAttributes = 'width=600,height=360,left=20,top=100,resizable=yes,menubar=no,toolbar=no';
		TempString ='location_add.cfm?InstallationID=' + installationID;
		aPopUp= window.open(TempString ,"LocationsWindow", TempAttributes);		
}

function EditNewsletterGroupMembers(groupID){
		TempAttributes = 'width=400,height=360,left=20,top=100,resizable=yes,menubar=no,toolbar=no';
		TempString ='members.cfm?GroupID=' + groupID;
		aPopUp= window.open(TempString ,"EditNewsletterGroupMembers", TempAttributes);		
}

function ViewDevices(installationID){
		TempAttributes = 'width=600,height=360,left=20,top=100,resizable=yes,menubar=no,toolbar=no';
		TempString ='devices_view.cfm?InstallationID=' + installationID;
		aPopUp= window.open(TempString ,"DevicesWindow", TempAttributes);		
}

function AddDevice(installationID){
		TempAttributes = 'width=600,height=360,left=20,top=100,resizable=yes,menubar=no,toolbar=no';
		TempString ='device_add.cfm?InstallationID=' + installationID;
		aPopUp= window.open(TempString ,"DevicesWindow", TempAttributes);		
}

function FindSKU(){
		TempAttributes = 'width=600,height=360,left=20,top=100,resizable=yes,menubar=no,toolbar=no';		
		TempString ='partSKU_find.cfm?SKU='+document.PackageForm.SKU.value;
		aPopUp= window.open(TempString ,"SKUWindow", TempAttributes);		
}

function FindSubProduct(){
		TempAttributes = 'width=600,height=360,left=20,top=100,resizable=yes,menubar=no,toolbar=no';		
		TempString ='/pricelist/subproduct_find.cfm';
		aPopUp= window.open(TempString ,"SubProductWindow", TempAttributes);		
}

function AddQuoteItem(quoteID,itemID,price,itemTypeID){
		TempAttributes = 'width=800,height=360,left=20,top=100,resizable=yes,menubar=no,toolbar=no,scrollbars';		
		TempString ='/pricelist/quote_detail_add.cfm?QuoteID=' + quoteID + '&ItemID=' + itemID + '&Price=' + price + '&ItemTypeID=' + itemTypeID;
		aPopUp= window.open(TempString ,"AddQuoteItem", TempAttributes);		
}


function ViewQuoteSpecialNotes(quoteID){
		TempAttributes = 'width=700,height=360,left=20,top=100,resizable=yes,menubar=no,toolbar=no';		
		TempString ='/pricelist/quote_special_notes_view.cfm?QuoteID=' + quoteID;
		aPopUp= window.open(TempString ,"ViewQuoteSpecialNotes", TempAttributes);		
}

function ViewActivityNextMoves(activityID){
		TempAttributes = 'width=700,height=360,left=20,top=100,resizable=yes,menubar=no,toolbar=no';		
		TempString ='/activitylist/activity_next_moves_view.cfm?ActivityID=' + activityID;
		aPopUp= window.open(TempString ,"ViewActivityNextMoves", TempAttributes);		
}

function ViewLocationComments(locationID){
		TempAttributes = 'width=700,height=360,left=20,top=100,resizable=yes,menubar=no,toolbar=no';		
		TempString ='/cors/location_comments_view.cfm?LocationID=' + locationID;
		aPopUp= window.open(TempString ,"ViewLocationComments", TempAttributes);		
}

function ViewLocationPhotos(locationID){
		TempAttributes = 'width=580,height=460,left=20,top=100,resizable=yes,menubar=no,toolbar=no,scrollbars';		
		TempString ='/cors/location_photos_view.cfm?LocationID=' + locationID;
		aPopUp= window.open(TempString ,"ViewLocationPhotos", TempAttributes);		
}

function ViewProjectPhotos(projectID,typeID){
		TempAttributes = 'width=700,height=360,left=20,top=100,resizable=yes,menubar=no,toolbar=no';		
		TempString ='/cors/project_photos_view.cfm?ProjectID=' + projectID + '&TypeID=' + typeID;
		aPopUp= window.open(TempString ,"ViewProjectPhotos", TempAttributes);		
}




function OpenNewPage(fileName){
	TempAttributes = 'resizable=yes,menubar=yes,toolbar=no';
	aPopUp= window.open(fileName ,"DevicesWindow");		
}

function stripCrap(strString) {
	var strChar;
	var newString = "";	
	
	if (strString.length == 0) return "0";
	for (i = 0; i < strString.length; i++) {
		strChar = strString.charAt(i);
		if (strChar != "%" && strChar != "," && strChar != "$" && strChar != " " && strChar != "'" && strChar != "#") {
			newString = newString + strChar;
		}
	}
	return newString;
}

function CheckTradeshowForm() {
	document.forms[0].BoothCost.value = stripCrap(document.forms[0].BoothCost.value);
	document.forms[0].BudgetedCost.value = stripCrap(document.forms[0].BudgetedCost.value);
	
	if (document.forms[0].FocusID.options[document.forms[0].FocusID.selectedIndex].value =="0") {
		alert("You must select a Focus!");
		return ( false );
	}
	else if (document.forms[0].CountryID.options[document.forms[0].CountryID.selectedIndex].value =="0") {
			alert("You must select a Country!");
			return ( false );
	}
	else {			
		return ( true );
	}
}

function CheckPackageForm() {
	document.forms[0].Price.value = stripCrap(document.forms[0].Price.value);
}

function CheckPartForm() {
	document.forms[0].Price.value = stripCrap(document.forms[0].Price.value);
}

function OpenCalendar(fieldIndex,weekDate){
		TempAttributes = 'width=200,height=140,left=200,top=200,resizable=yes,menubar=no,toolbar=no';
		if (weekDate) {
			TempString ='../calendar/index.cfm?FieldIndex='+fieldIndex+'&WeekDate='+weekDate;
		}
		else {
			TempString ='../calendar/index.cfm?FieldIndex='+fieldIndex;
		}
		
		aPopUp= window.open(TempString ,"CalendarWindow", TempAttributes);		
}

function OpenCalendar2(fieldIndex,confirmChange){
		TempAttributes = 'width=200,height=140,left=200,top=200,resizable=yes,menubar=no,toolbar=no';
		if (confirmChange==1) {
			TempString ='../calendar/index2.cfm?ConfirmChange=1&FieldIndex='+fieldIndex;
		}
		else {
			TempString ='../calendar/index2.cfm?FieldIndex='+fieldIndex;
		}
		
		aPopUp= window.open(TempString ,"Calendar2Window", TempAttributes);		
}

function trimAll(sString) {
	while (sString.substring(0,1) == ' ') {
		sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length-1, sString.length) == ' ')	{
		sString = sString.substring(0,sString.length-1);
	}
	return sString;
}

function isNumeric(strString) {
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;
   for (i = 0; i < strString.length && blnResult == true; i++) {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1) {
         blnResult = false;
         }
      }
   return blnResult;
}

function Reformat(field) {	
 	field.value = NumberFormat(stripCrap(field.value));
	
	if (!isNumeric(field.value)) {
		alert("Invalid number!");
		field.focus();
	}
}

function NumberFormat(_a)
{
 var _b=_a.toString().split("");
 var _c="";
 var _d=0;
 for(var i=_b.length-1;i>=0;i--)
 {
   _d++;
   _c=_b[i]+_c;
   if(_d%3==0&&i!=0)
   {
   _c=","+_c;
   }
 }
 return(_c);
}

function ltrim ( s ) {
	return s.replace( /^\s*/, "" );
}

function rtrim ( s ) {
	return s.replace( /\s*$/, "" );
}

function trim ( s ) {
	return rtrim(ltrim(s));
}

function chkdate(objName) {
var strDatestyle = "US"; //United States date style
//var strDatestyle = "EU";  //European date style
var strDate;
var strDateArray;
var strDay;
var strMonth;
var strYear;
var intday;
var intMonth;
var intYear;
var booFound = false;
var datefield = objName;
var strSeparatorArray = new Array("-"," ","/",".");
var intElementNr;
var err = 0;
var strMonthArray = new Array(12);
strMonthArray[0] = "Jan";
strMonthArray[1] = "Feb";
strMonthArray[2] = "Mar";
strMonthArray[3] = "Apr";
strMonthArray[4] = "May";
strMonthArray[5] = "Jun";
strMonthArray[6] = "Jul";
strMonthArray[7] = "Aug";
strMonthArray[8] = "Sep";
strMonthArray[9] = "Oct";
strMonthArray[10] = "Nov";
strMonthArray[11] = "Dec";
strDate = datefield.value;
if (strDate.length < 1) {
return true;
}
for (intElementNr = 0; intElementNr < strSeparatorArray.length; intElementNr++) {
if (strDate.indexOf(strSeparatorArray[intElementNr]) != -1) {
strDateArray = strDate.split(strSeparatorArray[intElementNr]);
if (strDateArray.length != 3) {
err = 1;
return false;
}
else {
strDay = strDateArray[0];
strMonth = strDateArray[1];
strYear = strDateArray[2];
}
booFound = true;
   }
}
if (booFound == false) {
if (strDate.length>5) {
strDay = strDate.substr(0, 2);
strMonth = strDate.substr(2, 2);
strYear = strDate.substr(4);
   }
}
if (strYear.length == 2) {
strYear = '20' + strYear;
}
// US style
if (strDatestyle == "US") {
strTemp = strDay;
strDay = strMonth;
strMonth = strTemp;
}
intday = parseInt(strDay, 10);
if (isNaN(intday)) {
err = 2;
return false;
}
intMonth = parseInt(strMonth, 10);
if (isNaN(intMonth)) {
for (i = 0;i<12;i++) {
if (strMonth.toUpperCase() == strMonthArray[i].toUpperCase()) {
intMonth = i+1;
strMonth = strMonthArray[i];
i = 12;
   }
}
if (isNaN(intMonth)) {
err = 3;
return false;
   }
}
intYear = parseInt(strYear, 10);
if (isNaN(intYear)) {
err = 4;
return false;
}
if (intMonth>12 || intMonth<1) {
err = 5;
return false;
}
if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31 || intday < 1)) {
err = 6;
return false;
}
if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30 || intday < 1)) {
err = 7;
return false;
}
if (intMonth == 2) {
if (intday < 1) {
err = 8;
return false;
}
if (LeapYear(intYear) == true) {
if (intday > 29) {
err = 9;
return false;
}
}
else {
if (intday > 28) {
err = 10;
return false;
}
}
}
if (strDatestyle == "US") {
datefield.value = strMonthArray[intMonth-1] + " " + intday+" " + strYear;
}
else {
datefield.value = intday + " " + strMonthArray[intMonth-1] + " " + strYear;
}
return true;
}
function LeapYear(intYear) {
if (intYear % 100 == 0) {
if (intYear % 400 == 0) { return true; }
}
else {
if ((intYear % 4) == 0) { return true; }
}
return false;
}

function ExpandingWindow(urlString,winwidth,winheight) {
var windowprops='width=100,height=100,scrollbars=yes,status=yes,resizable=yes';
var heightspeed = 2; // vertical scrolling speed (higher = slower)
var widthspeed = 7;  // horizontal scrolling speed (higher = slower)
var leftdist = 100;    // distance to left edge of window
var topdist = 100;     // distance to top edge of window

if (window.resizeTo&&navigator.userAgent.indexOf("Opera")==-1) {
//var winwidth = window.screen.availWidth - leftdist;
//var winheight = window.screen.availHeight - topdist;
var sizer = window.open("","","left=" + leftdist + ",top=" + topdist +","+ windowprops);
for (sizeheight = 1; sizeheight < winheight; sizeheight += heightspeed)
sizer.resizeTo("1", sizeheight);
for (sizewidth = 1; sizewidth < winwidth; sizewidth += widthspeed)
sizer.resizeTo(sizewidth, sizeheight);
sizer.location = urlString;
}
else
window.open(urlString,'mywindow');
}

function toggleLayer(layerName) {
	var layerDiv = document.getElementById(layerName);
	layerDiv.style.display = itemDiv.style.display == "block" ? "none" : "block";
}

function toggleForm(FormName) {
	if ( window.innerHeight && window.scrollMaxY ) { // Firefox 
		pageWidth = window.innerWidth + window.scrollMaxX;
		pageHeight = window.innerHeight + window.scrollMaxY;
	}
	else if ( document.body.scrollHeight > document.body.offsetHeight ) { // all but Explorer Mac	
		pageWidth = document.body.scrollWidth;
		pageHeight = document.body.scrollHeight;
	}
	else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
	 	pageWidth = document.body.offsetWidth + document.body.offsetLeft -21; 
		pageHeight = document.body.offsetHeight + document.body.offsetTop-4;
	}
	var yPosition = window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop;
	var itemDiv = document.getElementById(FormName);
	itemDiv.style.top = yPosition+50;
	itemDiv.style.left = 170;
	itemDiv.style.display = itemDiv.style.display == "block" ? "none" : "block";
	var selectDiv = document.getElementById("HideDiv");
	selectDiv.style.display = selectDiv.style.display == "block" ? "none" : "block";
	var greyBGDiv = document.getElementById("GreyBG");
	greyBGDiv.style.width = (pageWidth-1);
	greyBGDiv.style.height = (pageHeight-1);
	
	greyBGDiv.style.display = greyBGDiv.style.display == "block" ? "none" : "block";
	toggleDisabled(document.getElementById("MasterForm"));
}
function toggleForm2(FormName) {
	if ( window.innerHeight && window.scrollMaxY ) { // Firefox 
		pageWidth = window.innerWidth + window.scrollMaxX;
		pageHeight = window.innerHeight + window.scrollMaxY;
	}
	else if ( document.body.scrollHeight > document.body.offsetHeight ) { // all but Explorer Mac	
		pageWidth = document.body.scrollWidth;
		pageHeight = document.body.scrollHeight;
	}
	else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
	 	pageWidth = document.body.offsetWidth + document.body.offsetLeft -21; 
		pageHeight = document.body.offsetHeight + document.body.offsetTop-4;
	}
	var itemDiv = document.getElementById(FormName);
	var greyBGDiv = document.getElementById("GreyBG");
	//greyBGDiv.style.width = (pageWidth-0);
	//greyBGDiv.style.height = (pageHeight-0);
	greyBGDiv.style.display = greyBGDiv.style.display == "block" ? "none" : "block";
	itemDiv.style.display = itemDiv.style.display == "block" ? "none" : "block";
}
function toggleParentForm(FormName) {
	if ( window.innerHeight && window.scrollMaxY ) { // Firefox 
		pageWidth = window.innerWidth + window.scrollMaxX;
		pageHeight = window.innerHeight + window.scrollMaxY;
	}
	else if ( parent.document.body.scrollHeight > parent.document.body.offsetHeight ) { // all but Explorer Mac	
		pageWidth = parent.document.body.scrollWidth;
		pageHeight = parent.document.body.scrollHeight;
	}
	else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
	 	pageWidth = parent.document.body.offsetWidth; 
		pageHeight = parent.document.body.offsetHeight; 
	}
	var yPosition = window.pageYOffset ||  parent.document.body.scrollTop ||  parent.document.documentElement.scrollTop;
	var itemDiv = parent.document.getElementById(FormName);
	itemDiv.style.top = yPosition+50;
	itemDiv.style.left = 170;
	itemDiv.style.display = itemDiv.style.display == "block" ? "none" : "block";
	var selectDiv = parent.document.getElementById("HideDiv");
	selectDiv.style.top = yPosition+40;
	selectDiv.style.left = 160;
	selectDiv.style.display = selectDiv.style.display == "block" ? "none" : "block";
	var greyBGDiv = parent.document.getElementById("GreyBG");
	greyBGDiv.style.width = (pageWidth-1);
	greyBGDiv.style.height = (pageHeight-1);
	
	greyBGDiv.style.display = greyBGDiv.style.display == "block" ? "none" : "block";
	toggleDisabled(parent.document.getElementById("MasterForm"));
}
function toggleEditForm(FormName) {
	if ( window.innerHeight && window.scrollMaxY ) { // Firefox 
		pageWidth = window.innerWidth + window.scrollMaxX;
		pageHeight = window.innerHeight + window.scrollMaxY;
	}
	else if ( document.body.scrollHeight > document.body.offsetHeight ) { // all but Explorer Mac	
		pageWidth = document.body.scrollWidth;
		pageHeight = document.body.scrollHeight;
	}
	else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
	 	pageWidth = document.body.offsetWidth + document.body.offsetLeft; 
		pageHeight = document.body.offsetHeight + document.body.offsetTop;
	}
	var itemDiv = document.getElementById(FormName);
	itemDiv.style.display = itemDiv.style.display == "block" ? "none" : "block";
	var greyBGDiv = document.getElementById("GreyBG");
	greyBGDiv.style.width = (pageWidth-1);
	greyBGDiv.style.height = (pageHeight-1);
	greyBGDiv.style.display = greyBGDiv.style.display == "block" ? "none" : "block";
	//toggleDisabled(document.getElementById("MasterForm"));
}

function toggleDynamicEditForm(vOffset,FormName) {
	var yPosition = window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop;
	if ( window.innerHeight && window.scrollMaxY ) { // Firefox 
		pageWidth = window.innerWidth + window.scrollMaxX;
		pageHeight = window.innerHeight + window.scrollMaxY;
	}
	else if ( document.body.scrollHeight > document.body.offsetHeight ) { // all but Explorer Mac	
		pageWidth = document.body.scrollWidth;
		pageHeight = document.body.scrollHeight;
	}
	else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
	 	pageWidth = document.body.offsetWidth + document.body.offsetLeft; 
		pageHeight = document.body.offsetHeight + document.body.offsetTop;
	}
	var itemDiv = document.getElementById(FormName);
	var greyBGDiv = document.getElementById("GreyBG");
	
	itemDiv.style.top = yPosition+vOffset;
	greyBGDiv.style.width = (pageWidth-1);
	greyBGDiv.style.height = (pageHeight-1);
	greyBGDiv.style.display = greyBGDiv.style.display == "block" ? "none" : "block";
	itemDiv.style.display = itemDiv.style.display == "block" ? "none" : "block";
}

function toggleDynamicEditForm2(vOffset,itemName,PageName) {
	var yPosition = window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop;
	if ( window.innerHeight && window.scrollMaxY ) { // Firefox 
		pageWidth = window.innerWidth + window.scrollMaxX;
		pageHeight = window.innerHeight + window.scrollMaxY;
	}
	else if ( document.body.scrollHeight > document.body.offsetHeight ) { // all but Explorer Mac	
		pageWidth = document.body.scrollWidth;
		pageHeight = document.body.scrollHeight;
	}
	else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
	 	pageWidth = document.body.offsetWidth + document.body.offsetLeft; 
		pageHeight = document.body.offsetHeight + document.body.offsetTop;
	}
	var itemDiv = document.getElementById(itemName+'Div');
	var itemFrame = document.getElementById(itemName+'Frame');
	var greyBGDiv = document.getElementById("GreyBG");
	
	itemFrame.src = PageName;
	itemDiv.style.top = yPosition+vOffset;
	greyBGDiv.style.width = (pageWidth-1);
	greyBGDiv.style.height = (pageHeight-1);
	greyBGDiv.style.display = greyBGDiv.style.display == "block" ? "none" : "block";
	itemDiv.style.display = itemDiv.style.display == "block" ? "none" : "block";
}

function toggleDynamicParentEditForm(vOffset,FormName) {
	var yPosition = window.pageYOffset || parent.document.body.scrollTop || parent.document.documentElement.scrollTop;
	if ( window.innerHeight && window.scrollMaxY ) { // Firefox 
		pageWidth = window.innerWidth + window.scrollMaxX;
		pageHeight = window.innerHeight + window.scrollMaxY;
	}
	else if ( parent.document.body.scrollHeight > parent.document.body.offsetHeight ) { // all but Explorer Mac	
		pageWidth = parent.document.body.scrollWidth;
		pageHeight = parent.document.body.scrollHeight;
	}
	else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
	 	pageWidth = parent.document.body.offsetWidth + parent.document.body.offsetLeft; 
		pageHeight = parent.document.body.offsetHeight + parent.document.body.offsetTop;
	}
	var itemDiv = parent.document.getElementById(FormName);
	itemDiv.style.top = yPosition+vOffset;
	itemDiv.style.display = itemDiv.style.display == "block" ? "none" : "block";
	var greyBGDiv = parent.document.getElementById("GreyBG");
	greyBGDiv.style.width = (pageWidth-1);
	greyBGDiv.style.height = (pageHeight-1);
	greyBGDiv.style.display = greyBGDiv.style.display == "block" ? "none" : "block";
}

function toggleDisabled(el) {
	try {
		el.disabled = el.disabled ? false : true;
	}
	catch(E){}
                
	if (el.childNodes && el.childNodes.length > 0) {
		for (var x = 0; x < el.childNodes.length; x++) {
		toggleDisabled(el.childNodes[x]);
		}
	}
}

function toggleParentDisabled(el) {
	try {
		el.disabled = el.disabled ? false : true;
	}
	catch(E){}
                
	if (el.childNodes && el.childNodes.length > 0) {
		for (var x = 0; x < el.childNodes.length; x++) {
		toggleParentDisabled(el.childNodes[x]);
		}
	}
}

/******************************************
* Popup Box- By Jim Silver @ jimsilver47@yahoo.com
* Visit http://www.dynamicdrive.com/ for full source code
* This notice must stay intact for use
******************************************/

var ns4=document.layers
var ie4=document.all
var ns6=document.getElementById&&!document.all

//drag drop function for NS 4////
/////////////////////////////////

var dragswitch=0
var nsx
var nsy
var nstemp

function drag_dropns(name){
if (!ns4)
return
temp=eval(name)
temp.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP)
temp.onmousedown=gons
temp.onmousemove=dragns
temp.onmouseup=stopns
}

function gons(e){
temp.captureEvents(Event.MOUSEMOVE)
nsx=e.x
nsy=e.y
}
function dragns(e){
if (dragswitch==1){
temp.moveBy(e.x-nsx,e.y-nsy)
return false
}
}

function stopns(){
temp.releaseEvents(Event.MOUSEMOVE)
}

//drag drop function for ie4+ and NS6////
/////////////////////////////////


function drag_drop(e){
if (ie4&&dragapproved){
crossobj.style.left=tempx+event.clientX-offsetx
crossobj.style.top=tempy+event.clientY-offsety

crossobj2.style.left=tempx2+event.clientX-offsetx
crossobj2.style.top=tempy2+event.clientY-offsety

return false
}
else if (ns6&&dragapproved){
crossobj.style.left=tempx+e.clientX-offsetx+"px"
crossobj.style.top=tempy+e.clientY-offsety+"px"

crossobj2.style.left=tempx2+e.clientX-offsetx+"px"
crossobj2.style.top=tempy2+e.clientY-offsety+"px"

return false
}
}

function drag_drop2(e){
if (ie4&&dragapproved){
crossobj.style.left=tempx+event.clientX-offsetx
crossobj.style.top=tempy+event.clientY-offsety
return false
}
else if (ns6&&dragapproved){
crossobj.style.left=tempx+e.clientX-offsetx+"px"
crossobj.style.top=tempy+e.clientY-offsety+"px"
return false
}
}

function initializedrag(e,FormName){
	crossobj= document.getElementById(FormName);
	crossobj2= document.getElementById("HideDiv");
	var firedobj=ns6? e.target : event.srcElement
	var topelement=ns6? "html" : document.compatMode && document.compatMode!="BackCompat"? "documentElement" : "body"
	while (firedobj.tagName!=topelement.toUpperCase() && firedobj.id!="dragbar"){
		firedobj=ns6? firedobj.parentNode : firedobj.parentElement
	}
	if (firedobj.id=="dragbar"){
		offsetx=ie4? event.clientX : e.clientX
		offsety=ie4? event.clientY : e.clientY

		tempx=parseInt(crossobj.style.left)
		tempy=parseInt(crossobj.style.top)
		
		tempx2=parseInt(crossobj2.style.left)
		tempy2=parseInt(crossobj2.style.top)

		dragapproved=true
		document.onmousemove=drag_drop
	}
}

function initializedrag2(e,FormName){
	crossobj= document.getElementById(FormName);
	var firedobj=ns6? e.target : event.srcElement
	var topelement=ns6? "html" : document.compatMode && document.compatMode!="BackCompat"? "documentElement" : "body"
	while (firedobj.tagName!=topelement.toUpperCase() && firedobj.id!="dragbar"){
		firedobj=ns6? firedobj.parentNode : firedobj.parentElement
	}

	if (firedobj.id=="dragbar"){
		offsetx=ie4? event.clientX : e.clientX
		offsety=ie4? event.clientY : e.clientY

		tempx=parseInt(crossobj.style.left)
		tempy=parseInt(crossobj.style.top)
		
		dragapproved=true
		document.onmousemove=drag_drop2
	}
}


document.onmouseup=new Function("dragapproved=false")
//-->	


