// DViewScript.js
// Update Date: 5/4/2007 10:05:41 AM


// JS Global Variables
var dtCh= "/";
var minYear=1900;
var maxYear=2100;
var imageWin = "";


//***********************************************************//
//**	Script Name: changeCSS
//**	Script Description: Process the user's ability to manage CSS classes
//**	Last Modified: 3/31/2006 2:29:43 PM
//***********************************************************//
function changecss(theClass,element,value,parentWindow) {

 var cssRules;
 if (document.all) {
  cssRules = 'rules';
 }
 else if (document.getElementById) {
  cssRules = 'cssRules';
 }

// create obj to determine if self or parent
var documentLocation;

	if(parentWindow){
		if(parentWindow == true){
			documentLocation = opener.document;
		}else{
			documentLocation = document;
		}
	}else{
		documentLocation = document;
	}


	 for (var S = 0; S < documentLocation.styleSheets.length; S++){
	  for (var R = 0; R < documentLocation.styleSheets[S][cssRules].length; R++) {
	   if (documentLocation.styleSheets[S][cssRules][R].selectorText == theClass) {
	   		if(documentLocation.styleSheets[S][cssRules][R].style[element]){
				documentLocation.styleSheets[S][cssRules][R].style[element] = value;
	   			}
	   }
	  }
	 }	

}



//***********************************************************//
//**	Script Name: ChangeObject
//**	Script Description: Passes the values and changes the current location of the page
//**	Last Modified: 3/31/2006 1:12:58 PM
//***********************************************************//
function ChangeObject (thisOID,thisIDname,thisIDvalue,retVal,OtherArgs){
	var temp = 'adminIndex.asp?OID='+thisOID
	if (thisIDname != undefined && thisIDname != ''){
		temp = temp + '&thisIDname='+thisIDname+'&thisIDvalue='+thisIDvalue
		}
	if (retVal != undefined){
		temp = temp + '&retVal='+retVal
	}
	if (OtherArgs != undefined){
		temp = temp + '&'+OtherArgs
	}
	window.location.href=temp
}



//***********************************************************//
//**	Script Name: ChangesProductPerRow
//**	Script Description: Manages the Newsletter Product Display
//**	Last Modified: 3/31/2006 2:33:57 PM
//***********************************************************//
function ChangeProductsPerRow(selectObj){
	// detremine the current product table width
	// determine the current product image width
	// reset the columns
	
 var cssRules;
 if (document.all) {
  cssRules = 'rules';
 }
 else if (document.getElementById) {
  cssRules = 'cssRules';
 }

// create obj to determine if self or parent
var documentLocation = document;

	
	var ElementArray = new Array(2);
	var ClassArray = new Array(".productTable",".productImage",".productTableContainer");
	ElementArray[".productTable"] = new Array();
	ElementArray[".productImage"] = new Array();
	ElementArray[".productTableContainer"] = new Array();
	var currProducts = document.getElementById('ProductsPerRow').value
	var colPerRow = selectObj.value;
	for (i = 0;i<ClassArray.length;i++){
		for (var S = 0; S < documentLocation.styleSheets.length; S++){
			for (var R = 0; R < documentLocation.styleSheets[S][cssRules].length; R++) {
					if (documentLocation.styleSheets[S][cssRules][R].selectorText == ClassArray[i]) {
						ElementArray[ClassArray[i]]["width"] = documentLocation.styleSheets[S][cssRules][R].style["width"].replace('px','');
						ElementArray[ClassArray[i]]["height"] = documentLocation.styleSheets[S][cssRules][R].style["height"].replace('px','');
						ElementArray[ClassArray[i]]["padding"] = documentLocation.styleSheets[S][cssRules][R].style["padding"].replace('px','');
						ElementArray[ClassArray[i]]["margin"] = documentLocation.styleSheets[S][cssRules][R].style["margin"].replace('px','');
					}
			}
		}
	}


	// determine the new properties to set the item at which percent
	var currProductContainerWidth = ElementArray[".productTableContainer"]["width"]
	if (ElementArray[".productTableContainer"]["padding"]){currProductContainerWidth -= (colPerRow * ElementArray[".productTableContainer"]["padding"] * 2);}
	if (ElementArray[".productTable"]["margin"]){currProductContainerWidth -= (colPerRow * ElementArray[".productTable"]["margin"] * 2);}
	
	var currProductTablePercent = parseFloat(ElementArray[".productTable"]["width"]/ElementArray[".productTableContainer"]["width"])
	var currProductImagePercent = parseFloat(ElementArray[".productImage"]["width"]/ElementArray[".productTableContainer"]["width"]) 
	
	// set the proudct Table style
//	var thisValue = parseFloat(parseInt(ElementArray[".productTableContainer"]["width"]/colPerRow) * parseFloat(currProductTablePercent))
	thisValue = parseInt(currProductContainerWidth/colPerRow) - 100
	changecss(".productTable","width",thisValue)
	// set the product Image Percent
	var thisValue = parseFloat(parseInt(ElementArray[".productTableContainer"]["width"]/colPerRow) * parseFloat(currProductImagePercent))
	//alert(thisValue)
	thisValue = parseInt(currProductContainerWidth/colPerRow)
	changecss(".productImage","width",thisValue)
	

}



//***********************************************************//
//**	Script Name: CheckAll
//**	Script Description: Checks or unchecks all the checkboxes
//**	Last Modified: 3/31/2006 1:27:04 PM
//***********************************************************//
function CheckAll(thisFieldPrefix,TotalRows){
	if (TotalRows){
			for(i=0;i<TotalRows;i++){
				document.getElementById(thisFieldPrefix+i).checked = true
			}
	}else{
		alert("Error -> in code, seek administrator!!!")
	}
}



//***********************************************************//
//**	Script Name: ConfirmDelete
//**	Script Description: Confirms the delete and processes or displays
//**	Last Modified: 3/31/2006 1:12:29 PM
//***********************************************************//
function ConfirmDelete(alertName,thisOID,thisIDname,thisIDvalue,theseArgs){
	if(confirm("Are you sure you want to delete " + alertName + "?") == true){
		// process delete
		var oArgs = ""
		var isMac = navigator.userAgent.indexOf('Mac') != -1 
		
		if (isMac){
			if(oArgs){
				if (oArgs.substring(0,1) != "&"){
					oArgs = "&" + theseArgs
					}else{
					oArgs = theseArgs
				}
			}else{
				oArgs = ""
			}	
		}else if (theseArgs == undefined){
			oArgs = ""
		}else{
			if (oArgs.substring(0,1) != "&"){
				oArgs = "&" + theseArgs
				}else{
				oArgs = theseArgs
			}
		}

		var DeleteWin = window.open('DeleteForm.asp?a='+thisOID+'&b='+thisIDname+'&c='+thisIDvalue+oArgs,'DeleteWin','toolbars=no,width=350,height=250,resizable=yes,status=yes,location=no');
		DeleteWin.focus()
	}
}



//***********************************************************//
//**	Script Name: DisplayForm
//**	Script Description: Newsletter component used to show hash item as form
//**	Last Modified: 4/7/2006 5:45:18 PM
//***********************************************************//
function DisplayForm(ElementHash,ShowThisOne){
	for (var k in ElementHash){
		if (document.getElementById(k)){
			if (k == ShowThisOne){
				document.getElementById(k).style.display='block';
			}else{
				document.getElementById(k).style.display='none';
			}
		}
	}
}



