// Title: ezAdmin Utility Functions
// URL: http://www.myeasywebsite.com
// Version: 1.0
// Date: 054/15/2005 (mm/dd/yyyy)
// Note: Permission given to use this script in ANY kind of applications if
//    header lines are left unchanged.
//

/*---------------------------------------------
HELP FUNCTIONS
---------------------------------------------*/

// Temporary variables to hold mouse x-y pos.s
var tempX = 0;
var tempY = 0;

var IE = document.all?true:false

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.ONCLICK)

/~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
function DateToStr(myDate, myFormat){

	var strDate = "";
	var tmpDate = new Date(myDate); 

	if (myFormat==1){
		strDate = (tmpDate.getMonth() + 1) + "/" + tmpDate.getDate() + "/" + tmpDate.getFullYear()
	}

	return strDate;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
function WritePageEdited(){
	if (document){
		var str = "<div class='PageModified' onclick=javascript:this.style.display='none'; >"
		document.write (str + 'Last edited: '+ DateToStr(document.lastModified, 1) +'</div>');
	}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
function SiteUpdate(){
	var frm = parent.EditTop.Detail;
	var image = frm.imgUpdateSite;

	if (image) {
		image.src = "/App/images/UpdateWebsiteAni.gif";
	}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
function SiteUpdateReset(){
	var frm = parent.EditTop.Detail;
	var image = frm.imgUpdateSite;

	if (image) {
		image.src = "/App/images/UpdateWebsite.gif";
	}
}

/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
function ShowLocation(){

	var sWt = 375;
	var sHt = 425;
	var winl = (screen.width - sWt) / 2;
	var wint = (screen.height - sHt) / 2;	
	var winprops = "width="+sWt+",height="+sHt+",top="+wint+",left="+winl+",scrollbars=no,scrolling=no,menubar=no,toolbar=no,resizable=no";
	var targetpage = "ezSiteMenuLocation.aspx";
	var pagetitle = "navLocation";
	
	win = window.open(targetpage,pagetitle,winprops);

}

/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
function ShowEffects(){

	var sWt = 375;
	var sHt = 425;
	var winl = (screen.width - sWt) / 2;
	var wint = (screen.height - sHt) / 2;	
	var winprops = "width="+sWt+",height="+sHt+",top="+wint+",left="+winl+",scrollbars=no,scrolling=no,menubar=no,toolbar=no,resizable=no";
	var targetpage = "ezSiteMenuEffect.aspx";
	var pagetitle = "newWindow";
	
	win = window.open(targetpage,pagetitle,winprops);

}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
function FindElementX(sId, tag, classid){

	var str = "";
	var obj;
	var elements = document.getElementsByTagName(tag);

	for (var i = 0; i < elements.length; i++) {
		obj = elements[i]; 
		if(typeof obj != "undefined"){
			str = obj.id;
			if((str.indexOf(sId) > -1) && (obj.className==classid)){
				return obj;
			}
		}
	}

	return false;

}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
function FindElement(sId){

	var str = "";
	var obj;
	var elements = document.getElementsByTagName('input');

	for (var i = 0; i < elements.length; i++) {
		obj = elements[i]; 
		if(typeof obj != "undefined"){
			str = obj.id;
			if(str.indexOf(sId) > -1){
				return obj;
			}
		}
	}

	elements = document.getElementsByTagName('hidden');
	for (var i = 0; i < elements.length; i++) {
		obj = elements[i]; 
		if(typeof obj != "undefined"){
			str = obj.id;
			if(str.indexOf(sId) > -1){
				return obj;
			}
		}
	}

	elements = document.getElementsByTagName('select');
	for (var i = 0; i < elements.length; i++) {
		obj = elements[i]; 
		if(typeof obj != "undefined"){
			str = obj.id;
			if(str.indexOf(sId) > -1){
				return obj;
			}
		}
	}

	elements = document.getElementsByTagName('checkbox');
	for (var i = 0; i < elements.length; i++) {
		obj = elements[i]; 
		if(typeof obj != "undefined"){
			str = obj.id;
			if(str.indexOf(sId) > -1){
				return obj;
			}
		}
	}

	elements = document.getElementsByTagName('div');
	for (var i = 0; i < elements.length; i++) {
		obj = elements[i]; 
		if(typeof obj != "undefined"){
			str = obj.id;
			if(str.indexOf(sId) > -1){
				return obj;
			}
		}
	}

	return false;

}


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
var popupHandle;
function closePopup() {
	if(popupHandle != null && !popupHandle.closed) popupHandle.close();
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
function fn_ShowHelp(targetpage, target, pagetitle) {
	closePopup();
	
	if (target=="POPUP"){ // 'POPUP',
		popupHandle = ShowPopupHelp(targetpage, pagetitle, 600, 475);
	}

	if (target=="MAINWINDOW"){ // 'MAINWINDOW',
		parent.EditRight.location.href=targetpage;
	}

}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
function ShowPopupHelp(targetpage, pagetitle, wt, ht){
	var winl = (screen.width - wt) / 2;
	var wint = (screen.height - ht) / 2;	
	var winprops = "width="+wt+",height="+ht+",top="+wint+",left="+winl+",scrollbars=yes,scrolling=auto,menubar=no,toolbar=no,resizable=yes";
	win = window.open(targetpage,pagetitle,winprops);	
	return win;
} 

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
function ShowPopupMail(targetpage, pagetitle, wt, ht){
	var winl = (screen.width - wt) / 2;
	var wint = (screen.height - ht) / 2;	
	var winprops = "width="+wt+",height="+ht+",top="+wint+",left="+winl+",scrollbars=yes,scrolling=auto,menubar=no,toolbar=no,resizable=yes";
	win = window.open(targetpage,pagetitle,winprops);	
	return win;
} 

/*---------------------------------------------
GENERAL USE FUNCTIONS
---------------------------------------------*/

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
function fnCheckBrowser(){
	
	var sBrowser = "0";
	if(document.getElementById) {
		sBrowser="1";
	}else if(document.layers) {
		sBrowser="2";
	} else if (document.all) {
		sBrowser="99";
	}
	
	return sBrowser;

}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
function fnOver(obj) {
	obj.style.background="#33FFFF";
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
function fnOut(obj) {
	obj.style.background="#FFFFFF";
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
function fnBtnOver(obj) {
	obj.style.background="#33FFFF";
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
function fnBtnOut(obj) {
	obj.style.background="#DDDDDD";
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
function toggleDivMenu(sGraphic){

	var str = "";
	var toggle = 0;
	//-- remove the _Graphic from name to get to div object
	str = sGraphic.replace("_Graphic",""); 

	toggle = document.getElementById(str + '_Text').value;
	
	if (toggle==5){
		// if disabled, close and exit
		document.getElementById(str).style.display = 'none';
		document.getElementById(sGraphic).src = '/App/images/closed.gif';
		return;
	}

	//var obj = document.getElementById(str);
	if (toggle==0){
		// if closed then open
		document.getElementById(str).style.display = 'block';
		document.getElementById(sGraphic).src = '/App/images/expand.gif';
		document.getElementById(str + '_Text').value = 1;
	}else{
		// if 1 or "" then close
		document.getElementById(str).style.display = 'none';
		document.getElementById(sGraphic).src = '/App/images/closed.gif';
		document.getElementById(str + '_Text').value = 0;
	}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
function setDivMenu(sGraphic){

	var str = "";
	var toggle = 0;
	//-- remove the _Graphic from name to get to div object
	str = sGraphic.replace("_Graphic",""); 

	toggle = document.getElementById(str + '_Text').value;
	
	//var obj = document.getElementById(str);

	if (toggle==5){
		// if disabled, close and exit
		document.getElementById(str).style.display = 'none';
		document.getElementById(sGraphic).src = '/App/images/closed.gif';
		return;
	}

	if (toggle==0){
		// if closed then keep closed
		document.getElementById(str).style.display = 'none';
		document.getElementById(sGraphic).src = '/App/images/closed.gif';
	}else{
		// if 1 or "" then keep open
		document.getElementById(str).style.display = 'block';
		document.getElementById(sGraphic).src = '/App/images/expand.gif';
	}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
function toggleVisible(sGraphic, swap){

	
	var str = "";
	//-- remove the _Graphic from name to get to div object
	str = sGraphic.replace("_Graphic",""); 
	
	var obj = document.getElementById(str);
	//if (obj.style.display=='block'){
	
	if (obj.style.visibility=='visible'){
		document.getElementById(str).style.display = 'none';
		document.getElementById(str).style.visibility = 'hidden';
		if (swap)
			document.getElementById(sGraphic).src = '/App/images/closed.gif';
			
	}else{
		document.getElementById(str).style.display = 'block';
		document.getElementById(str).style.visibility = 'visible';
		if (swap)
			document.getElementById(sGraphic).src = '/App/images/expand.gif';
	}
}

/*---------------------------------------------
SECTION FOR COLORS
---------------------------------------------*/

//function fnShowFont(txtBox, left, top, clrBox, divBox, divType){
//	var txtTarget = document.getElementById('txt_target');
//	var clrTarget = document.getElementById('clr_target');
//	var divTarget = document.getElementById('div_target');
//	var typTarget = document.getElementById('txt_type');

//	var move = false;
//	
//	if (txtTarget.value != txtBox){
//		move = true;
//	}

//	//-- save control names and type
//	txtTarget.value = txtBox;
//	clrTarget.value = clrBox;
//	divTarget.value = divBox;
//	typTarget.value = divType;
//	
//	var IfrRef = document.getElementById('iFraFont');
//	
//	if ((IfrRef.style.visibility=='hidden') || (move)) {
//    IfrRef.style.top = 200;
//    IfrRef.style.left = 250;
//		IfrRef.style.visibility = "visible";
//    IfrRef.style.display = "block";		
//}else{
//		IfrRef.style.visibility="hidden";
//		IfrRef.style.display = "none";
//	} 
//}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
function fnShowColor(txtBox, left, top, clrBox, divBox, divType){
	var txtTarget = document.getElementById('txt_target');
	var clrTarget = document.getElementById('clr_target');
	var divTarget = document.getElementById('div_target');
	var typTarget = document.getElementById('txt_type');

	var move = false;
	
	if (txtTarget.value != txtBox){
		move = true;
	}

	//-- save control names and type
	txtTarget.value = txtBox;
	clrTarget.value = clrBox;
	divTarget.value = divBox;
	typTarget.value = divType;
	
	var IfrRef = document.getElementById('iFraColor');
	
	if ((IfrRef.style.visibility=='hidden') || (move)) {
    IfrRef.style.top = 200;
    IfrRef.style.left = 250;
		IfrRef.style.visibility = "visible";
    IfrRef.style.display = "block";		
}else{
		IfrRef.style.visibility="hidden";
		IfrRef.style.display = "none";
	} 
}


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
function IsValidColor(hexcolor) { 

	if (hexcolor == '') return true;
	if (hexcolor.length > 7) return false;

	var strPattern = /^#([0-9a-f]{1,2}){6}$/i; 
	return strPattern.test(hexcolor); 
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
function fnOnChangeColor(txtBox, clrBox, divBox, divType){

	var setTxt = document.getElementById(txtBox);
	var setClr = document.getElementById(clrBox);	
	var setDiv = document.getElementById(divBox);	
	var setType = divType;
	var color = setTxt.value;

	if (IsValidColor(color)){
		setTxt.value = color.toUpperCase();

		fnSetDivProperty(setClr.id, color, 'BACKGROUND');		// visual color box

		if (divType=='MENUBORDER') {
			fnSetMenuBorder(color, txtBox, clrBox, divBox);
		}else{
			
			fnSetDivProperty(setDiv.id, color, setType);		// user div graphic
		}

	}else{
		alert('Invalid color value');
		setTxt.value = '#FFFFFF';
	}	
	
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
function fnSetDivProperty(divObject, divValue, divType){

	var divBox = document.getElementById(divObject);
	
	if (!divBox){
		alert('fnSet object not found:' + divObject + ' ' + divValue + ' ' + divType);
	}else{
		
		if (divType=="BACKGROUND"){
			divBox.style.backgroundColor = divValue;		
		}

		if (divType=="FONT"){
			divBox.style.color = divValue;
		}

		if (divType=="SITESCROLL"){
			fnSetScrollColor(divValue);
		}
			
		if (divType=="SITEBGIMAGE"){
			//divBox.style.backgroundImage = 'url(/uploads/images/site/' + divValue + ')';	
			divBox.style.backgroundImage = 'url(' + divValue + ')';
		}
		
		if (divType=="MENUBGIMAGE"){
			divBox.style.backgroundImage = 'url(/admin/data/menu/images/' + divValue + ')';
		}
	
		if (divType=="BGREPEAT"){
			divBox.style.backgroundRepeat = divValue;	
		}

		if (divType=="BGALIGN"){
			divBox.style.backgroundPosition = divValue;	
		}

		if (divType=="FONTNAME"){
			divBox.style.fontFamily = divValue;
		}
		
		if (divType=="FONTWT"){
			divBox.style.fontWeight = divValue;
		}
		
		if (divType=="FONTALIGN"){
			divBox.style.textAlign = divValue;	
		}			
			
		if (divType=="FONTSIZE"){
			divBox.style.fontSize = divValue;
		}	

		if (divType=="HEIGHT"){
			divBox.style.height = divValue;
		}	
		
		if (divType=="WIDTH"){
			divBox.style.width = divValue;
		}	

		if (divType=="BORDER"){
			divBox.style.border = divValue;
		}	
		
		if (divType=="BORDERSIZE"){
			divBox.style.borderTopWidth = divValue;
			divBox.style.borderBottomWidth = divValue;			
			divBox.style.borderLeftWidth = divValue;
			divBox.style.borderRightWidth = divValue;			
		}	

		if (divType=="BORDERCOLOR"){
			divBox.style.borderColor = divValue;
		}	
		
		if (divType=="BORDERTOP"){
			divBox.style.borderTop = divValue;
		}	
		
		if (divType=="BORDERBOTTOM"){
			divBox.style.borderBottom = divValue;
		}			

		if (divType=="BORDERLEFT"){
			divBox.style.borderLeft = divValue;
		}

		if (divType=="BORDERRIGHT"){
			divBox.style.borderRight = divValue;
		}
		
	}//-- end if null

}


/*---------------------------------------------
SECTION FOR SITE STYLES
---------------------------------------------*/
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
function IsValidSize(pxsize) { 
	if (pxsize.value == '') { pxsize.value ='10'; }

	//-- var strPattern = /([0-9]{1,2})(px){1}$/i; 
	var strPattern = /([0-9]{1,2}){1}$/i; 
	
	var good = strPattern.test(pxsize.value); 
	
	//var myNum = 0;
	
	if (!good) {
		alert('Bad Size: ' + pxsize.value + ' \nSize values must only be numbers! \nExample: 10 = 10 pixel size.');
		pxsize.value='10';
		return false;
	}else{
		return true;
	}
}


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
function fnIsValidSize(pxsize) { 
	if (pxsize.value == '') { pxsize.value='10px'; }

	//-- var strPattern = /([0-9]{1,2})(px){1}$/i; 
	var strPattern = /([0-9]{1,2}){1}$/i; 
	
	var good = strPattern.test(pxsize.value); 
	
	var myNum = 0;
	
	if (!good) {
		
		if (pxsize.id == 'txtEffectDuration'){
			alert('Bad Size: ' + pxsize.value + ' \nSize value must only be numbers!');
			pxsize.value='100';
			return;
		}else{
			alert('Bad Size: ' + pxsize.value + ' \nSize values must only be numbers! \nExample: 10 = 10 pixel size.');
			pxsize.value='10';
			return;
		}
	}

	//-- check size for rotator control
	if ((pxsize.id == 'txtRotHeight') || (pxsize.id == 'txtRotWidth')){
		if (pxsize.value > 700) {
			alert('Bad Size: ' + pxsize.value + ' \nSize can not be greater than 500!');
			pxsize.value='500';
			return;
		}
	}
	
	if ((pxsize.id == 'txtRotHeight') || (pxsize.id == 'txtRotWidth')){
		if (pxsize.value < 75) {
			alert('Bad Size: ' + pxsize.value + ' \nSize can not be less than 75!');
			pxsize.value='75';
			return;
		}
	}

	if ((pxsize.id == 'txtTickBorderSize')){
		if (pxsize.value > 10) {
			alert('Bad Size: ' + pxsize.value + ' \nSize can not be greater than 10!');
			pxsize.value='10';
			return;
		}
	}

	// set site style font sizes
	if (pxsize.id == 'txtTickBorderSize'){
		fnSetDivProperty('BorderColor', pxsize.value, 'BORDERSIZE');
	}	

	// set site style font sizes
	if (pxsize.id == 'txtTickerFontSize'){
		fnSetDivProperty('txtTickerText', pxsize.value, 'FONTSIZE');
	}	
	
	// set site style font sizes
	if (pxsize.id == 'txtSiteFontSize'){
		fnSetDivProperty('divBrowserName', pxsize.value, 'FONTSIZE');
		fnSetDivProperty('divPage', pxsize.value, 'FONTSIZE');
		fnSetDivProperty('divContent', pxsize.value, 'FONTSIZE');
	}
	
	// set menu font sizes
	if (pxsize.id == 'txtMainFontSize'){
		fnSetDivProperty('MainItem', pxsize.value, 'FONTSIZE');
		fnSetDivProperty('divMainItemOver', pxsize.value, 'FONTSIZE');
	}

	if (pxsize.id == 'txtMenuItemFontSize'){
		fnSetDivProperty('divMenuItem', pxsize.value, 'FONTSIZE');
		fnSetDivProperty('divMenuItemOver', pxsize.value, 'FONTSIZE');
	}


	// set ticker style font sizes
	if (pxsize.id == 'txtTickerFontSize'){
		fnSetDivProperty('txtTickerText', pxsize.value, 'FONTSIZE');
	}	
	
	// set main menu item height
	if (pxsize.id == 'txtMainHt'){
		if(pxsize.value<20) pxsize.value=20;
		fnSetDivProperty('MainItem', pxsize.value, 'HEIGHT');
		fnSetDivProperty('divMainItemOver', parseInt(pxsize.value) + 4, 'HEIGHT');
	}

	// set main menu item width 
	if (pxsize.id == 'txtMainWt'){
		if(pxsize.value>150) pxsize.value=150;
		fnSetDivProperty('MainItem', pxsize.value, 'WIDTH');
		fnSetDivProperty('divMainItemOver', pxsize.value, 'WIDTH');		
	}	
	
	// set sub menu item height


	if (pxsize.id == 'txtMenuItemHt'){
		if(pxsize.value<20) pxsize.value=20;
		fnSetDivProperty('divMenuItem', pxsize.value, 'HEIGHT');
		fnSetDivProperty('divMenuItemOver', pxsize.value, 'HEIGHT');
	}	
	
	// set main menu item width 
	if (pxsize.id == 'txtMenuItemWt'){
		if(pxsize.value>200) pxsize.value=200;
		fnSetDivProperty('divMenuItem', pxsize.value, 'WIDTH');
		fnSetDivProperty('divMenuItemOver', pxsize.value, 'WIDTH');		
	}	
	
} 

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
function fnSetColorValues(color, txtBox, clrBox, divBox, divType){
	
	var valid = IsValidColor(color);

	if (!valid) {
		alert('Invalid Color Value: ' + color + '. \nHex color value must start with # character followed by 6 characters using ABCDEF and/or numbers 0123456789. \nExample: #FFFFFF = White ');
	}	
	
	var setText = document.getElementById(txtBox);

	//-- set the text value item
	setText.value = color;
		
	//-- set the color box item
	fnSetDivProperty(clrBox, color, 'BACKGROUND');		
	
	//-- check to see if we are doing a single item or group
	var myDiv = document.getElementById(divBox);
	
	if (myDiv){
		//-- do a single item
		fnSetDivProperty(divBox, color, divType);
	}

	if (divType=="MENUBORDER"){
		fnSetMenuBorder(color, txtBox, clrBox, divBox)
	}	
	
	if (divType=="SITESCROLL"){
		fnSetDivProperty(divBox, color, 'BACKGROUND');
		fnSetScrollColor(color);
	}
	
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
function fnSetMenuBorder(sColor, sField, sDivBox, sDivDisplay){

	//-- set text value (have to set for recursion)
	document.getElementById(sField).value = sColor;
	
	//-- set div box color (have to set for recursion)
	fnSetDivProperty(sDivBox, sColor, 'BACKGROUND');
	
	var sColorProp = "";
	
	//-- MAIN MENU PROPERTIES //		
	
	if (sDivDisplay =="divMainBorder") {
		// for main border
		if (sColor==""){
			sColorProp = "none"			
		}else{
			sColorProp = "1px solid " + sColor;
		}			
		fnSetDivProperty('MainItem', sColorProp, 'BORDER');
		
		/////////////////////////////////////////////////
		//-- recall for border top and bottom
		var mainTopClr = document.getElementById('txtMainTop').value;		
		var mainBotClr = document.getElementById('txtMainBot').value;		
		var mainLeftClr = document.getElementById('txtMainLeft').value;		
		var mainRightClr = document.getElementById('txtMainRight').value;		

		if (mainTopClr =='') mainTopClr = sColor;
		if (mainBotClr =='') mainBotClr = sColor;
		if (mainLeftClr =='') mainLeftClr = sColor;
		if (mainRightClr =='') mainRightClr = sColor;

		fnSetMenuBorder(mainTopClr, 'txtMainTop', 'clrMainTop', 'divMainTop');
		fnSetMenuBorder(mainBotClr, 'txtMainBot', 'clrMainBot', 'divMainBot');	
		fnSetMenuBorder(mainLeftClr, 'txtMainLeft', 'clrMainLeft', 'divMainLeft');
		fnSetMenuBorder(mainRightClr, 'txtMainRight', 'clrMainRight', 'divMainRight');

	}else if (sDivDisplay =="divMainTop") {		
		// for main top border
		if (sColor==""){
			sColorProp = "none";
		}else{
			sColorProp = "1px solid " + sColor;
		}
		fnSetDivProperty('MainItem', sColorProp, 'BORDERTOP');
	
	}else if (sDivDisplay =="divMainBot") {		
		// for main top border
		if (sColor==""){
			sColorProp = "none";
		}else{
			sColorProp = "1px solid " + sColor;
		}
		fnSetDivProperty('MainItem', sColorProp, 'BORDERBOTTOM');

	}else if (sDivDisplay =="divMainLeft") {		
		// for main left border
		if (sColor==""){
			sColorProp = "none";
		}else{
			sColorProp = "1px solid " + sColor;
		}
		fnSetDivProperty('MainItem', sColorProp, 'BORDERLEFT');

	}else if (sDivDisplay =="divMainRight") {		
		// for main left border
		if (sColor==""){
			sColorProp = "none";
		}else{
			sColorProp = "1px solid " + sColor;
		}
		fnSetDivProperty('MainItem', sColorProp, 'BORDERRIGHT');
		
	//-- MAIN OVER PROPERTIES //		
	
	}else if (sDivDisplay =="divMainOverBorder") {		
		// for main menu item border
		myDiv = document.getElementById('divMainItemOver');

		if (sColor==""){		
			sColorProp = "none"			
		}else{
			sColorProp = "1px solid " + sColor;
		}
		fnSetDivProperty('divMainItemOver', sColorProp, 'BORDER');

		/////////////////////////////////////////////////
		//-- recall for border top and bottom
		var mainOverTopClr = document.getElementById('txtMainOverTop').value;		
		var mainOverBotClr = document.getElementById('txtMainOverBot').value;		
		var mainOverLeftClr = document.getElementById('txtMainOverLeft').value;		
		var mainOverRightClr = document.getElementById('txtMainOverRight').value;		

		if (mainOverTopClr =='') mainOverTopClr = sColor;
		if (mainOverBotClr =='') mainOverBotClr = sColor;
		if (mainOverLeftClr =='') mainOverLeftClr = sColor;
		if (mainOverRightClr =='') mainOverRightClr = sColor;

		fnSetMenuBorder(mainOverTopClr, 'txtMainOverTop', 'clrMainOverTop', 'divMainOverTop');
		fnSetMenuBorder(mainOverBotClr, 'txtMainOverBot', 'clrMainOverBot', 'divMainOverBot');	
		fnSetMenuBorder(mainOverLeftClr, 'txtMainOverLeft', 'clrMainOverLeft', 'divMainOverLeft');
		fnSetMenuBorder(mainOverRightClr, 'txtMainOverRight', 'clrMainOverRight', 'divMainOverRight');	
		
	}else if (sDivDisplay =="divMainOverTop") {		
		// for main menu item top border
		if (sColor==""){		
			sColorProp = "none"			
		}else{
			sColorProp = "2px outset " + sColor;
		}			
		fnSetDivProperty('divMainItemOver', sColorProp, 'BORDERTOP');

	}else if (sDivDisplay =="divMainOverBot") {		
		// for main menu item bottom border
		if (sColor==""){		
			sColorProp = "none"			
		}else{
			sColorProp = "3px solid " + sColor;
		}			
		fnSetDivProperty('divMainItemOver', sColorProp, 'BORDERBOTTOM');

	}else if (sDivDisplay =="divMainOverLeft") {		
		// for main menu item bottom border
		if (sColor==""){		
			sColorProp = "none"			
		}else{
			sColorProp = "2px solid " + sColor;
		}			
		fnSetDivProperty('divMainItemOver', sColorProp, 'BORDERLEFT');

	}else if (sDivDisplay =="divMainOverRight") {		
		// for main menu item bottom border
		if (sColor==""){		
			sColorProp = "none"			
		}else{
			sColorProp = "2px solid " + sColor;
		}			
		fnSetDivProperty('divMainItemOver', sColorProp, 'BORDERRIGHT');

	}else if (sDivDisplay =="divMainOverFontColor") {		
		// for main menu over font color
		myDiv = document.getElementById('divMainItemOver');
		myDiv.style.color = sColor;		
		
	//-- SUB MENU PROPERTIES //		
		
	}else if (sDivDisplay =="divMenuItemBorder") {		
		// for sub menu item border
		if (sColor==""){		
			sColorProp = "none"			
		}else{
			sColorProp = "1px solid " + sColor;
		}		
		fnSetDivProperty('divMenuItem', sColorProp, 'BORDER');
		
		/////////////////////////////////////////////////
		//-- recall for border top
		var subTopClr = document.getElementById('txtMenuItemTop').value;
		var subBotClr = document.getElementById('txtMenuItemBot').value;
		var subLeftClr = document.getElementById('txtMenuItemLeft').value;
		var subRightClr = document.getElementById('txtMenuItemRight').value;

		if (subTopClr == '') subTopClr = sColor;
		if (subBotClr == '') subBotClr = sColor;
		if (subLeftClr == '') subLeftClr = sColor;
		if (subRightClr == '') subRightClr = sColor;

		fnSetMenuBorder(subTopClr, 'txtMenuItemTop', 'clrMenuItemTop', 'divMenuItemTop');		
		fnSetMenuBorder(subBotClr, 'txtMenuItemBot', 'clrMenuItemBot', 'divMenuItemBot');	
		fnSetMenuBorder(subLeftClr, 'txtMenuItemLeft', 'clrMenuItemLeft', 'divMenuItemLeft');		
		fnSetMenuBorder(subRightClr, 'txtMenuItemRight', 'clrMenuItemRight', 'divMenuItemRight');	

	}else if (sDivDisplay =="divMenuItemTop") {		
		// for sub menu item top border
		if (sColor==""){		
			sColorProp = "none"			
		}else{
			sColorProp = "1px solid " + sColor;
		}		
		fnSetDivProperty('divMenuItem', sColorProp, 'BORDERTOP');
		
	}else if (sDivDisplay =="divMenuItemBot") {		
		// for sub menu item bot border
		if (sColor==""){		
			sColorProp = "none"			
		}else{
			sColorProp = "1px solid " + sColor;
		}		
		fnSetDivProperty('divMenuItem', sColorProp, 'BORDERBOTTOM');	

	}else if (sDivDisplay =="divMenuItemLeft") {		
		// for sub menu item bot border
		if (sColor==""){		
			sColorProp = "none"			
		}else{
			sColorProp = "1px solid " + sColor;
		}		
		fnSetDivProperty('divMenuItem', sColorProp, 'BORDERLEFT');	

	}else if (sDivDisplay =="divMenuItemRight") {		
		// for sub menu item bot border
		if (sColor==""){		
			sColorProp = "none"			
		}else{
			sColorProp = "1px solid " + sColor;
		}		
		fnSetDivProperty('divMenuItem', sColorProp, 'BORDERRIGHT');	

	//-- SUB MENU OVER PROPERTIES //			
		
	}else if (sDivDisplay =="divMenuItemOverBorder") {		
		// for sub menu item border
		if (sColor==""){		
			sColorProp = "none"			
		}else{
			sColorProp = "1px solid " + sColor;
		}		
		fnSetDivProperty('divMenuItemOver', sColorProp, 'BORDER');

		/////////////////////////////////////////////////
		//-- recall for border top and bottom
		var subOverTopClr = document.getElementById('txtMenuItemOverTop').value;		
		var subOverBotClr = document.getElementById('txtMenuItemOverBot').value;		
		var subOverLeftClr = document.getElementById('txtMenuItemOverLeft').value;		
		var subOverRightClr = document.getElementById('txtMenuItemOverRight').value;		

		if (subOverTopClr=='') subOverTopClr = sColor;
		if (subOverBotClr=='') subOverBotClr = sColor;
		if (subOverLeftClr=='') subOverLeftClr = sColor;
		if (subOverRightClr=='') subOverRightClr = sColor;

		fnSetMenuBorder(subOverTopClr, 'txtMenuItemOverTop', 'clrMenuItemOverTop', 'divMenuItemOverTop');
		fnSetMenuBorder(subOverBotClr, 'txtMenuItemOverBot', 'clrMenuItemOverBot', 'divMenuItemOverBot');
		fnSetMenuBorder(subOverLeftClr, 'txtMenuItemOverLeft', 'clrMenuItemOverLeft', 'divMenuItemOverLeft');
		fnSetMenuBorder(subOverRightClr, 'txtMenuItemOverRight', 'clrMenuItemOverRight', 'divMenuItemOverRight');		

	}else if (sDivDisplay =="divMenuItemOverTop") {		
		// for sub menu item over top border
		if (sColor==""){		
			sColorProp = "none"			
		}else{
			sColorProp = "1px solid " + sColor;
		}	
		fnSetDivProperty('divMenuItemOver', sColorProp, 'BORDERTOP');
		
	}else if (sDivDisplay =="divMenuItemOverBot") {		
		// for main menu item bottom border
		if (sColor==""){		
			sColorProp = "none"			
		}else{
			sColorProp = "1px solid " + sColor;
		}		
		fnSetDivProperty('divMenuItemOver', sColorProp, 'BORDERBOTTOM');

	}else if (sDivDisplay =="divMenuItemOverLeft") {		
		// for main menu item bottom border
		if (sColor==""){		
			sColorProp = "none"			
		}else{
			sColorProp = "1px solid " + sColor;
		}		
		fnSetDivProperty('divMenuItemOver', sColorProp, 'BORDERLEFT');
		
	}else if (sDivDisplay =="divMenuItemOverRight") {		
		// for main menu item bottom border
		if (sColor==""){		
			sColorProp = "none"			
		}else{
			sColorProp = "1px solid " + sColor;
		}		
		fnSetDivProperty('divMenuItemOver', sColorProp, 'BORDERRIGHT');


	}else if (sDivDisplay =="divMenuItemFontColor") {		
		// for sub menu font color
		myDiv = document.getElementById('divMenuItem');
		myDiv.style.color = sColor;			
		
	}else if (sDivDisplay =="divMenuItemOverFontColor") {		
		// for sub menu over font color
		myDiv = document.getElementById('divMenuItemOver');
		myDiv.style.color = sColor;			
	}	
		
}



//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// set the menu style for a selected style
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
function fnSetMenuStyle(myObj){
	
	var styleName = myObj;
	
	document.getElementById('txt_MenuStyleId').value = styleName;
	document.getElementById('txt_MenuStyleIdLabel').value = styleName;
	
	var styleActive = document.getElementById(myObj + '_MS_ACTIVE').value;

	if (styleActive=="False"){
		document.getElementById('chk_Active').checked = false;	
	}else{
		document.getElementById('chk_Active').checked = true;
	}

	//-- global properties
	var gblLocation = document.getElementById(myObj + '_MS_LOCATION').value;

	var gblMenuHt = document.getElementById(myObj + '_MS_MENU_HEIGHT').value;

	var gblFlow = document.getElementById(myObj + '_MS_FLOW').value;
	var gblPresetStyle = document.getElementById(myObj + '_MS_PRESET_STYLE').value;
	
	var gblAlign = document.getElementById(myObj + '_MS_ALIGN').value;
	var gblMenuBg = document.getElementById(myObj + '_MS_MENU_BG').value;
	var gblFontFamily = document.getElementById(myObj + '_MS_FONT_FAMILY').value;
	
	document.getElementById('cboLocation').value = gblLocation;
	document.getElementById('cboMenuHeight').value = gblMenuHt;

	if (gblFlow=="H"){
		document.getElementById('optMenuLayout_0').checked = true;	
	}else{
		document.getElementById('optMenuLayout_1').checked = true;
	}
	document.getElementById('cboPresetStyle').value = gblPresetStyle;
	
	document.getElementById('cboAlign').value = gblAlign;	
	fnSetDivProperty('MenuBackground', gblAlign, 'FONTALIGN');
	
	fnSetColorValues(gblMenuBg, 'txtMenuBackground', 'clrMenuBackground', 'divMenuBackground', 'BACKGROUND');
	
	document.getElementById('txtFontFamily').value = gblFontFamily;
	fnSetDivProperty('MainItem', gblFontFamily, 'FONTNAME');


	var mainFontSize = document.getElementById(myObj + '_MS_MAIN_FONT_SIZE').value;
	document.getElementById('txtMainFontSize').value = mainFontSize;	
	fnIsValidSize(document.getElementById('txtMainFontSize'));
	
	//-- main menu properties
	var mainClr = document.getElementById(myObj + '_MS_MAIN_ITEM_COLOR').value;	
	var mainBorder = document.getElementById(myObj + '_MS_MAIN_ITEM_BORDER').value;
	var mainTopClr = document.getElementById(myObj + '_MS_MAIN_ITEM_TOP_COLOR').value;
	var mainBotClr = document.getElementById(myObj + '_MS_MAIN_ITEM_BOT_COLOR').value;
	
	var mainLeftClr = document.getElementById(myObj + '_MS_MAIN_ITEM_LEFT_COLOR').value;
	var mainRightClr = document.getElementById(myObj + '_MS_MAIN_ITEM_RIGHT_COLOR').value;

	var mainFontClr = document.getElementById(myObj + '_MS_MAIN_ITEM_FONT_COLOR').value;
	var mainFontWt = document.getElementById(myObj + '_MS_MAIN_ITEM_FONT_WT').value;
	var mainFontAlign = document.getElementById(myObj + '_MS_MAIN_ITEM_FONT_ALIGN').value;
	
	fnSetColorValues(mainClr, 'txtMainBgColor', 'clrMainBgColor', 'MainItem', 'BACKGROUND');
	fnSetColorValues(mainBorder, 'txtMainBorder', 'clrMainBorder', 'divMainBorder', 'MENUBORDER');
	fnSetColorValues(mainTopClr, 'txtMainTop', 'clrMainTop', 'divMainTop', 'MENUBORDER');
	fnSetColorValues(mainBotClr, 'txtMainBot', 'clrMainBot', 'divMainBot', 'MENUBORDER');
	fnSetColorValues(mainLeftClr, 'txtMainLeft', 'clrMainLeft', 'divMainLeft', 'MENUBORDER');
	fnSetColorValues(mainRightClr, 'txtMainRight', 'clrMainRight', 'divMainRight', 'MENUBORDER');
	fnSetColorValues(mainFontClr, 'txtMainFontColor', 'clrMainFontColor', 'MainItem', 'FONT');
	
	document.getElementById('cboMainFontWt').value = mainFontWt;	
	fnSetDivProperty('MainItem', mainFontWt, 'FONTWT');

	document.getElementById('cboMainFontAlign').value = mainFontAlign;	
	fnSetDivProperty('MainFontColor', mainFontAlign, 'FONTALIGN');

	//-- main menu over properties
	var mainOverClr = document.getElementById(myObj + '_MS_MAIN_OVER_COLOR').value;	
	var mainOverBorder = document.getElementById(myObj + '_MS_MAIN_OVER_BORDER').value;	
	var mainOverTopClr = document.getElementById(myObj + '_MS_MAIN_OVER_TOP_COLOR').value;	
	var mainOverBotClr = document.getElementById(myObj + '_MS_MAIN_OVER_BOT_COLOR').value;	
	var mainOverLeftClr = document.getElementById(myObj + '_MS_MAIN_OVER_LEFT_COLOR').value;	
	var mainOverRightClr = document.getElementById(myObj + '_MS_MAIN_OVER_RIGHT_COLOR').value;	
	var mainOverFontClr = document.getElementById(myObj + '_MS_MAIN_OVER_FONT_COLOR').value;	
	var mainOverFontWt = document.getElementById(myObj + '_MS_MAIN_OVER_FONT_WT').value;	
	var mainOverFontAlign = document.getElementById(myObj + '_MS_MAIN_OVER_FONT_ALIGN').value;	

	fnSetColorValues(mainOverClr, 'txtMainOverBgColor', 'clrMainOverBgColor', 'divMainItemOver', 'BACKGROUND');
	fnSetColorValues(mainOverBorder, 'txtMainOverBorder', 'clrMainOverBorder', 'divMainOverBorder', 'MENUBORDER');
	fnSetColorValues(mainOverTopClr, 'txtMainOverTop', 'clrMainOverTop', 'divMainOverTop', 'MENUBORDER');
	fnSetColorValues(mainOverBotClr, 'txtMainOverBot', 'clrMainOverBot', 'divMainOverBot', 'MENUBORDER');
	fnSetColorValues(mainOverLeftClr, 'txtMainOverLeft', 'clrMainOverLeft', 'divMainOverLeft', 'MENUBORDER');
	fnSetColorValues(mainOverRightClr, 'txtMainOverRight', 'clrMainOverRight', 'divMainOverRight', 'MENUBORDER');
	fnSetColorValues(mainOverFontClr, 'txtMainOverFontColor', 'clrMainOverFontColor', 'divMainItemOver', 'FONT');	
	
	document.getElementById('cboMainOverFontWt').value = mainOverFontWt;	
	fnSetDivProperty('divMainItemOver', mainOverFontWt, 'FONTWT');

	document.getElementById('cboMainOverFontAlign').value = mainOverFontAlign;	
	fnSetDivProperty('divMainItemOverAlign', mainOverFontAlign, 'FONTALIGN');
	
	//-- sub menu properties

	var subFontSize = document.getElementById(myObj + '_MS_SUB_FONT_SIZE').value;
	document.getElementById('txtMenuItemFontSize').value = subFontSize;	
	fnIsValidSize(document.getElementById('txtMenuItemFontSize'));

	var subClr = document.getElementById(myObj + '_MS_SUB_ITEM_COLOR').value;		
	var subBorder = document.getElementById(myObj + '_MS_SUB_ITEM_BORDER').value;			
	var subTopClr = document.getElementById(myObj + '_MS_SUB_ITEM_TOP_COLOR').value;		
	var subBotClr = document.getElementById(myObj + '_MS_SUB_ITEM_BOT_COLOR').value;	
	var subLeftClr = document.getElementById(myObj + '_MS_SUB_ITEM_LEFT_COLOR').value;		
	var subRightClr = document.getElementById(myObj + '_MS_SUB_ITEM_RIGHT_COLOR').value;	

	var subFontClr = document.getElementById(myObj + '_MS_SUB_ITEM_FONT_COLOR').value;		
	var subFontWt = document.getElementById(myObj + '_MS_SUB_ITEM_FONT_WT').value;		
	var subFontAlign = document.getElementById(myObj + '_MS_SUB_ITEM_FONT_ALIGN').value;		
	
	fnSetColorValues(subClr, 'txtMenuItemBgColor', 'clrMenuItemBgColor', 'divMenuItem', 'BACKGROUND');
	fnSetColorValues(subBorder, 'txtMenuItemBorderColor', 'clrMenuItemBorderColor', 'divMenuItemBorder', 'MENUBORDER');
	fnSetColorValues(subTopClr, 'txtMenuItemTop', 'clrMenuItemTop', 'divMenuItemTop', 'MENUBORDER');
	fnSetColorValues(subBotClr, 'txtMenuItemBot', 'clrMenuItemBot', 'divMenuItemBot', 'MENUBORDER');
	fnSetColorValues(subLeftClr, 'txtMenuItemLeft', 'clrMenuItemLeft', 'divMenuItemLeft', 'MENUBORDER');
	fnSetColorValues(subRightClr, 'txtMenuItemRight', 'clrMenuItemRight', 'divMenuItemRight', 'MENUBORDER');

	fnSetColorValues(subFontClr, 'txtMenuItemFontColor', 'clrMenuItemFontColor', 'divMenuItem', 'FONT');		
	
	document.getElementById('cboMenuFontWt').value = subFontWt;	
	fnSetDivProperty('divMenuItem', subFontWt, 'FONTWT');

	document.getElementById('cboMenuFontAlign').value = subFontAlign;	
	fnSetDivProperty('divMenuItemAlign', subFontAlign, 'FONTALIGN');
	
	//-- sub menu over properties
	var subOverClr = document.getElementById(myObj + '_MS_SUB_OVER_COLOR').value;	
	var subOverBorder = document.getElementById(myObj + '_MS_SUB_OVER_BORDER').value;		
	var subOverTopClr = document.getElementById(myObj + '_MS_SUB_OVER_TOP_COLOR').value;		
	var subOverBotClr = document.getElementById(myObj + '_MS_SUB_OVER_BOT_COLOR').value;		
	var subOverLeftClr = document.getElementById(myObj + '_MS_SUB_OVER_LEFT_COLOR').value;		
	var subOverRightClr = document.getElementById(myObj + '_MS_SUB_OVER_RIGHT_COLOR').value;		

	var subOverFontClr = document.getElementById(myObj + '_MS_SUB_OVER_FONT_COLOR').value;		
	var subOverFontWt = document.getElementById(myObj + '_MS_SUB_OVER_FONT_WT').value;		
	var subOverFontAlign = document.getElementById(myObj + '_MS_SUB_OVER_FONT_ALIGN').value;
	
	fnSetColorValues(subOverClr, 'txtMenuItemOverBgColor', 'clrMenuItemOverBgColor', 'divMenuItemOver', 'BACKGROUND');
	fnSetColorValues(subOverBorder, 'txtMenuItemOverBorderColor', 'clrMenuItemOverBorderColor', 'divMenuItemOverBorder', 'MENUBORDER');
	fnSetColorValues(subOverTopClr, 'txtMenuItemOverTop', 'clrMenuItemOverTop', 'divMenuItemOverTop', 'MENUBORDER');
	fnSetColorValues(subOverBotClr, 'txtMenuItemOverBot', 'clrMenuItemOverBot', 'divMenuItemOverBot', 'MENUBORDER');
	fnSetColorValues(subOverLeftClr, 'txtMenuItemOverLeft', 'clrMenuItemOverLeft', 'divMenuItemOverLeft', 'MENUBORDER');
	fnSetColorValues(subOverRightClr, 'txtMenuItemOverRight', 'clrMenuItemOverRight', 'divMenuItemOverRight', 'MENUBORDER');

	fnSetColorValues(subOverFontClr, 'txtMenuItemOverFontColor', 'clrMenuItemOverFontColor', 'divMenuItemOver', 'FONT');		

	document.getElementById('cboMenuOverFontWt').value = subOverFontWt;	
	fnSetDivProperty('divMenuItemOver', subOverFontWt, 'FONTWT');

	document.getElementById('cboMenuOverFontAlign').value = subOverFontAlign;	
	fnSetDivProperty('divMenuItemOverAlign', subOverFontAlign, 'FONTALIGN');
	
}	
	