//***********************************************************//
//**	Script Name: DisplayPopUp
//**	Script Description: Displays the popup form
//**	Last Modified: 3/31/2006 1:18:25 PM
//***********************************************************//
function DisplayPopUp(thisFileName,theseArgs,confirmAction,fullSize){
	if ((confirmAction) && (confirm != "-1")){
		if (confirm(confirmAction) == false){
			return false;
		}
	}
			var Args = '?pFn='+thisFileName+'&'+theseArgs
			Args = Args.replace(/&&/g,'&')
			if(fullSize){
				var myPopUp = window.open('/admin/PopUpController.asp'+Args,thisFileName,'fullscreen=yes, scrollbars=yes');
			}else{
				var myPopUp = window.open('/admin/PopUpController.asp'+Args,thisFileName,'toolbar=no,scrollbars=yes,status=yes,location=no,width=300,height=250,resizable=yes');
			}
			myPopUp.focus();
		
}


//***********************************************************//
//**	Script Name: GetColor
//**	Script Description: Displays the popup to return the HEX color
//**	Last Modified: 3/31/2006 2:30:24 PM
//***********************************************************//
function GetColor(thisID){
	var myColor = window.open('/admin/PopUpController.asp?pFn=GetWebSafeColors&ID='+thisID,'WebSafeColors','width=225px,height=400px;resizeable=yes;scrollbars=no,menubar=no,location=no,address=no');
	myColor.focus();
}


//***********************************************************//
//**	Script Name: GetFont
//**	Script Description: Opens the popup to display the Font Helper
//**	Last Modified: 3/31/2006 2:30:03 PM
//***********************************************************//
function GetFont(thisID,CurrentValue){
	var myColor = window.open('/admin/PopUpController.asp?pFn=WebSafeFonts&ID='+thisID+'&Val='+CurrentValue,'WebSafeFonts','width=400px,height=225px;resizeable=yes;scrollbars=no,menubar=no,location=no,address=no,resizable=yes');
	myColor.focus();
}


//***********************************************************//
//**	Script Name: GetStylesFromParent
//**	Script Description: Parses the styles from the parent
//**	Last Modified: 3/31/2006 2:27:58 PM
//***********************************************************//
function GetStylesFromParent(thisData){
// obtain the styles from the passed data and return string
var retVal = thisData.substring(thisData.indexOf('<STYLE>')+7,thisData.indexOf('</STYLE>')-thisData.indexOf('<STYLE>'))
retVal = retVal.replace(/(\n|\r|\f|\t)/g,' ')
retVal = retVal.replace(/\"/g,'&quot;')
return retVal
}


//***********************************************************//
//**	Script Name: handleEnter
//**	Script Description: Handles the Enter Key when pressed by the user
//**	Last Modified: 3/31/2006 1:33:39 PM
//***********************************************************//
function handleEnter (field, event) {
		var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
		if (keyCode == 13) {
			var i;
			for (i = 0; i < field.form.elements.length; i++)
				if (field == field.form.elements[i])
					break;
			i = (i + 1) % field.form.elements.length;
			field.form.elements[i].focus();
			return false;
		} 
		else
		return true;
	}      



//***********************************************************//
//**	Script Name: HandlePassword
//**	Script Description: Outdated -- used to verify password
//**	Last Modified: 3/31/2006 1:09:02 PM
//***********************************************************//
function HandlePassword(thisField){
	if (thisField.value == ""){
		return;
	}else if (thisField.value.length < 6){
		alert("Password must be greater then 6 characters")
		thisField.value = ""
		thisField.focus();
	}else if (thisField.value.length > 12){
		alert("Password cannot be greater then 12 characters")
		thisField.value = ""
		thisField.focus();
	}else if (thisField.value != "**********"){
		var x = window.showModalDialog("code/PopUp/checkPassword.asp","","dialogHeight:100px;dialogWidth:300px;center:yes;resizable:no;status:no;");
		if (x != thisField.value){
			alert("Passwords do not match")
			thisField.value = ""
			thisField.focus();
		}
	}
}


//***********************************************************//
//**	Script Name: HideAndSeek
//**	Script Description: Hides all and displays selected
//**	Last Modified: 3/31/2006 1:28:55 PM
//***********************************************************//
function HideAndSeek(thisElement,thisSeek,thisTotal){

	// if thisTotal is empty find total by TotalRows
	if (thisTotal){
		var thisCount = parseInt(thisTotal) + 1
	}else{
		if (document.getElementById('TotalRows')){
			var thisCount = document.getElementById('TotalRows').value
		}else{
			alert('No Count was passed and Total Rows could not be found')
			return;
		}
	}
		

	// hide
		for(i=0;i<thisCount;i++){
			if (document.getElementById(thisElement+i)){
					var thisItem = document.getElementById(thisElement+i)
					if (thisSeek != -1){
						if (i == thisSeek){
							thisItem.style.display = 'block'
						}else{
							thisItem.style.display = 'none'
						}
					}else{
						thisItem.style.display = 'none';
					}
				}else{
				// do nothing 
				window.status = "error - unable to find " + thisElement+i
			}
		}

}



//***********************************************************//
//**	Script Name: isCurrency
//**	Script Description: Validates if the value is currency
//**	Last Modified: 3/31/2006 1:11:10 PM
//***********************************************************//
function isCurrency(thisVal){
	var temp = thisVal.replace(/\$/g,'')
	for(i=0;i<temp.length;i++){
		var zchar = temp.charCodeAt(i)
		if ((zchar <  47 || zchar > 58) && zchar != 46){
			alert("Please enter only numbers and one decimal point")
			return "";
		} 
	}
	
	return temp;
}



//***********************************************************//
//**	Script Name: isDate
//**	Script Description: Validates if the value is a date
//**	Last Modified: 3/31/2006 1:11:38 PM
//***********************************************************//
function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : mm/dd/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date")
		return false
	}
return true
}



//***********************************************************//
//**	Script Name: isEmail
//**	Script Description: Validates if the string is an email
//**	Last Modified: 3/31/2006 1:07:49 PM
//***********************************************************//
function isEmail(thisVal){
	// number of characters before @
		var at="@"
		var dot="."
		var str = thisVal
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid Email Address")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid Email Address")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid Email Address")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid Email Address")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid Email Address")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid Email Address")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid Email Address")
		    return false
		 }

 		 return true				


}



//***********************************************************//
//**	Script Name: isInteger
//**	Script Description: returns true or false based on if the variables is an integer
//**	Last Modified: 3/31/2006 1:05:03 PM
//***********************************************************//
function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}



//***********************************************************//
//**	Script Name: isPhone
//**	Script Description: Determines if the value is a phone number
//**	Last Modified: 3/31/2006 1:09:34 PM
//***********************************************************//
function isPhone(thisVal){
	var temp = "";
	var thisTemp = "";
	thisTemp = thisVal.replace(/\(/g,'')
	thisTemp = thisTemp.replace(/\)/g,'')
	thisTemp = thisTemp.replace(/\s/g,'')
	thisTemp = thisTemp.replace(/\-/g,'')
	for(i=0;i<thisTemp.length;i++){
	
		var zchar = thisTemp.charAt(i)
		var charInt = thisTemp.charCodeAt(i)
		if (charInt <  47 || charInt > 58){
			alert("Please enter only numbers or '(' '-'")
			return "";
			break;	
		}
	
		
		if (temp.length == 0){
			temp = "(" + zchar
		}else if (temp.length == 4){
			temp = temp + ') ' + zchar
		}else if (temp.length == 9){
			temp = temp + '-' + zchar
		}else if (temp.length > 13){
		alert("Phone # cannot be larger than (000)-000-0000")
		return "";
		}
		else{
			temp = temp + zchar
		}
		
		
	}

	return temp;

}


//***********************************************************//
//**	Script Name: isSSN
//**	Script Description: Validates if the values is SSN
//**	Last Modified: 3/31/2006 1:10:00 PM
//***********************************************************//
function isSSN(thisVal){
	if (thisVal.length == 11 && thisVal.indexOf('-') == 3){
		return thisVal;
	}else if (thisVal.length >= 11){
		alert("Social Security # must be formatted 000-00-0000")
		return "";
	}else if (thisVal.length < 9){
		alert("Social Security # must be formatted 000-00-0000")
		return "";
	} else {
			
		var temp = "";
		for(i=0;i<thisVal.length;i++){
			var zchar = thisVal.charCodeAt(i)
				if ((zchar <  47 || zchar > 58) && zchar != 45){
					alert("Social Security # can only contain numbers and '-'")
					thisVal = ""
					return thisVal;
					break;
					} else {
						if (temp.length == 3){
							temp = temp + "-" + thisVal.charAt(i)
						}else if (temp.length == 6){
							temp = temp + "-" + thisVal.charAt(i)
						}else{
							temp = temp + thisVal.charAt(i)
						}
				}
					
			
		}
	if (temp != ""){
				return temp;
			}
	
	} 
	
}



//***********************************************************//
//**	Script Name: isWebsite
//**	Script Description: Validates if the string is a website
//**	Last Modified: 3/31/2006 1:07:31 PM
//***********************************************************//
function isWebsite(thisVal){
	if (thisVal.substring(0,7) != "http://"){
		alert("Prefix the website with http://")
		return "";
	}else{
		return thisVal;
	}
}


//***********************************************************//
//**	Script Name: isZipCode
//**	Script Description: Valdiates if the value is a zip code
//**	Last Modified: 4/13/2006 1:42:27 PM
//***********************************************************//
function isZipCode(thisVal){

	for(i=0;i<thisVal.length;i++){
		var zchar = thisVal.charCodeAt(i)
			if ((zchar < 47 || zchar > 58) && zchar != 45){
				alert("Zip Code can only contain numbers and '-'")
				thisVal = "00000"
				return thisVal;
				break;
			}
	} 

	if(thisVal.length == 5){
		return thisVal;
	} else if (thisVal.length == 9 && thisVal.indexOf("-") != 4){
		return thisVal.substr(0,5) + "-" + thisVal.substr(6,9); 
	} else{
	
		if (thisVal.length < 5){
			alert("Zip Codes must be at least five characters in length")
			return "00000";
		} else if (thisVal.length < 10){
			var temp = thisVal.substr(0,5)
			temp = temp + "-0000"
			return temp;
		} else if (thisVal.length > 10){
			var temp = thisVal.substr(0,5) + "-" + thisVal.substr(6,9)
			return temp;
		} else {
			return thisVal;
		}

	}		
}


//***********************************************************//
//**	Script Name: jDatemanagement
//**	Script Description: Creates an array and displays it as selectbox options
//**	Last Modified: 5/25/2006 4:21:16 PM
//***********************************************************//
function jsDataManagement(thisData,thisType,thisName){
	if (thisData != undefined){
		if(thisData == 'GetCountry'){
			document.writeln(GetCountryOption());
		}else{
		var tempArray = thisData.split(",")
			for(i=0;i<tempArray.length;i++){
				if (thisType == "Select"){
					document.writeln ('<option value="' + tempArray[i] + '">'+tempArray[i]+'</option>')
				}else if(thisType == "Radio"){
					document.writeln ('<input type=radio name="'+thisName+'" id="'+thisName+'" value="'+tempArray[i]+'"> ' + tempArray[i]) 
				}
			}
		}
	}

}



//***********************************************************//
//**	Script Name: NoSpaces
//**	Script Description: Removes spaces from a textbox
//**	Last Modified: 3/31/2006 1:25:54 PM
//***********************************************************//
function NoSpaces(thisField){
var retVal = ""
var x = thisField.value
	for(i=0;i<x.length;i++){
		if(x.charCodeAt(i) != 32){
			retVal = retVal + x.charAt(i)
		}
	}
	thisField.value = retVal
}



//***********************************************************//
//**	Script Name: parseStyleInputType
//**	Script Description: Manages the different input types for the Class User Interface
//**	Last Modified: 3/31/2006 2:30:57 PM
//***********************************************************//
function parseStyleInputType(ElementName,thisInputType,thisValue){
	if (thisInputType == ''){
		return false;
	}else if(!StyleInputArray[thisInputType]){
		return false;
	}

	var currentObject = StyleInputArray[thisInputType]
	var thisType = currentObject['InputType']
	var thisNumericField = currentObject['NumericField']
	var thisMaxLength = currentObject['MaxLength']
	var thisInputSize = currentObject['thisInputSize']
	var thisExtraData = currentObject['ExtraData']
	
	if(thisType == 'GetColor'){
		document.writeln('<input type=text name="'+ElementName+'_'+thisInputType+'" id="'+ElementName+'_'+thisInputType+'" size="15" maxlength="7" value="'+thisValue.replace('"','"')+'"> <input type=button name=cmdAction value="Get Color" class=formButton onClick="GetColor('+unescape('%27')+ElementName+'_'+thisInputType+unescape('%27')+');">');
	}else if(thisType == 'GetFont'){
		document.writeln('<input type=text name="'+ElementName+'_'+thisInputType+'" id="'+ElementName+'_'+thisInputType+'" size="25" maxlength="25" value="'+thisValue.replace('"','"')+'"> <input type=button name=cmdAction value="Get Font" class=formButton onClick="GetFont('+unescape('%27')+ElementName+'_'+thisInputType+unescape('%27')+',document.getElementById('+unescape('%27')+ElementName+'_'+thisInputType+unescape('%27')+').value);">');
	}else if(thisType == 'Textbox'){
		document.writeln('<input type=text name="'+ElementName+'_'+thisInputType+'" id="'+ElementName+'_'+thisInputType+'" size="'+thisInputSize+'" maxlength="'+thisMaxLength+'" value="'+thisValue.replace('"','"')+'">');
	}else if(thisType == 'Select'){
		document.writeln('<select name="'+ElementName+'_'+thisInputType+'" id="'+ElementName+'_'+thisInputType+'">\n');
		var tempArray = thisExtraData.split(";")
		for(zItem=0;zItem<tempArray.length;zItem++){
			if (thisValue == tempArray[i]){
				document.writeln('<option value="'+tempArray[zItem]+'" selected>'+tempArray[zItem]+'</option>\n');		
			}else{
				document.writeln('<option value="'+tempArray[zItem]+'">'+tempArray[zItem]+'</option>\n');		
			}
		}
		document.writeln('</select>');
	}else if(thisType == 'Border'){
		var thisSize = Trim(thisValue.substring(0,thisValue.indexOf(' ')))
		var thisBorder = thisValue.substring(thisValue.indexOf(' ')+1,thisValue.length)
		thisBorder = Trim(thisBorder.substring(0,thisBorder.indexOf(' ')))
		var thisColor = Trim(thisValue.substring(thisValue.length,9))
		// display size
		document.writeln('<input type=text name="'+ElementName+'_'+thisInputType+'_size" id="'+ElementName+'_'+thisInputType+'_size" size="6" maxlength="4" value="'+thisSize+'" onBlur="UpdateComplexCSS('+unescape('%27')+ElementName+'_'+thisInputType+unescape('%27')+','+unescape('%27')+'size,border,color'+unescape('%27')+');">');
		// display border
		document.writeln('<select name="'+ElementName+'_'+thisInputType+'_border" id="'+ElementName+'_'+thisInputType+'_border" onChange="UpdateComplexCSS('+unescape('%27')+ElementName+'_'+thisInputType+unescape('%27')+','+unescape('%27')+'size,border,color'+unescape('%27')+');">\n');
		var tempArray = thisExtraData.split(";")
		for(zItem=0;zItem<tempArray.length;zItem++){
			if (thisBorder == tempArray[zItem]){
				document.writeln('<option value="'+tempArray[zItem]+'" selected>'+tempArray[zItem]+'</option>\n');		
			}else{
				document.writeln('<option value="'+tempArray[zItem]+'">'+tempArray[zItem]+'</option>\n');		
			}
		}
		document.writeln('</select>');
		// display color
		document.writeln('<input type=text name="'+ElementName+'_'+thisInputType+'_color" id="'+ElementName+'_'+thisInputType+'_color" size="8" maxlength="7" value="'+thisColor+'" onBlur="UpdateComplexCSS('+unescape('%27')+ElementName+'_'+thisInputType+unescape('%27')+','+unescape('%27')+'size,border,color'+unescape('%27')+');"> <input type=button name=cmdAction value="Get Color" class=formButton onClick="GetColor('+unescape('%27')+ElementName+'_'+thisInputType+'_color'+unescape('%27')+');">');
		document.writeln('<input type=hidden name="'+ElementName+'_'+thisInputType+'" id="'+ElementName+'_'+thisInputType+'" value="'+thisValue+'">\n');
		
	}


}


//***********************************************************//
//**	Script Name: parseStyleValue
//**	Script Description: Creates the input and manages the value
//**	Last Modified: 3/31/2006 2:31:35 PM
//***********************************************************//
function parseStyleValue(ElementName,thisValue){
// parse the following style elements
// font-family, font-size, font-weight,color
var ItemList = "font-family,font-size,font-weight,color,background-color,border,padding,text-align";
thisValue = thisValue.toLowerCase();
var myArray = thisValue.split(';');
var foundItem = false;
for(i=0;i<myArray.length;i++){
	
	var thisName = Trim(myArray[i].substring(0,myArray[i].indexOf(':')));
	var thisValue = Trim(myArray[i].substring(myArray[i].indexOf(':')+1,myArray[i].length));

	if(ItemList.indexOf(thisName) > -1){
		foundItem = true
		document.writeln('<tr>');
		document.writeln('<td style="width:100px;font-weight:bold;font-size:12px;" valign=top>'+thisName+'</td>');
		document.writeln('<td valign=top>');
		parseStyleInputType(ElementName,thisName,thisValue);
		document.writeln('</td>')
		document.writeln('</tr>');
	}		
}

	// hide any items that do not contain items
	if(foundItem == false){
		if(document.getElementById('Menu_'+ElementName)){
			document.getElementById('Menu_'+ElementName).style.display='none';
		}
	}
		

}



//***********************************************************//
//**	Script Name: PreviewFile
//**	Script Description: Displays a file in a new window
//**	Last Modified: 3/31/2006 1:31:19 PM
//***********************************************************//
function PreviewFile(thisFileName){
	var thisFile = window.open(thisFileName,'thisFile','resizable=yes,width=600,height=600,toolbars=yes,scrollbars=yes,status=yes');
	thisFile.focus();
}


//***********************************************************//
//**	Script Name: PreviewImage
//**	Script Description: On Click will preview image in new window
//**	Last Modified: 6/16/2006 9:32:10 AM
//***********************************************************//
function PreviewImage(thisPath){
	if (!thisPath){
		return false;
	}else if(thisPath == 'pub/images/noimage.gif'){
		return false;
	}
	
	if (imageWin){
		imageWin.close()
	}
	// opens a window and writes to the document
	imageWin = window.open('','imageWin','toolbars=no,resizable=yes,scrollbars=yes,status=no,location=no')
	imageWin.document.writeln('<p></p><input type=button name=cmdAction style="color:#FFFFFF;font-family:arial;font-size:12px;color:#00000;border:1px solid #CCCCC;" value="Close" onClick="window.close();""><BR>')
	imageWin.document.writeln('<img src="'+thisPath+'" id=thisImage name=thisImage>')
	imageWin.document.writeln('<p></p><input type=button name=cmdAction style="color:#FFFFFF;font-family:arial;font-size:12px;color:#00000;border:1px solid #CCCCC;" value="Close" onClick="window.close();"">')
	imageWin.document.writeln(unescape('%3C') + 'script>\n')
	imageWin.document.writeln('var thisH = thisImage.height\n')
	imageWin.document.writeln('var thisW = thisImage.width\n')
	imageWin.document.writeln('if(thisW > 600){\n')
	imageWin.document.writeln('thisImage.height = parseInt((thisH * 600)/thisW)\n')
	imageWin.document.writeln('thisImage.width = 600;\n')
	imageWin.document.writeln('}\n')
	imageWin.document.writeln('window.resizeTo(thisImage.width+100,thisImage.height+100)\n'+unescape('%3C')+'/script>')
	imageWin.focus();

}



//***********************************************************//
//**	Script Name: ProcessHyperlink
//**	Script Description: Used in conjunction with the PopUp Get Hyperlink
//**	Last Modified: 3/31/2006 1:30:58 PM
//***********************************************************//
function ProcessHyperLink(){
	var thisLinkType = document.getElementById('LinkType').value
	var retVal = "";
	
	if (thisLinkType == 'Internal'){
		var thisInternalType = document.getElementById('InternalLinkType').value
		
		if (thisInternalType == 'Page'){
			var thisValue = document.getElementById(InternalPage).value
			var thisText = document.getElementById(InternalPageText).value
			var thisTarget = document.getElementById(InternalPageTarget).value
			
		}else if (thisInternalType == 'Image'){
			var thisText = document.getElementById(InternalImageText).value
			var thisTarget = document.getElementById(InternalImageTarget).value
			var thisValue = document.getElementById(InternalImagePath).value
			
		}else if (thisInternalType == 'File'){
			var thisText = document.getElementById(InternalFileText).value
			var thisTarget = document.getElementById(InternalFileTarget).value
			var thisValue = document.getElementById(InternalFilePath).value
			
		}else{
			alert('Please select an Internal Link Type')
			return false;
		}

		
		
	}else if (thisLinkType == 'External'){
		ExternalUrl
		ExternalText
		ExternalTarget


	}else{

		alert('Please select a Link Type');
		return false;
	}

}



//***********************************************************//
//**	Script Name: ProcessMCheckbox
//**	Script Description: Updates the Checkbox value
//**	Last Modified: 3/31/2006 1:26:23 PM
//***********************************************************//
function ProcessMCheckbox(thisVal, ColumnName,thisData){
	if (document.getElementById(ColumnName)){
		var thisField = document.getElementById(ColumnName)
		if (thisVal == true){			// add 
			thisField.value = thisField.value + ',' + thisData				
		}else if (thisVal == false){			// remove
			thisField.value = thisField.value.replace(','+thisData,'')
		}
	}else{
		alert("Error incorrect setup of Multiple Checkbox field")
	}

}



//***********************************************************//
//**	Script Name: returnHyperlink
//**	Script Description: Returns the V2.0 Hyperlink
//**	Last Modified: 5/23/2006 10:48:41 AM
//***********************************************************//
function returnHyperLink(){
		var retVal = "";

		if (document.getElementById('ExternalLink').style.display == "block"){
			// process external link
			var myExternalUrl = document.getElementById('ExternalUrl')
			var myExternalText = document.getElementById('ExternalText')
			var myExternalTarget = document.getElementById('ExternalTarget')
			// validation
			if (myExternalUrl.value == ""){
				alert("Please enter the Url")
				myExternalUrl.focus();
				return false;
			}else if(myExternalText.value == ""){
				alert("Please enter text for the link")
				myExternalText.focus();
				return false;
			}
			
			if (myExternalTarget.value == "ajax"){
				retVal = '<a href="javascript:void(0)" onClick="go('+unescape('%27')+myExternalUrl.value+unescape('%27')+'");">'+myExternalText.value+'</a>'
			}else{
				// create the link
				retVal = '<a href="'+myExternalUrl.value+'" target="'+myExternalTarget.value+'">'+myExternalText.value+'</a>'
			}

		}else if (document.getElementById('InternalLink').style.display == "block"){

			if (document.getElementById('Internal0').style.display == "block"){ // Select Page
				var myInternalPage =  document.getElementById('InternalPage')
				var myInternalPageText = document.getElementById('InternalPageText')
				var myInternalPageTarget = document.getElementById('InternalPageTarget')
				var myPagePrefix = document.getElementById('PagePrefix');
				var myPageType = document.getElementById('PageType');
				
				// validation
				if (myInternalPage.value == 0){
					alert("Please select a Page")
					//myInternalPage.focus();
					return false;
				}else if(myInternalPageText.value == ""){
					alert("Please enter link text")
					//myInternalPageText.focus();
					return false;
				}

				if (myInternalPageTarget.value == "ajax"){
					retVal = '<a href="javascript:void(0);" onClick="go('+unescape('%27')+'/admin/adminApp.asp?OID='+myInternalPage.value+'&PageType='+myPageType.value+unescape('%27')+');">'+myInternalPageText.value+'</a>'			
				}else{
					var rootURL = '';

					if(document.getElementById('xPageType')){
						if(document.getElementById('xPageType').value == 'AdminPage'){
							rootURL = '/admin/adminIndex.asp?';
						}else{
							rootURL = '/index.asp?';
						}
					}else{
						rootURL = '/index.asp?';
					}
					// create string
					retVal = '<a href="'+rootURL+'OID='+myInternalPage.value+'&PageType=Page" target="'+myInternalPageTarget.value+'">'+myInternalPageText.value+'</a>'
				}

			}else if (document.getElementById('Internal1').style.display == "block"){ // Select Image
				var myInternalImageText = document.getElementById('InternalImageText')
				var myInternalImageTarget = document.getElementById('InternalImageTarget')
				var myInternalImagePath = document.getElementById('InternalImagePath')

				if (myInternalImageText.value == ""){
					alert("Please enter text for the link")
					myInternalImageText.focus();
					return false;
				}else if(myInternalImagePath.src == ""){
					alert("Please select an image from the list")
					myInternalImagePath.focus();
					return false;
				}
			
			// create string
			retVal = '<a href="'+myInternalImagePath.src.substring(myInternalImagePath.src.indexOf('/pub/images'),myInternalImagePath.src.length)+'" target="'+myInternalImageTarget.value+'">'+myInternalImageText.value+'</a>'

			}else if (document.getElementById('Internal2').style.display == "block"){ // Select File
				var myInternalFileText = document.getElementById('InternalFileText')
				var myInternalFileTarget =  document.getElementById('InternalFileTarget')
				var myInternalFilePath	 = document.getElementById('InternalFilePath')	
		
				if (myInternalFileText.value == ""){
					alert("Please enter text for the link")
					myInternalFileText.focus();
					return false;
				}else if(myInternalFilePath.innerHTML == ""){
					alert("Please select a file from the list")
					myInternalFilePath.focus();
					return false;
				}
				
			// create string
			retVal = '<a href="/pub/files/'+myInternalFilePath.innerHTML+'" target="'+myInternalFileTarget.value+'">'+myInternalFileText.value+'</a>'
			
			} // end internal selection
		}
		returnValue = retVal
		window.close();
}



//***********************************************************//
//**	Script Name: ShowFAQ
//**	Script Description: Hides and displays FAQ
//**	Last Modified: 3/31/2006 1:31:43 PM
//***********************************************************//
function ShowFAQ(thisName){
	if(document.getElementById(thisName)){
		if (document.getElementById(thisName).style.display == 'block'){
			document.getElementById(thisName).style.display = 'none'
		}else{
			document.getElementById(thisName).style.display = 'block'
		}
	}
}


//***********************************************************//
//**	Script Name: ShowForm
//**	Script Description: Displays the show form
//**	Last Modified: 8/2/2006 1:21:10 PM
//***********************************************************//
function ShowForm(thisAction,thisOID,thisIDname,thisIDvalue,OtherArgs,ShowPrefix){
		
	var oArgs = OtherArgs
	var isMac = navigator.userAgent.indexOf('Mac') != -1 
	var formName = 'ShowForm';
	
	if (isMac){
		if (oArgs){
			if(oArgs.substring(1,1) != "&"){
				oArgs = '&'+oArgs
			}
		}else{
			oArgs = ''
		}	
	}else{
		if ((oArgs != undefined) && (oArgs != '')){
			if(oArgs.substring(1,1) != "&"){
			oArgs = '&'+oArgs
			}
		}else{
			oArgs = ''
		}
	}
	
	if(oArgs){
		if(oArgs.indexOf('return=true') > -1){
			formName = 'ShowFormNew'
		}
	}
	
	if (ShowPrefix){
		var myShowForm = window.open('Show'+ShowPrefix+'Form.asp?a='+thisAction+'&b='+thisOID+'&c='+thisIDname+'&d='+thisIDvalue+oArgs,formName,'toolbars=no,scrollbars=yes,status=yes,location=no,width=600,height=575,resizable=yes,left=10,top=10');
		myShowForm.focus();
		}else{
		var myShowForm = window.open('ShowForm.asp?a='+thisAction+'&b='+thisOID+'&c='+thisIDname+'&d='+thisIDvalue+oArgs,formName,'toolbars=no,scrollbars=yes,status=yes,location=no,width=600,height=575,resizable=yes,left=10,top=10');
		myShowForm.focus();
	}

}


//***********************************************************//
//**	Script Name: ShowHiddenItem
//**	Script Description: Displays a hidden item
//**	Last Modified: 3/31/2006 1:32:03 PM
//***********************************************************//
function ShowHiddenItem(thisField){
	if ((thisField != undefined) && (thisField != '')){
		if(document.getElementById(thisField)){
			if (document.getElementById(thisField).className == "hiddenInput"){
				document.getElementById(thisField).className = "pageContent";
			}else if(document.getElementById(thisField).className == "pageContent"){
				document.getElementById(thisField).className= "hiddenInput";
			}
		}
	}
}



//***********************************************************//
//**	Script Name: ShowMailMerge()
//**	Script Description: displays mail merge information
//**	Last Modified: 11/13/2006 1:57:18 PM
//***********************************************************//
function ShowMailMerge(){
	var mailMerge = window.open('','MailMerge','width=400,height=200,scrollbars=no,location=no,resizable=no');
	mailMerge.document.writeln('<title>Mail Merge Features</title>');
	mailMerge.document.writeln('<body style="margin:5px;font-family:arial;font-size:12px;padding:5px;border:1px solid #000000;">');
	mailMerge.document.writeln('<h3 style="border-bottom:1px solid #000000;">Mail Merge Options:</h3>');
	mailMerge.document.writeln('<h5 style="font-size:12px;font-weight:normal;"><b>[Name]</b> - will replace with the name or email address of recipient</h5>');
	mailMerge.document.writeln('<h5 style="font-size:12px;font-weight:normal;"><b>[Email]</b> - will replace with the email address of the recipients</h5>');
	mailMerge.document.writeln('<h6 style="border-top:1px solid #000000;">*If no name is present the email address is used<BR>**Please note, these are case sensitive and must include hard brackets</h6>');
	mailMerge.document.writeln('<input type=button name=cmdAction value=Close id=cmdAction onClick="window.close();">');
	mailMerge.document.writeln('</body>');
	mailMerge.focus();
}



//***********************************************************//
//**	Script Name: ShowPortfolio
//**	Script Description: Displays the ShowPortfolio form
//**	Last Modified: 3/31/2006 1:32:56 PM
//***********************************************************//
function ShowPortfolio(thisUsername){
	if (thisUsername != ""){
		thisUsername = "p=" + thisUsername
	}else{
//		thisUsername = "p=" + window.status.substring(14,window.status.length)
	}

	var myPortfolio = window.open('/admin/ShowPortfolio.asp?'+thisUsername,'myPortfolioView','width=825,height=600,scrollbars=yes,status=yes,location=yes,address=no,toolbar=yes,resizable=yes');
	myPortfolio.focus();

}



//***********************************************************//
//**	Script Name: ShowThisHideThat
//**	Script Description: Shows one item and hides the other items
//**	Last Modified: 3/31/2006 1:33:18 PM
//***********************************************************//
function ShowThisHideThat(showMe,hideMe){
	
	if (document.getElementById(showMe)){
		//document.getElementById(showMe).style.display='block';
		//document.getElementById(showMe).style.visibility='visible';
		document.getElementById(showMe).style.display='inline';
		document.getElementById(showMe).style.visibility='visible';
	}
	
	if (document.getElementById(hideMe)){
		document.getElementById(hideMe).style.display='none';
		//document.getElementById(hideMe).style.display='hidden';
	}
}



//***********************************************************//
//**	Script Name: Textbox Dropdown Collection
//**	Script Description: Manages the different aspects of the textbox dropdown
//**	Last Modified: 3/31/2006 2:37:05 PM
//***********************************************************//
function ReturnWordMatchDropDown(thisObj,ArrayLookUp,ArraySetTitle){
	var iKeyCode = event.keyCode

	if(iKeyCode == 38){
		SelectDIVItem("Up","SearchResults",ArrayLookUp)
		return true;
	}else if(iKeyCode == 40){
		SelectDIVItem("Down","SearchResults",ArrayLookUp)
		return true;
	}else if(iKeyCode == 13){
		EnterDIVItem(thisObj.id,"SearchResults",ArrayLookUp);
		return true;
	}else if (iKeyCode < 32 || (iKeyCode >= 33 && iKeyCode <= 46) || (iKeyCode >= 112 && iKeyCode <= 123)) {
		return true;
	}
	
	// determine the current length
	currLength = thisObj.value.length
	var currValue = thisObj.value.toLowerCase()
	if (currLength == 0){return true;} // quit if no length passed
	for(i=currLocation;i<ArrayLookUp.length;i++){
		if(ArrayLookUp[i].toLowerCase().substring(0,currLength) ==  currValue){
			currLocation = i
			break;
		}else{
			currLocation = -1
		}
	}
	
	if(currLocation == -1){
		currLocation = 0
		document.getElementById('SearchResults').innerHTML = ""
		document.getElementById('SearchResults').style.display='none';
		return true;
	}
	
	// set the current value = to this obj value
	thisObj.value = ArrayLookUp[i].substring(0,ArrayLookUp[i].length)
	var oRange = thisObj.createTextRange();
	oRange.moveStart("character", currLength);
	oRange.moveEnd("character", thisObj.value.length);
	oRange.select();
	thisObj.focus();
	
	// display the remaining items in the div tag
	var divHTML = ""
	for(i=currLocation+1;i<ArrayLookUp.length;i++){
		if(ArrayLookUp[i].toLowerCase().substring(0,currLength) == currValue){
			divHTML = divHTML + "<label tabIndex=0 id=suggestItem"+i+" onClick=Pass2textbox('"+ArrayLookUp[i]+"','"+thisObj.id+"','SearchResults');>"+ArrayLookUp[i]+"</label><BR>" 
		}else{
			if (divHTML != ""){
				document.getElementById('SearchResults').innerHTML = divHTML
				document.getElementById('SearchResults').style.display='block';
				}else{
				document.getElementById('SearchResults').innerHTML = ""
				document.getElementById('SearchResults').style.display="none";
				}
			break;
		}
	}
	
	// if here and divHTML is != '' then display
		if (divHTML != ""){
			document.getElementById('SearchResults').innerHTML = divHTML
			document.getElementById('SearchResults').style.display='block';
		}else{
			document.getElementById('SearchResults').innerHTML = ""
			document.getElementById('SearchResults').style.display='none';
		}	
	
}

	

function Pass2textbox(thisValue,thisObjName,thisDIV){
	if (thisValue != ""){
		document.getElementById(thisObjName).value = thisValue;
		document.getElementById(thisDIV).style.display='none';
		document.getElementById(thisObjName).focus()
	}
}

function EnterDIVItem(objName,DIVName,ArrayLookUp){
	for(i=parseFloat(currLocation+1);i<ArrayLookUp.length;i++){
		if(document.getElementById('suggestItem'+i)){
			if(document.getElementById('suggestItem'+i).style.background == "#ffffff"){
				document.getElementById(objName).value = document.getElementById('suggestItem'+i).innerHTML
				document.getElementById(DIVName).innerHTML = ""
				document.getElementById(DIVName).style.display='none';
			}
		}
	}
}


function SelectDIVItem(MoveType,DIVName,ArrayLookUp){
	var divObj = document.getElementById(DIVName)
	if(divObj.style.display == 'none'){return false;}
	
	var currItem = -1
	// determine current item
	for(i=parseFloat(currLocation+1);i<ArrayLookUp.length;i++){
		if(document.getElementById('suggestItem'+i)){
			if(document.getElementById('suggestItem'+i).style.background == "#ffffff"){
				currItem = i;
				break;
			}
		}
	}
	

	if(MoveType == "Up"){
		if (currItem == -1){return false;}
		if(parseFloat(currItem-1) == 0){return false;}
		// if current item equals currLocation
		document.getElementById('suggestItem'+parseFloat(currItem - 1)).style.background = "#ffffff";
		document.getElementById('suggestItem'+currItem).style.background = "#336699";


	}else{
		if(parseFloat(currItem+1) == ArrayLookUp.length){return false;}
		// move item down
		if(currItem == -1){
			document.getElementById('suggestItem'+parseFloat(currLocation+1)).style.background = '#FFFFFF';
		}else{
			document.getElementById('suggestItem'+parseFloat(currItem + 1)).style.background = "#ffffff";
			document.getElementById('suggestItem'+currItem).style.background = "#336699";
		}
	}

}


//***********************************************************//
//**	Script Name: Trim
//**	Script Description: Removes whitespace from left and right of string
//**	Last Modified: 3/31/2006 2:31:57 PM
//***********************************************************//
function Trim(str){	while(str.charAt(0) == (" ") )	{	str = str.substring(1);	}	while(str.charAt(str.length-1) == " " )	{	str = str.substring(0,str.length-1);	}	return str;}



//***********************************************************//
//**	Script Name: UpdateComplexCSS
//**	Script Description: Handles Style Management for 2 or more variable properties
//**	Last Modified: 3/31/2006 2:28:46 PM
//***********************************************************//
function UpdateComplexCSS(hiddenElement,ElementParts){
    var retVal = "";
    var tempArray = ElementParts.split(',')
    for(i=0;i<tempArray.length;i++){
       tempArray[i] = Trim(tempArray[i])
        if(document.getElementById(hiddenElement+'_'+tempArray[i])){
            if(retVal != ""){
                retVal = retVal + ' '
            }
            retVal = retVal + document.getElementById(hiddenElement+'_'+tempArray[i]).value
        }
    }
    if(document.getElementById(hiddenElement)){
        document.getElementById(hiddenElement).value = retVal
    }

}


//***********************************************************//
//**	Script Name: UpdateCSSClass
//**	Script Description: Manages the CSS Class user interface
//**	Last Modified: 3/31/2006 2:29:14 PM
//***********************************************************//
function UpdateCSSClass(StyleArray,FormName){
// this function will loop through the hash and determine which element is visibile
// then it will determine the elements of the current form and update the css classes
var currForm = "";
var currFormNameLength = 0;

for(var k in StyleArray){
	if (document.getElementById(k)){
		if(document.getElementById(k).style.display=='block'){
			currForm = k
		}
	}
}

currFormNameLength = currForm.length;

// process each element prefixed with currForm
var FormContainer = document.getElementById(FormName)
var ElementArray = FormContainer.elements
var ClassProperty = "";
var ClassValue = "";
var midChar = "";


for(i=0;i<FormContainer.length;i++){
	if(FormContainer.elements[i].id.substring(0,currFormNameLength)==currForm){
		// determine class property
		ClassProperty = Trim(FormContainer.elements[i].id.substring(parseFloat(currFormNameLength+1),FormContainer.elements[i].id.length))
		// determine if '-' exists, if so, remove each, and uppercase the following left
	//	alert(ClassProperty)
		if(ClassProperty.indexOf('-') > -1){
		//	while(ClassProperty.indexOf('-') > 0){
				midChar = ClassProperty.substring(ClassProperty.indexOf('-')+1,ClassProperty.length)
				midChar = midChar.substring(0,1).toUpperCase()
				ClassProperty = ClassProperty.substring(0,ClassProperty.indexOf('-')) + midChar + ClassProperty.substring(parseFloat(ClassProperty.indexOf('-')+2),ClassProperty.length)
		//	}
		}
		// determine class value
		ClassValue = FormContainer.elements[i].value
		// change values
		changecss("."+currForm,ClassProperty,ClassValue,true)
	}
}



alert('Successfully updated');

}


//***********************************************************//
//**	Script Name: ValidateAllZipCode
//**	Script Description: Validates Zip Code by Country
//**	Last Modified: 3/31/2006 2:49:56 PM
//***********************************************************//

function ValidateAllZipCode(thisfield,thisCountry){

	if(thisfield.value == ""){
		return true;
	}

	if(thisCountry){
		if((thisCountry.toUpperCase() == "US") || (thisCountry.toUpperCase() == "United States")){
			// process US Zip Code
			return ValidateTextbox(thisfield,'Zip Code')

		}else if(thisCountry.toUpperCase() == "CANADA"){
			// PROCESS CANADIAN
			if (thisfield.value.length != 7){
				alert('Invalid Canadian Zip Code must be 7 characters formatted L#L #L#');
				thisfield.value = ""
				return false;
			}
			
			for(i=0;i<thisfield.value.length;i++){
				//LNL NLN, letter - number, space
				if(i == 3){
					if(thisfield.value.charAt(i) != " "){
						alert('Invalid Canadian Zip Code please format A2A 2A2');
						thisfield.value = ""
						return false;
					}
				}else if((i == 1) || (i == 4) || (i == 6)){
					if(isInteger(thisfield.value.charAt(i)) == false){
						alert('Invalid Canadian Zip Code please format A2A 2A2');
						thisfield.value = ""
						return false;
						}
				}else{
					if(isInteger(thisfield.value.charAt(i)) == true){
						alert('Invalid Canadian Zip Code please format A2A 2A2');
						thisfield.value = ""
						return false;
					}
				}
			}
		}		
	}else{
		alert('Please select a country!')
		thisfield.value = ""
		return;
	}

}


//***********************************************************//
//**	Script Name: ValidateBrowser
//**	Script Description: Determines if user has cookies enabled and an adequate browser
//**	Last Modified: 3/31/2006 2:42:13 PM
//***********************************************************//
function ValidateBrowser(){
	var BrowserName = navigator.appName
	var Platform = navigator.platform
	var Cookies_On = navigator.cookieEnabled
	if(Cookies_On == false){
		BrowserErrorMessage("Cookies",BrowserName,Platform,Cookies_On)
		return false;
	}else{
		return true;
	}
}



function BrowserErrorMessage(MessageType,BrowserName,Platform,CookiesOn){
	if (MessageType == "Cookies"){
		alert("*** It appears you do not have cookies enabled in your browser ***\n\nUnable to add this item to your cart.\nPlease enable cookies in your browser before continuing.")
		return true
	}else if(MessageType == "Old Browser" && Platform.substring(0,3) == "Mac"){
		alert("*** It appears your browser is not compatible with this shopping cart ***\n\nYou are current using:\n\nBrowser: "+BrowserName+"\n*** We recommend Firefox of Safari. ***")
		return true
	}else if(MessageType == "Old Browser" && Platform.substring(0,3) == "Win"){
		alert("*** It appears your browser is not compatible with this shopping cart ***\n\nYou are current using:\n\nBrowser: "+BrowserName+"\n*** We recommend updating to a later version. ***")
		return true
	}
}


//***********************************************************//
//**	Script Name: ValidateCCExpiration
//**	Script Description: Validates the expiration date for a credit card
//**	Last Modified: 3/31/2006 2:44:22 PM
//***********************************************************//
function ValidateCCExpiration(thisField,thisVal){
	var d = new Date()
	var thisMonth = d.getMonth() + 1
	if(navigator.appName == "Microsoft Internet Explorer"){
		var thisYear = d.getYear()
		}else{
		var thisYear = d.getYear() + 1900	
	}
	var currMonth = parseInt(thisVal.substring(0,thisVal.indexOf('/')))
	var currYear = parseFloat(thisVal.substring(thisVal.indexOf('/')+1,thisVal.length))

	if((currMonth == "") || (currYear == "")){
		return true;
	}else if((currMonth < thisMonth) && (currYear <= thisYear)){
		alert('Your card has already expired!')
		thisField.options.selectedIndex = 0;
		thisField.focus();
		return false;
	}else if(currYear < thisYear){
		alert('Your card has already expired!')
		thisField.options.selectedIndex = 0;
		thisField.focus();
		return false;
	}

}


//***********************************************************//
//**	Script Name: ValidateForm
//**	Script Description: Validates a form
//**	Last Modified: 4/25/2006 1:55:19 PM
//***********************************************************//
function ValidateForm(PassedForm){
var browserType = navigator.appName
var required = 0;
var errorMessage = "";
var caught = false;


if(document.getElementById('isWYSIWYG')){
	if (document.getElementById('isWYSIWYG').value=='true'){
		if (UpdateWYSIWYGEditor() == false){
			caught = false;
			return false;
		}
	}
}


  for(i=0;i<PassedForm.elements.length;i++){
  
  	if (PassedForm.elements[i].accessKey){
		required = PassedForm[i].accessKey.substring(0,1)
		}else{
		required = 0
		}		
		
   if (required == 1){
			if (document.getElementById('Cell_'+PassedForm[i].id)){
				errorMessage = document.getElementById('Cell_'+PassedForm[i].id).innerHTML
				errorMessage = errorMessage.replace(' ','');
				}else{
				errorMessage = PassedForm[i].name
				}
		
		 if((PassedForm[i].value == "") || (PassedForm[i].type == "select-one" && PassedForm[i].value == 0)){
			alert(errorMessage + " is a required field.")
			if (PassedForm[i].type != "hidden"){
				PassedForm[i].focus()
			}
			var caught = true;
		 	return false;
			}
   		}
  }
  	if (caught==false){
  		return true;
	 	}else{
		return false;
		}
}



//***********************************************************//
//**	Script Name: ValidateFormCart
//**	Script Description: Verifies the cart data
//**	Last Modified: 3/31/2006 2:43:30 PM
//***********************************************************//
function ValidateFormCart(theseArgs){

if(ValidateCartTotals() == false){
	return false;
}
	


// check shipping type if applicable
if (document.getElementById('ShippingType')){
	if(document.getElementById('ShippingType').value == ""){
		alert('Please select a shipping type');
		return false;
	}
}

var tempArray = theseArgs.split("&")
for(i=0;i<tempArray.length;i++){
		if(tempArray[i] != ""){
		var thisName = tempArray[i].substring(0,tempArray[i].indexOf('='))
		var thisType = tempArray[i].substring(tempArray[i].indexOf('=')+1,tempArray[i].length)

		if (thisType != "Expiration"){
			if(document.getElementById(thisName)){
				var thisObj = document.getElementById(thisName)
				}else{
					alert(thisName + ' does not exist.');
					return false;
				}
		}
		
		if (thisType == "Name"){
			if(thisObj.value == ""){
				alert('Billing Name is required.');
				thisObj.focus();
				return false;
			}else if(thisObj.value.indexOf(' ') == -1){
				alert('Billing Name must contain a first name and last name');
				thisObj.focus();
				return false;
			}
		}else if(thisType == "CCN"){
			if(thisObj.value == ""){
				alert('Credit Card Number is required');
				thisObj.focus();
				return false;
			}else if(ValidateTextbox(thisObj,"Integer") == false){
				thisObj.focus();
				return false;
			}else if(thisObj.value.length < 12){
				alert('Credit Card Number must be greater then 11 numbers');
				thisObj.focus();
				return false;
			}
		
		}else if(thisType == "CVV"){
			if(thisObj.value == ""){
				alert("CVV number is required.")
				thisObj.focus();
				return false;
			}else if(ValidateTextbox(thisObj,"Integer") == false){
				thisObj.focus();
				return false;
			}else if(thisObj.value.length < 3){
				alert("CVV number must be greater then 2 numbers");
				thisObj.focus();
				return false;
			}		
		}else if(thisType == "Type"){
			if(thisObj.value == ""){
				alert("Please select a Credit Cart Type")
				thisObj.focus();
				return false;
			}else if(thisObj.options[thisObj.selectedIndex] == ""){
				alert("Please select a Credit Card Type")
				thisObj.focus();
				return false;
			}
		}else if(thisType == "Expiration"){
			var thisMonth = thisName.substring(0,thisName.indexOf('|'))
			var thisYear = thisName.substring(thisName.indexOf('|')+1,thisName.length)
			var objMonth = document.getElementById(thisMonth)
			var objYear = document.getElementById(thisYear)
		
			if(objMonth.value == ""){
				alert('Expiration Month is required')
				objMonth.focus();
				return false;
			}else if(objYear.value == ""){
				alert('Expiration Year is required');
				objYear.focus();
				return false;
			}else if(ValidateCCExpiration(objMonth,objMonth.value+'/'+objYear.value) == false){
				objMonth.focus();
				return false;
			}
		
		}else{
			alert('Unable to find thisType ' + thisType);
			return false;
		}	
	}

	}
	return true;

}


//***********************************************************//
//**	Script Name: ValidateFormOnClose
//**	Script Description: Validates if user uploaded an image without saving
//**	Last Modified: 3/31/2006 1:06:51 PM
//***********************************************************//
function ValidateFormOnClose(PassedForm){
	// checks to see if current form is of type Add
	// if any images exist, user must delete images before closing
	var caught = false;

		for(i=0;i<PassedForm.elements.length;i++){
			var thisElement = PassedForm.elements[i]
			if (thisElement.id.indexOf('Image') > -1){
				// check value if not <> then stop user
				if(((thisElement.value != "") && (PassedForm.id == "fromAdd")) || ((thisElement.value == "") && (PassedForm.id == "fromUpdate"))) {
					if (PassedForm.id == "fromAdd"){
						alert('Please delete the image before closing');
					}else{
						alert('Please upload an image and then click update');
					}
				caught = true;
				return false;
				}
			}else if(thisElement.id.indexOf('Video') > -1){
				// check value if not <> then stop user
				if(((thisElement.value != "") && (PassedForm.id == "fromAdd")) || ((thisElement.value == "") && (PassedForm.id == "fromUpdate"))) {
					if (PassedForm.id == "fromAdd"){
						alert('Please delete the file before closing');
					}else{
						alert('Please upload a file and then click update');
					}
					caught = true;
					return false;
				}
			}
		}

	// if still here return true
	if (caught == false){
		return true;	
	}

}



//***********************************************************//
//**	Script Name: ValidateTextarea
//**	Script Description: Validates the textarea by the length
//**	Last Modified: 3/31/2006 1:32:26 PM
//***********************************************************//
function ValidateTextarea(thisField,thisMaxLength){
	if (thisField.value.length > thisMaxLength){
		alert('Max Length for this text area is ' + thisMaxLength + ', your data has been shortened.');
		thisField.value = thisField.value.substring(0,parseInt(thisMaxLength-1))
		thisField.focus();
	}
}




//***********************************************************//
//**	Script Name: ValidateTextbox
//**	Script Description: Manages the different textbox functions
//**	Last Modified: 3/31/2006 1:07:13 PM
//***********************************************************//
function ValidateTextbox(thisField,thisType){

if (thisField.value == "" || thisField == null){
	return true;
}else{

	if (thisType == "Date"){
		if (isDate(thisField.value)==false){
			thisField.value = "";
			thisField.focus();
			return false;
		}
		return true;
	} else if (thisType == "Integer"){
		if (isInteger(thisField.value)==false){
			alert("Please enter numbers only");
			thisField.value = ""
			thisField.focus();
			return false
		}
	} else if (thisType == "Currency"){
		 thisField.value = isCurrency(thisField.value);
	} else if (thisType == "Zip Code"){
		var temp = isZipCode(thisField.value);
		if (temp != thisField.value){
			thisField.focus();
		}
	} else if (thisType == "Social Security Number"){
		var temp = isSSN(thisField.value);
		if (temp != thisField.value){
			thisField.focus();
		}
	} else if (thisType == "Phone"){
		var temp = isPhone(thisField.value);
		if (temp != thisField.value){
			thisField.value = temp
			thisField.focus();
		}
	} else if (thisType == "Email"){
		var temp = isEmail(thisField.value);
		if (temp == false){
			thisField.focus();
		}
	} else if (thisType == "Website"){
		var temp = isWebsite(thisField.value);
		if (temp != thisField.value){
			thisField.focus();
		}			
	} else {
		alert("Currently " + thisType + " is not supported.")
		return true
	}
 }
}



//***********************************************************//
//**	Script Name: VerifyPassword
//**	Script Description: Validates if the words are password
//**	Last Modified: 3/31/2006 1:10:27 PM
//***********************************************************//
 function VerifyPassword(Password2,Password){
            if (Password.value == Password2.value){
                return true;
            }else{
                alert("Passwords do not match");
				Password2.value = ""
				Password.value = ""
                Password.focus();
               return false;
            }
    }

