<!-- hide from old browsers
//alert('sharedscripts up');
var appleDevice=0;
var curTogDiv=0;
var openDivs=new Array();
var validate=0;
var httpsPg=0;
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;    // true if we're on ie
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false; // true if we're on windows
//reset popwin variables
var popWin=0, popWin_x=0, popWin_y=0, popWin_h=0, popWin_w=0;
//reset nav variables
var curAccessArea="", navMainData=new Array(), navSubData=new Array();
//var defAdminPanel="";
var availableImgs1=new Array(), availableImgs2=new Array(), availableImgs3=new Array();

function jqueryFormReset(formID,skipCheckboxes,skipRadioBtns){
	$(':input','#'+formID).not(':button, :submit, :reset, :hidden').val('');
	if(skipCheckboxes!=1){$(':input','#'+formID).removeAttr('checked');}
	if(skipRadioBtns!=1){$(':input','#'+formID).removeAttr('selected');}
}

//STANDARD SUBSCRIBE, EMAIL AND SEARCH FUNCTIONS
function runSearch(fmName,txtField){if($("#"+(txtField?txtField:"st")).val()==""||$("#"+(txtField?txtField:"st")).val()=="Search"){alert("Please enter search text");return false;}else{$("#"+(fmName?fmName:"searchForm")).submit();}}

function eReferral(altTitle){openOverlay('iframe',(altTitle!=null?altTitle:(typeof eRefTitle!='undefined'?eRefTitle:'Email Link to a Friend')),'/content/forms/referral.php?p=ref',390,300);}

function eSubscribe(optType,altTitle){openOverlay('iframe',(altTitle!=null?altTitle:(typeof eSubTitle!='undefined'?eSubTitle:'Subscribe to Mailing List')),'/content/forms/subscription.php?prc=sub&opt='+optType,390,220);}

function eUnsubscribe(optType,altTitle){openOverlay('iframe',(altTitle!=null?altTitle:(typeof eUnsubTitle!='undefined'?eUnsubTitle:'Unsubscribe to Mailing List')),'/content/forms/subscription.php?prc=unsub&opt='+optType,390,180);}

function eSubscribeAJAX(step,op,data){
	switch(step){
		case 1:
			//make sure an email address, and name if included, are supplied
			//if($("#subEmail_"+op).val()=='' || $("#subEmail_"+op).val().indexOf('Email')!=-1){alert("Please enter your email address");$("#subEmail_"+op).focus();return;}
			//validate the email - THIS FUNCTION is found in he validator.js script, so that script must be available for this to work properly
			if($("#subEmail_"+op).length>0 && validateEmailv2($("#subEmail_"+op).val())==false){alert("Please enter a valid email address");$("#subEmail_"+op).focus();return;}
			if($("#subName_"+op).length>0 && $("#subName_"+op).val()==''){alert("Please enter your name");$("#subName_"+op).focus();return;}
			//submit the subscription
			$("#subBtn_"+op).css('display','none');
			$("#subProcess_"+op).css('display','block');
			em=$("#subEmail_"+op).length>0?$("#subEmail_"+op).val():'';
			nm=$("#subName_"+op).length>0?$("#subName_"+op).val():'';
			$.post("/content/forms/subscription-process.php",{prc:'subGo',opt:op,eAdd:em,name:nm},function(html){eSubscribeAJAX(2,op,html);});
		break;	
		case 2:
			//display the submission process response and reset the subscription form
			alert(data);
			$("#subBtn_"+op).css('display','block');
			$("#subProcess_"+op).css('display','none');
			if($("#subEmail_"+op).length>0){$("#subEmail_"+op).val('');}
			if($("#subName_"+op).length>0){$("#subName_"+op).val('');}
		break;
	}
}

//COMMENTS CONTROL
var cmtBtnID=0;
function submitComments(data,step,table,cID,ckCaptcha,toggleInput){
	//alert('submit comments, step '+step);	
	switch(step){
		case 1:
			$("#subBtn"+cID).css('display','none');
			$("#subProcess"+cID).css('display','block');
			//alert($("#cmtForm"+cID+" #recaptcha_challenge_field").val());
			//test the captcha IF in use
			if(ckCaptcha==1){
				ckVals={recaptcha_challenge_field:$("#cmtForm"+cID+" #recaptcha_challenge_field").val(),recaptcha_response_field:$("#cmtForm"+cID+" #recaptcha_challenge_field").val()};
				$.post("/_libs/recaptchack.php",ckVals,function(html){submitComments(html,2,table,cID,toggleInput);});
			}else{
				submitComments('valid',2,table,cID,toggleInput);
			}
			return false;
		break;	
		case 2:
			//if captcha entry is incorrect, display the error, reset the submit button and load a new captcha
			if(data!='valid'){
				$("#subBtn"+cID).css('display','block');
				$("#subProcess"+cID).css('display','none');
				alert("The visual confirmation was not completed correctly. Please try again.");
				Recaptcha.reload();
			}else{
				$.post("/_panels/admin/_comments_process.php",{uc:1,tbl:table,rID:cID,cDo:'post',em:$("#em"+cID).val(),nm:$("#nm"+cID).val(),cmt:$("#cmt"+cID).val()},function(html){submitComments(html,3,table,cID,toggleInput);});
			}
			return false;
		break;
		case 3:
			$("#subBtn"+cID).css('display','block');
			$("#subProcess"+cID).css('display','none');
			if(parseInt(data)>0){
				alert("Thank you for your comments."+(parseInt(data)==1?" They have been received and will be reviewed shortly.":""));
				//route differently for immediately approved comments, and moderated comments
				if(parseInt(data)==2){ //if the comment is immediately live, reload the page to show it
					//tmp=window.location.href.split('#'); window.location=tmp[0]+"#comments"; window.location.reload();
					tpl=$("#cmtTpl"+cID).clone(false).attr('id','cmt'+(new Date().getTime()));
					tpl.html(tpl.html().replace('%NAME%',$("#nm"+cID).val()));
					tpl.html(tpl.html().replace('%DATE%',(new Date().toLocaleDateString())));
					tpl.html(tpl.html().replace('%COMMENTS%',$("#cmt"+cID).val().replace(/\n/g, '<br />')));
					tpl.appendTo($('#cmtAdd'+cID));
					$("#curCmtCt"+cID).html(parseInt($("#curCmtCt"+cID).html())+1); //update the comment count
					if($("#bblCmtCt"+cID).length!=0){$("#bblCmtCt"+cID).html(parseInt($("#bblCmtCt"+cID).html())+1);} //update the bubble comment count if available
				}//else{ //if the comments require review, simply clear the form and hide it if requested
				$("#em"+cID).val(''); $("#nm"+cID).val(''); $("#cmt"+cID).val(''); //Recaptcha.reload();
				if(toggleInput==1){toggleContDiv('ac'+cID,'ADD COMMENT','','CANCEL COMMENT','','',300,0);}
			}else{
				alert("Sorry, you comments could not be submitted. Please try again.");
			}
		break;
	}
}

//SHADOWBOX OVERLAY CONTROL
function openOverlay(oPlayer,oTitle,oContent,oWidth,oHeight,pgHash){
	//if pgHash was sent, then we update the Hash in the browser URL as well
	if(pgHash!=null && pgHash!=0 && top.curURL!=null){top.goPage(top.curURL+'#ol.'+pgHash);}
	//set defaults for any missing arguments
	if(oPlayer==0 || oPlayer==null){oPlayer='iframe';}
	if(oTitle==0 || oTitle==null){oTitle='';}
	if(oContent==0 || oContent==null){oContent='';}
	//if the current page is under https and we're opening an iframe, make sure the iframe is also under https
	if(oPlayer=='iframe' && httpsPg==1){oContent+=(oContent.indexOf('?')==-1?'?':'&')+'https=1';}
	/*if(oPlayer=='iframe' && httpsPg==1 && oContent.indexOf('https')==-1){
		if(oContent.indexOf('http://')!=-1){
			oContent=oContent.split('http').join('https');
		}else{
			oContent='https://'+curHost+oContent+(oContent.indexOf('?')==-1?'?':'&')+'https=1';
		}
	}*/
	if(oWidth==0 || oWidth==null){oWidth=600;}
	if(oHeight==0 || oHeight==null){oHeight=450;}
	//open contact form overlay
	Shadowbox.open({
		player:     oPlayer,
		title:      oTitle,
		content:    oContent,
		width:      oWidth,
		height:     oHeight
	});
}
	
//function to automatically close the shadowbox overlay when the playing video is completed
function closeShadowboxVid(){
	if(top.closeShadowboxInt==null || top.closeShadowboxInt==0){top.closeShadowboxInt=setInterval('closeShadowboxVid();',500);}
	vidState=shadowbox_content.getConfig().state;
	//alert('vid state='+vidState);
	if(vidState=='COMPLETED'){clearInterval(top.closeShadowboxInt);top.Shadowbox.close();}
}

//load gallery function
function lg(gID,gTable,gImg){
	top.Shadowbox.open(top['gc_'+gTable+gID][gImg?gImg:0]);
	goPage(top.curURL+'#gc.'+gTable+'.'+gID);
}

//media play functions
function vidEmbedClose(){$("#vidEmbedDiv").remove();}

function vidEmbedHide(){$("#vidEmbedDiv").css({'z-index':-100,'left':-2000});}

function mp(vFile,vTitle,vWidth,vHeight,useHD){
	//alert('in mp, Shadowbox='+Shadowbox);
	if(vTitle==null){vTitle="";}
	//if video height and/or width were not sent, use the default values for SD and HD content
	if(vWidth==null||vWidth==0){vWidth=(parseInt(useHD)==1?(vWidthHD?vWidthHD:"640"):(vWidthSD?vWidthSD:"480"));}
	if(vHeight==null||vHeight==0){vHeight=(parseInt(useHD)==1?(vHeightHD?vHeightHD:"360"):(vHeightSD?vHeightSD:"360"));}
	//if(useHD==1){vWidth=(vHeight/9)*16;}else{useHD=0;}
	//add the standard video filepath to the vFile variable if it does not already have a path included
	if(vFile.indexOf('/')!=0){vFile='/_uploads/_media_uploads/'+vFile;}
	//create an html5 video embed if this is an apple mobile device
	if(appleDevice==1){
		//remove any existing embed overlay
		vidEmbedClose();
		//build the dynamic video display object
		qtObj='<div id="vidEmbedDiv" style="position:fixed;z-index:-100;left:-2000px;">';
		//qtObj='<div id="vidEmbedDiv" style="position:fixed;padding:10px;background:#ccc;border:1px solid #888;">';
		//qtObj+='<a href="javascript:vidEmbedClose();" style="display:block;padding-bottom:5px;font-weight:bold;">X Close</a>';
		qtObj+='<video'+(posterImg?' poster="'+posterImg+'"':'')+' controls="controls" id="videoEmbedObj">'; // width="'+vWidth+'" height="'+vHeight+'" autoplay="autoplay"
		qtObj+='<source src="'+vFile+'" type="video/mp4" />';
		qtObj+='</video></div>';
		//insert the new video object at the top of the page body
		$("body").after(qtObj);
		//center the overlay
		//wSize=window.center();
		/*wSize.y=$(window).height()/2; //TO USE FIXED POSITION POPUPS, WE NEED VIEWPORT HEIGHT, NOT PAGE-TOP RELATIVE HEIGHT*/
		//xOffset=parseInt(vWidth)/2;yOffset=parseInt(vHeight)/2;
		//$("#vidEmbedDiv").css('left',(wSize.x-xOffset>10?wSize.x-xOffset:10)); $("#vidEmbedDiv").css('top',(wSize.y-yOffset>10?wSize.y-yOffset:10));
		//autoplay the video
		var pElement = document.getElementById("videoEmbedObj");
		pElement.load();
		pElement.play();
		//NOTE THAT for the moment, iOS seems to be allowing autoplay to happen, so we're automatically hiding the overlay
		//if autoplay doesnt work in the future, comment out the vidEmbedHide() function call AND uncomment the centering code above
		//vidEmbedHide();
	}else{
		Shadowbox.open({player:'flv',title:vTitle,content:vFile,height:vHeight,width:vWidth});
	}
	if(curURL!=null){goPage(curURL+'#ov.'+useHD+'.'+escape(vFile));}
}

function updateCompProgBar(progData){
	//alert('updateCompProgBar, progData= '+progData);
	progData=progData.split('|');
	//if compData[0]>=100 then reload the page - but ONLY if a popWin is not open
	if(parseInt(progData[0])>=100 && popWin==0){
		//alert('refresh panel');
		top.refreshPanel(); //setTimeout("top.refreshPanel()",1500);
	}else{
		//otherwise update the progress bar
		$("#uploadProgBar_"+progData[1]).progressCtrl(parseInt(progData[0]));
	}
}

function firstCharUpper(txt){
	return txt.substr(0,1).toUpperCase()+txt.substr(1);
}

function addCommas(nStr){
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}

function addInputField(col){
	if(popWin.$('#'+col+'Inputs')!=null){
		popWin[col+'Ct']++;
		addHTML='<div style="padding:3px 0px 3px 30px;"><nobr><span class="bodySmallPlain">'+popWin[col+'Label']+' '+popWin[col+'Ct']+':</span> ';
		addHTML+='<input type="text" name="'+col+'_'+popWin[col+'Ct']+'" id="'+col+'_'+popWin[col+'Ct']+'" value="" style="width:440px;" /></nobr></div>';
		popWin.$('#'+col+'Inputs').append(addHTML);
		//also increment the input line count tracking hidden input variable
		//alert(popWin.$('#inputCt__'+col).attr('value'));
		popWin.$('#inputCt__'+col).attr('value',popWin[col+'Ct']);
		//alert(popWin.$('#inputCt__'+col).attr('value'));
	}
}

function jqueryScroll(anchorID,speed){
	if(speed==null){speed=800;}
	$.scrollTo('#'+anchorID,speed,{easing:'easeInOutQuad'});
}

function goPage(page){
	window.top.location=page;
}

function assocUpdate(frameID,inputID,area){
	//alert('in assocProdUpdate');
	pathPrefix=getPathPrefix(area,1);
	framePrefix=getPathPrefix(area,0);
	assocString="";
	items=framePrefix.frames[frameID].document.getElementsByTagName('input');
	for(i=0;i<items.length;i++){
		if(items[i].checked){
			//tilda separate values
			if(assocString!=""){assocString+="~";}
			assocString+=items[i].name;
		}
	}
	//alert(assocString);
	//alert(pathPrefix.tableForm[inputID]);
	//now attach any value found for associated items to the database input variable
	pathPrefix.tableForm[inputID].value=assocString;
	return true;
}

function leaveDiv(e,divName) {
if (!e) var e = window.event;
var tg = (window.event) ? e.srcElement : e.target;
if (tg.nodeName != 'DIV'){return;}
//now work backwards from the current target to make sure we arent in a sub object from the actual target div
var reltg = (e.relatedTarget) ? e.relatedTarget : e.toElement;
while (reltg != tg && reltg.nodeName != 'BODY'){
	reltg= reltg.parentNode;
	if (reltg== tg){return;}
}
// Mouseout took place when mouse actually left layer
// Handle event
//alert('mouse out of div');
//hidediv("dropdown_menu");//another fx that works fine
toggleDivVisible(divName,0)
}


function toggleDivShow(divName,animDur){
	//alert('in toggleDivShow'); 
	if(divObj=findObjectPath(divName)){
		displayChange = (divObj.style.display == 'none') ? 'block' : 'none';
		divObj.style.display=displayChange;
		fixIEBug();
	}
}	

function toggleDivVisible(divName,direction){
	//alert('in toggleDivVisible'); 
	if(divObj=findObjectPath(divName)){
		//alert(divObj);
		if(direction=='1'){divObj.style.display='block';}
		if(direction=='0'){divObj.style.display='none';}
		fixIEBug();
	}
}


function toggleTransp(objName,direction){
	if(obj=findObjectPath(objName)){
		//alert(obj.name);
		if(direction=='1'){ 
			obj.setAttribute("class", "semiTransparent");
			obj.setAttribute("className", "semiTransparent");
		}
		if(direction=='0'){
			obj.setAttribute("class", "opaque");
			obj.setAttribute("className", "opaque");
		}
	}
}


function assocListUpdate(colName,area){
	//alert('in assocListUpdate');
	pathPrefix=getPathPrefix(area,1);
	framePrefix=getPathPrefix(area,0);
	assocString="";
	//assocList=framePrefix.frames['iframeList_'+colName].document.getElementsByTagName('input');
	alert(framePrefix.frames[colName+'_iframe'].document);
	assocList=framePrefix.frames[colName+'_iframe'].document.getElementsByTagName('input');
	for(i=0;i<assocList.length;i++){
		if(assocList[i].checked){
			//tilda separate values
			if(assocString!=""){assocString+="~";}
			assocString+=assocList[i].name;
		}
	}
	//alert(assocString);
	//alert(pathPrefix.tableForm['db__'+colName]);
	//now attach any value found for associated items to the hidden input element for this variable
	pathPrefix.tableForm['db__'+colName].value=assocString;
	//alert(pathPrefix.tableForm['db__'+colName].value);
	return true;
}


function toggleOpenNavFS(togVal){
	openFSobj=findObjectPath('openNavFS');
	//alert(openFSobj);
	if(openFSobj!=null){openFSobj.value=togVal;}
}


function updateTabState(navTab,newFlag,updateNav){
	//alert('in updateTabState, navTab='+navTab+" newFlag="+newFlag);
	//this function allows javascript to update the tabFlag entry in the navMainData array
	navTabs=navTab.split("__");
	for(i=0;i<navMainData.length;i++){
		if((navObj=findObjectPath(navMainData[i][1],'navTop')) && (navMainData[i][1]==navTabs[0])){
			//the nav tab was found, so update the tabFlag
			navMainData[i][4]=newFlag;
			//now update the nav bar, and exit the function
			if(updateNav){
				if(navObj && navMainData[i][4]=='dead'){
					navObj.className='headerNavDead';
				}else if(navObj && navMainData[i][4]=='done'){
					navObj.className='headerNavDone';
				}
			}
			break;
		}
	}
}


function goNavFrame(navTab,filePath,updateNav,linkVars){
	//alert('in goNavFrame');
	//navMainData and navSubData are arrays created by the navTop.php script - curAccessArea holds the current accessArea name
	decision=true;
	//first see if there are any warnings or pre-processing required for the area we are GOING TO
	switch(navTab){
		case "adminPanels":
			//reset the default admin panel for initial display
			//if(defAdminPanel==null){defAdminPanel=0;}
			if(defAdminObj=findObjectPath("defAdminPanel",'navTop')){parseInt(defAdminPos=defAdminObj.value);}else{defAdminPos=0;}
			//if(selectObj=findObjectPath('panelList','navTop')){selectObj.options[defAdminPanel].selected=1;}
			if(selectObj=findObjectPath('panelList','navTop')){selectObj.options[defAdminPos].selected=1;}
			if(addRecsObj=findObjectPath('addRecords','navTop')){addRecsObj.style.display='none';}
			//update the default top panel controls for this new admin panel
			//top.switchPanels(1);
		break;
	}
	//alert('next step');
	//next see if there are any warnings or pre-processing required for the area we are LEAVING (curAccessArea is the CURRENTLY LIVE TAB)
	//alert(curAccessArea.indexOf('cciModules'));
	switch(curAccessArea){
		case "posasap":
		case "marketingMaterials__posasap":
			decision=confirm('Are you sure you want to leave P.O.S. ASAP?\nAny unsaved changes will be lost.');
		break;
	}
	if(curAccessArea.indexOf('cciModules')==0){
		decision=confirm('Are you sure you want to leave the current training module?');
	}
	//if the user didnt click cancel on an option dialog above, continue here
	if(decision==true){
		navArrayLoc=0;
		navTabs=navTab.split("__");
		//reset main and sub nav
		if(updateNav==1){
			titleObj=findObjectPath('navTitle','navTop');
			titleObj.innerHTML="";
			//subTitleObj=findObjectPath('navSubTitle','navTop');
			//subTitleObj.innerHTML="";
			//alert(navTabs[0]);
			//alert(navMainData.length);
			for(i=0;i<navMainData.length;i++){
				//toggle the sub nav if it exists
				if((subObj=findObjectPath(navMainData[i][1]+"_sub",'navTop')) && (navMainData[i][1]+"_sub"==navTabs[0]+"_sub")){
					subObj.style.display='block';
					subObj.className='headerSubMenu';
					//also set the correct sub menu link hilighting
					for(ii=0;ii<navSubData[navArrayLoc].length;ii++){
						if((subLinkObj=findObjectPath(navSubData[i][ii],'navTop')) && (navTab==navSubData[i][ii])){
							//alert('found sub');
							subLinkObj.className='headerSubLive';
							//update the sub title as well
							//subTitleObj.innerHTML='&nbsp;&#x203a; '+subLinkObj.innerHTML;
						}else if(subLinkObj){
							subLinkObj.className='headerSub';
						}
					}
				}else if(subObj){
					subObj.style.display='none';
					subObj.className='offScreen';
				}
				//toggle the main nav if it exists
				if((navObj=findObjectPath(navMainData[i][1],'navTop')) && (navMainData[i][1]==navTabs[0])){
					//capture the array position of this nav item
					navArrayLoc=i;
					//insert the correct title 
					titleObj.innerHTML=navMainData[navArrayLoc][3];
					//setup the correct CSS class
					navObj.className='headerNavLive';
				}else if(navObj && navMainData[i][4]=='dead'){
					navObj.className='headerNavDead';
				}else if(navObj && navMainData[i][4]=='done'){
					navObj.className='headerNavDone';
				}else if(navObj){
					navObj.className='headerNavLink';
				}
			}
		}
		//save the new accessArea variable
		curAccessArea=navTab; goString="";
		//now go to the requested nav frame
		if(filePath=='useRouter'){
			goString='/_libs/access_router.php?accessArea='+navTab+"&";
		}else if(filePath!=null && filePath!=''){
			goString=filePath+"?";
		}
		//add any GET link variables we need to pass along (mm_index uses this)
		if(linkVars!=null){goString+=linkVars;}
		//finally GO FORTH!.. unless filePath==none, in which case we simply wanted to update the nav
		//alert('goString='+goString);
		if(filePath!='none'){window.top.bottomFrame.location=goString;}
	}
}


function checkPopSize(){resizePopup(1,1,0,0,'modifyTable');}


function resizePopup(resizeHeight,resizeWidth,forceHeight,forceWidth,resizeObj){
	//popWin.alert('resizeHeight='+resizeHeight+" resizeWidth="+resizeWidth);
	//if height or width force sizing was sent, use that
	if(resizeHeight==1 || resizeWidth==1){
		//if(typeof popWin.$ != 'undefined'){
		//	h=popWin.$('#modifyTable').height(); w=popWin.$('#modifyTable').width();
		//	h=popWin.$('#modifyTable').height(); w=popWin.$('#modifyTable').width();
		//}else{
		if(resizeObj!=null){refObj=resizeObj;}else{refObj='contentDiv';}
		divObj=findObjectPath(refObj,'popWin');
		h=divObj.offsetHeight; w=divObj.offsetWidth;
		//}
		//force the width or height if requested
		if(forceHeight!=null && forceHeight!=0){h=forceHeight;}
		if(forceWidth!=null && forceWidth!=0){w=forceWidth;}
		//enlarge the popup size - IE and FF require the large vertical extension - camino and safari could go with half or less of this amount
		//the horizontal extension is mostly for IE, but all benefit visually from a little more horizontal space
		//popWin.alert('popWin_h:'+popWin_h+', h:'+h);
		if(popWin_h>=h){resizeHeight=0;}else{h+=120;}
		if(popWin_w>=w){resizeWidth=0;}else{w+=40;} 
		//dont let the height get larger than the screen height or width minus 46
		//NOTE that if we have to reduce size in one dimension, enlarge the other dimension a bit to compensate for appearance of the resized dimension's scroll bar
		if(h>(screen.height-40)){h=screen.height-46;w+=35;}
		y=Math.round((screen.height - h)/2);
		if(w>(screen.width-40)){w=screen.width-46;h+=35;}
		x=Math.round((screen.width - w)/2);
		//now resize and reposition the popup window - ONLY continue if the new popwin width or height is different than the saved value
		if(resizeHeight==0){y=popWin_y;h=popWin_h;}
		if(resizeWidth==0){x=popWin_x;w=popWin_w;}
		popWin.moveTo(x,y)
		popWin.resizeTo(w,h);
		//save the current x,y,h & w
		popWin_x=x, popWin_y=y, popWin_h=h, popWin_w=w;
	}
	return
}


function calcHeight(){
  //find the height of the internal page
  var the_height=document.getElementById('the_iframe').contentWindow.document.body.scrollHeight;
 //change the height of the iframe
  document.getElementById('the_iframe').height=the_height;
}


function existingFileDownload(checkName,curFile,area){
	//if there is an image select menu for this checkName, then use its value for download, otherwise
	if(selectList=findObjectPath(checkName+"__select",area)){
		//alert('select list found');
		newFile=selectList.options[selectList.selectedIndex].value;
		//if the selection in the select menu has a value, then use it as the download image
		if(newFile!=""){curFile=newFile;}
	}
	location.href='/_libs/file_download.php?src='+curFile;

}


function toggleUnderline(checkName,toggle,area){
	if(textObj=findObjectPath(checkName,area)){
		switch(toggle){
			case 'over':
				textObj.style.textDecoration='underline';
				break;
				
			case 'norm':
				textObj.style.textDecoration='none';
				break;
		}
	}
}


function fileSelectStart(checkName,area){
	//function to automatically move a select list to a given entry based upon text found in the startField - good for moving around in huge select lists
	//alert('in fileSelectStart');
	selectList=findObjectPath(checkName+"__select",area);
	startField=findObjectPath("fileSelectStart",area);
	if(selectList!=null && startField!=null && selectList.selectedIndex==0 && startField.value!=""){
		//NOTE - if startField.value=="useCustomSelectStart", then call the customSelectStart function found in the site.js script
		if(startField.value=="useCustomSelectStart"){
			customSelectStart(checkName,area);
		}else{
			//alert('ok to reposition');
			for(ii=0;ii<selectList.options.length;ii++){
				if(selectList.options[ii].value.indexOf(startField.value)!=-1){
					//alert('found match');
					selectList.selectedIndex=ii-1;
					break;
				}
			}
		}
	}
}


function restrictSelect(checkName,area){
	//function to automatically restrict a list selection to selections whose value includes the value of the startField
	//alert('in fileSelectStart');
	selectList=findObjectPath(checkName+"__select",area);
	startField=findObjectPath("fileSelectStart",area);
	if(selectList && startField && selectList.selectedIndex!=0 && startField.value!=""){
		if(selectList.options[selectList.selectedIndex].value.indexOf(startField.value)==-1){
			selectList.selectedIndex=0;
		}
	}
}


function toggleFileDisplay(checkName,toggle,area,arg4,arg5){
	//alert('in toggleFileDisplay, checkName='+checkName);
	//get the file type, if there is one
	//alert('in toggleFileDisplay');
	if(fileType=findObjectPath(checkName+"__fType",area)){fType=fileType.value;}else{fType='file';}
	showFile="";hidePreview=0;
	switch(toggle){
		case "select":
			//reset the file upload, if there is one
			if(fileUpload=findObjectPath(checkName+"__new",area)){fileUpload.value="";}
			//reset remove checkbox if there is one
			if(removeBox=findObjectPath(checkName+'__remove',area)){removeBox.checked=0;}
			//modify the selection if needed
			if(selectList=findObjectPath(checkName+'__select',area)){
				selectFile=selectList.options[selectList.selectedIndex].value;
				if(selectFile==""){
					//if there is no saved image, set status to 'no image', otherwise revert to the saved image
					if(savedFile=findObjectPath(checkName+"__saved",area)){
						toggleFileDisplay(checkName,'saved',area);
						//revertToSaved(checkName,area);
					}else{
						//update the image status if there is one
						changeText('statDiv_'+checkName,'(no&nbsp;'+fType+')','#830000',area);
						showFile='/_images/shared/_xc_image_noUpload.jpg';
						hidePreview=1;
					}
				}else{
					//if the current selected image matches the saved image, say 'image ok', otherwise say 'new selection'
					if((savedFile=findObjectPath(checkName+"__saved",area)) && (savedFile.value==selectFile)){
						toggleFileDisplay(checkName,'saved',area);
					}else{
						//update the image status if there is one
						changeText('statDiv_'+checkName,'(new&nbsp;selection)','#A99228',area);
					}
				}
			}
			break;
		case "new":
			//reset the select list if there is one
			if(selectList=findObjectPath(checkName+"__select",area)){selectList.selectedIndex=0;}
			//reset remove checkbox if there is one
			if(removeBox=findObjectPath(checkName+'__remove',area)){removeBox.checked=0;}
			//update the image status if there is one
			changeText('statDiv_'+checkName,'(new&nbsp;upload)','#A99228',area);
			//show the upload image placeholder in the preview frame
			showFile="/_images/shared/_xc_image_uploadReady.jpg";
			break;
		case "remove":
			if(checkObj=findObjectPath(checkName+'__remove',area)){
				if(checkObj.checked==1){
					//reset the caption, if there is one
					if(fileCaption=findObjectPath("db__"+checkName+"_cap",area)){fileCaption.value="";}
					//reset the file upload, if there is one
					if(fileUpload=findObjectPath(checkName+"__new",area)){fileUpload.value="";}
					//reset file rename, if there is one
					if(fileRename=findObjectPath(checkName+"__rename",area)){fileRename.value="";}
					//reset the select list if there is one
					if(selectList=findObjectPath(checkName+"__select",area)){selectList.selectedIndex=0;}
					//update the image status if there is one
					changeText('statDiv_'+checkName,'(remove&nbsp;'+fType+')','#A99228',area);
					//show the upload image placeholder in the preview frame
					showFile="/_images/shared/_xc_image_remove.jpg";
					hidePreview=1;
				}else{
					//revert to the saved image (remove button wouldn't be available if there wasn't one)
					toggleFileDisplay(checkName,'saved',area);
					//revertToSaved(checkName,area);
				}
			}
			break;
		case "saved":
			//reset the file upload, if there is one
			if(fileUpload=findObjectPath(checkName+"__new",area)){fileUpload.value="";}
			//reset remove checkbox if there is one
			if(removeBox=findObjectPath(checkName+'__remove',area)){removeBox.checked=0;}
			//make sure we havge a saved image before continuing
			if(savedFile=findObjectPath(checkName+"__saved",area)){
				//if there is a select list, move it to the position of the saved image
				selectList=findObjectPath(checkName+"__select",area);
				//there may be a selectList input that IS NOT actually a select list, so determine that here
				if(selectList!=null){
					if(selectList.options!=null){
						//find the saved image in the list - then update the list to reflect that image and break out of the for loop
						for(ii=0;ii<selectList.options.length;ii++){
							if(selectList.options[ii].value==savedFile.value){selectList.selectedIndex=ii;break;}
						}
					}
				}
				//use the saved image in the image preview
				showFile=savedFile.value;
				//update the image status if there is one
				changeText('statDiv_'+checkName,'('+fType+'&nbsp;ok)','#174917',area);
			}
			break;
		case "matchField":
			//NOTE - this is currently incompatible with popups wherein the image list is available as a select list BECAUSE in those cases, the javascript image list is not created
			//alert(checkName+"__array");
			//if(selectList=findObjectPath(checkName+'__select',area)){selectList.value="";}
			fileArray=checkName+"__array";
			//if a file upload is selected, ignore this whole sectiontoggleContDiv
			if((fileUpload=findObjectPath(checkName+"__new",area)) && (fileUpload.value!="")){return;}
			//now search for file matches
			if((fieldObj=findObjectPath(arg4,area)) && (popWin[fileArray]!=null)){
				fieldText=fieldObj.value;
				for(inc in popWin[fileArray]){
					basename=popWin[fileArray][inc].split("/");
					filename=basename[basename.length-1];
					basename=filename.substr(0,filename.length-4);
					//check for a file match - use the arg5 suffix if sent
					if(arg5==null){arg5="";}
					if((fieldText+arg5)==basename){
					 	//alert('found match');
						showFile=popWin[fileArray][inc];
						changeText('statDiv_'+checkName,'('+fType+'&nbsp;ok)','#174917',area);
						changeText('dispFileName_'+checkName,' : '+filename,'#000000',area);
						//reset the file upload, if there is one
						if(fileUpload=findObjectPath(checkName+"__new",area)){fileUpload.value="";}
						if(removeImage=findObjectPath(checkName+"__remove",area)){removeImage.value="0";}
						if(selectList=findObjectPath(checkName+'__select',area)){selectList.value=showFile;}
						break;
					}
				}
				//if no matching file was found, change thte title accordingly
				if(showFile==""){
					changeText('statDiv_'+checkName,'(no&nbsp;'+fType+')','#830000',area);
					changeText('dispFileName_'+checkName,'','#000000',area);
					if(removeImage=findObjectPath(checkName+"__remove",area)){removeImage.value="1";}
					if(selectList=findObjectPath(checkName+'__select',area)){selectList.value="";}
				}
				break;
			}
			break;
	}	
	//now update the image display
	if(showFile==""){
		//only proceed if selectList exists and is in fact a list and not a hidden input
		if((selectList=findObjectPath(checkName+'__select',area)) && (selectList.type!='hidden')){
			showFile=selectList.options[selectList.selectedIndex].value;
		}else{
			showFile="/_images/shared/_xc_image_none.jpg";
		}
	}
	//alert(showFile);
	//toggle image preview visibility
	if(hidePreview==1){
		if(divObj=findObjectPath("filePrevTitle_"+checkName,area)){divObj.style.display='none';}
		if(divObj=findObjectPath("filePrevCont_"+checkName,area)){divObj.style.display='none';}
		if(divObj=findObjectPath("fileCapTitle_"+checkName,area)){divObj.style.display='none';}
		if(divObj=findObjectPath("fileCapCont_"+checkName,area)){divObj.style.display='none';}
	}else{
		if(divObj=findObjectPath("filePrevTitle_"+checkName,area)){divObj.style.display='block';}
		if(divObj=findObjectPath("filePrevCont_"+checkName,area)){divObj.style.display='block';}
		if(divObj=findObjectPath("fileCapTitle_"+checkName,area)){divObj.style.display='block';}
		if(divObj=findObjectPath("fileCapCont_"+checkName,area)){divObj.style.display='block';}
		//now see if there is an anchor tag that we should scroll to
		scrollToAnchor("anchor_"+checkName,area);
		//update the preview pane
		if(previewFrame=findObjectPath("iframe_"+checkName,area)){
			//alert('found previewFrame');
			previewFrame.src='/_libs/image_output.php?src='+showFile+'&output=thumbDoc';
		}
	}
}


function openPopPreview(checkName,area){
	//capture the popup link data from the preview iframe and use it to open the media preview popup
	if(lData=top.frames[area]["iframe_"+checkName].document.getElementById('popLink')){
		//alert(lData);
		lData=lData.toString();
		lData=lData.substring(21,lData.length-1).split(',');
		for(x in lData){lData[x]=lData[x].substring(1,lData[x].length-1);}
		goURL(lData[0],lData[1],lData[2],lData[3],lData[4],lData[5]);
	}
}


function changeText(objID,newText,newColor,area){
	//alert('toggleContDiv');
	if(divObj=findObjectPath(objID,area)){
		divObj.innerHTML=newText;
		if(newColor!=0 && newColor!=null){divObj.style.color=newColor;}
	}
}


function toggleContDiv(checkName,openName,openColor,closeName,closeColor,area,animDur,togglePrev){
	divObj=findObjectPath("contDiv_"+checkName,area);
	//first switch the signal image and/or button text
	if(signalObj=findObjectPath("divTogSign_"+checkName,area)){
		//openName may contain both a name and instructions to toggle a graphic - 'someTitleTxt|1' or 'image' will invoke toggling an image
		openName=openName.split('|');
		//if there is an image to toggle, do that here
		if(openName.length>1 || openName=="image"){
			if(divObj.style.display=='none' || divObj.style.display==''){
				signalObj.src=stringReplace(signalObj.src,'_closed','_open');
			}else{
				signalObj.src=stringReplace(signalObj.src,'_open','_closed');
			}
		}
		if(openName[0]!="" && openName!="image"){
			//popWin.alert('found signal');
			//use the divTogTitle_ID object if we also toggled a graphic
			if(openName.length>1){signalObj=findObjectPath("divTogTitle_"+checkName,area);}
			switch(signalObj.innerHTML){
				case openName[0]:
					signalObj.innerHTML=closeName;
					if(closeColor!=""){signalObj.style.color=closeColor;}
					//now see if there is an anchor tag that we should scroll to
					scrollToAnchor("anchor_"+checkName,area);
				break;
				case closeName:
					signalObj.innerHTML=openName[0];
					if(openColor!=""){signalObj.style.color=openColor;}
				break;
			}
		}
	}
	isOpening=0;
	//NOTE that if we're using jquery and DONT want to animate div action here - then give the noJqueryToggle variable a value somewhere
	if(area=='popWin' && animDur!='none' && (typeof popWin.$ != 'undefined') && (animDur!=null || typeof popWin.noJqueryToggle == 'undefined')){
		if(animDur==null){animDur=400;}
		//popWin.$('#contDiv_'+checkName).slideToggle(animDur);
		if(divObj.style.display == 'none' || divObj.style.display == ''){ 
			isOpening=1;
			popWin.$('#contDiv_'+checkName).animate({opacity:'show',height:'show'},animDur,'');
		}else{
			isOpening=0;
			popWin.$('#contDiv_'+checkName).animate({opacity:'hide',height:'hide'},animDur,'');
		}
	}else if(animDur!='none' && (typeof $ != 'undefined') && (animDur!=null || typeof noJqueryToggle == 'undefined')){
		if(animDur==null){animDur=400;}
		//$('#contDiv_'+checkName).slideToggle(animDur,function(){alert('toggle');});
		if(divObj.style.display == 'none' || divObj.style.display == ''){ 
			isOpening=1;
			//$('#contDiv_'+checkName).slideDown(animDur);
			$('#contDiv_'+checkName).animate({opacity:'show',height:'show'},animDur,'');
		}else{
			isOpening=0;
			//$('#contDiv_'+checkName).slideUp(animDur,nudgeScroll);
			$('#contDiv_'+checkName).animate({opacity:'hide',height:'hide'},animDur,nudgeScroll);
		}
	}else{
		if(divObj.style.display == 'none' || divObj.style.display == ''){ 
			isOpening=1;
			divObj.style.display='block';
		}else{
			isOpening=0;
			divObj.style.display='none';
		}
	}
	//if togglePrev argument was sent, then, using the arguments for this item, toggle the previously opened div
	if(togglePrev==1){
		prevTogDiv=curTogDiv;
		curTogDiv=(isOpening==1?checkName:0);
		if(prevTogDiv!=0 && prevTogDiv!=checkName && isOpening==1){toggleContDiv(prevTogDiv,openName[0],openColor,closeName,closeColor,area,animDur,0);}
	}
	//alert('going to fixIEBug');
	fixIEBug();
	//alert('going to scrollTonchor');
}

function nudgeScroll(){
	//alert('in scroll bit');
	var ScrollTop = document.body.scrollTop;
	if(ScrollTop == 0){
		if(window.pageYOffset){
			ScrollTop = window.pageYOffset;
		}else{
			ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
		}
	}
	window.scrollTo(0,ScrollTop-1);
	//moving the vertical scroll position by a pixel helps remove artifacts that sometimes appear when browser needs to scroll up
	//scrolly = (window.document.all)?window.document.body.scrollTop:window.pageYOffset; 
	//window.scrollTo(0,scrolly-1);
}


//function to scroll document to a given anchor
function scrollToAnchor(anchorName,area){
	//alert(anchorName);
	//if(anchorObj=findObjectPath(anchorName,area)){
	anchorObj=findObjectPath(anchorName,area);
	if(anchorObj!=null && anchorObj!=""){
		//get the correct pathprefix
		pathPrefix=getPathPrefix(area,0);
		//NOTE that the getAnchorPosition script must be directly linked to whatever page is specified in the pathprefix 
		//(ie, popwin must have this script directly attached)
		scrollCoords=pathPrefix.getAnchorPosition(anchorName);
		//find the actual height of the popWin
		if(pathPrefix.innerHeight){
			frameHeight = pathPrefix.innerHeight;
		}else if(pathPrefix.document.documentElement && pathPrefix.document.documentElement.clientHeight){
			frameHeight = pathPrefix.document.documentElement.clientHeight;
		}else if(pathPrefix.document.body){
			frameHeight = pathPrefix.document.body.clientHeight;
		}
		//grab the current scroll position
		//scrollx = (pathPrefix.document.all)?pathPrefix.document.body.scrollLeft:pathPrefix.pageXOffset;
  		scrolly = (pathPrefix.document.all)?pathPrefix.document.body.scrollTop:pathPrefix.pageYOffset; 
		//now, if the desired anchor is below the window height, scroll down just enough to reveal that anchor
		if((frameHeight+scrolly)<scrollCoords.y){
			//alert('scrolly='+scrolly+' frameHeight='+frameHeight+' scrollCoords.y='+scrollCoords.y);
			pathPrefix.scrollTo(0,(scrollCoords.y-frameHeight)+10);
		}
	}
}


function triggerDateFilter(dateName,area){
	pathPrefix=getPathPrefix(area,1);
	radioSet=pathPrefix.forms['tableForm']['filter__'+dateName+'__dateRange'];
	//radioSet=findObjectPath('filter__'+dateName+'__dateRange',area);
	for(inc=0;inc<radioSet.length;inc++){
		if(radioSet[inc].value=='range'){radioSet[inc].checked=1;break;}
	}
}


function resizeOuterTo(w,h) {
 if (parseInt(navigator.appVersion)>3) {
   if (navigator.appName=="Netscape") {
    top.outerWidth=w;
    top.outerHeight=h;
   }
   else top.resizeTo(w,h);
 }
}


function checkChars(checkText,formCall){
//now check for illegal characters
	//charList=Array("~","$","&","?","@","\"","\\","�","�","�","�");
	charList=Array("~","$","&","?","@","\"","\\","�","i","�");
	for(i=0;i<charList.length;i++){
		if(checkText.indexOf(charList[i])!=-1){
			alert("Sorry, your text cannot contain the "+charList[i]+" character.");
			if(formCall){
				return false;
			}else{
				return;
			}
		}
	}
}

function fixIEBug(){
	//alert("in fixIEDbug")
	///Defeat IE6 fixed bug by opening and closing the last div
	if(x = document.getElementById('defeatIEBug')){
		currentStyle = x.style.display;
		newStyle = (currentStyle == 'none') ? 'block' : 'none';
		x.style.display = newStyle;
		x.style.display = currentStyle;
	}
	return;
}

function goURL(url,target,popWidth,popHeight,resize,scrollbars) {
	//create the popup according to indended target
	switch(target){
		case 'top':
			window.location=url;
			break;
		case 'popup':
			//alert('here');
			//only a 'popup' target gets assigned the popWin variable, other popups (media previews, etc) are NOT tracked, as an open popWin may spawn those requests
			closePopup();
			popWin=0; popWin_h=0; popWin_w=0;
		case 'previewPop':
		case 'img_pop':
		case 'subPop':
			//set variable defaults
			if(!resize){resize=1;}
			if(!scrollbars){scrollbars=0;}
			if(!popWidth){popWidth=400;}
			if(!popHeight){popHeight=400;}
			var winLeft=parseInt((screen.width - popWidth)/2);
			var winTop=parseInt((screen.height - popHeight)/2);
			//alert('width=' + popWidth + ',height=' + popHeight + ',left=' + winLeft + ',top=' + winTop + ',resizable=' + resize +',scrollbars=' + scrollbars);
			tempWin=window.open('','','width=' + popWidth + ',height=' + popHeight + ',left=' + winLeft + ',top=' + winTop + ',resizable=' + resize +',scrollbars=' + scrollbars);
			if(target=="img_pop"){
				//img pops have a special setup here
				tempWin.document.write('<html><head><title>Image Window</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head>');
				tempWin.document.write('<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">');	
				tempWin.document.write('<table id="imageTable" width="100%" height="100%" border="0" cellpadding="0" cellspacing="0"><tr><td align="center" valign="middle">');
				tempWin.document.write('<img src="'+url+'"><br /><img src="/_images/spacer.gif" width="1" height="10"><br />');
				tempWin.document.write('<input type="button" name="close" id="close" value="Close Window" onClick="JavaScript:window.close();" /></td></tr></table></body></html>');
			}else{
				//any other popup type, simply apply the sent URL
				tempWin.location=url;
			}
			tempWin.focus();
			//only set the popWin variable for a popup target
			if(target=="popup"){popWin=tempWin;}
			break;
	}
}


function clearFilter(area){
	//alert("in clearFilter, area="+area);
	//DONT CAPTURE THE OPEN DIVS - WANT THEM TO BE CLOSED WHEN PAGE IS RELOADED
	//openDivList=captureOpenDivs(area);
	pathPrefix=getPathPrefix(area,0);
	goAction=pathPrefix.document.tableForm.action;
	obj=findObjectPath("useSavedFilters","navBottom");
	if(obj){obj.value=0;}
	//SKIP THE SUBMIT ACTION, AND THUS RESET THE FILTERS
	//pathPrefix.location.href=goAction+"?curPage=1&newFilters=1&openDivs="+openDivList;
	pathPrefix.location.href=goAction+"?curPage=1";
}


function filterRecords(area,xlsOutput,customXLS){
	//alert("in filterRecords, area="+area);
	captureOpenDivs(area);
	pathPrefix=getPathPrefix(area,1);
	saveAction=pathPrefix.tableForm.action;
	//setup filter tableForm action - add the xlsOUtput variables if requested
	pathPrefix.tableForm.action=pathPrefix.tableForm.action+"?curPage=1&newFilters=1";
	if(xlsOutput){pathPrefix.tableForm.action=pathPrefix.tableForm.action+"&xlsOutput="+xlsOutput+"&customXLS="+customXLS;}
	pathPrefix.tableForm.submit();
	//reset the tableForm action
	pathPrefix.tableForm.action=saveAction;
}


function flipPage(selectList,area,goPage){
//alert("in flipPage, area="+area+" selectList="+selectList);
	captureOpenDivs(area);
	pathPrefix=getPathPrefix(area,1);
	//alert(pathPrefix.tableForm.action);
	goAction=pathPrefix.tableForm.action;
	if(!goPage){goPage=pathPrefix.tableForm[selectList].options[pathPrefix.tableForm[selectList].selectedIndex].text;}
	pathPrefix.tableForm.action=goAction+"?curPage="+goPage;
	//alert(pathPrefix.tableForm.action)
	pathPrefix.tableForm.submit();
}


function changeSort(sortBy,sortDir,area){
	//alert("in changeSort, area="+area+" sortBy="+sortBy);
	captureOpenDivs(area);
	pathPrefix=getPathPrefix(area,1);
	//update the sortBy and sortDir hidden inputs
	objBy=findObjectPath("sortBy","navBottom");
	objBy.value=sortBy;
	objToggle=findObjectPath("sortDir","navBottom");
	objToggle.value=sortDir;
	//now add the openDivs list and go!
	goAction=pathPrefix.tableForm.action;
	pathPrefix.tableForm.action=goAction;
	//alert(pathPrefix.tableForm.action)
	pathPrefix.tableForm.submit();
}


function captureOpenDivs(area){
	//alert("in captureOpenDivs");
	//capture a list of all open divs in openDivs array for the current resource page for use when the page reloads after the update
	pathPrefix=getPathPrefix(area,1);
	x=pathPrefix.getElementsByTagName('div');
	top.openDivs=new Array();
	for(i=0;i<x.length;i++){
		//record any open divs in the current resource so we can reopen these after the resource has ben updated
		if(x[i].id.indexOf('contDiv_')>=0 && x[i].style.display=='block'){
			top.openDivs[openDivs.length]=x[i].id;
		}
	}
}


function showOpenDivs(area){
	//alert('in show open divs');
	for(i in top.openDivs){
		//alert(top.openDivs[i]);
		pathPrefix=getPathPrefix(area,1);
		x=pathPrefix.getElementById(top.openDivs[i]);
		if(x!=null){
			x.style.display='block';
			//flip the toggle arrow if available
			togSign=top.openDivs[i].replace('contDiv','divTogSign');
			if(signalObj=findObjectPath(togSign,area)){
				//signalObj.src=stringReplace(signalObj.src,'_closed','_open');
				$(signalObj).attr('src',$("#"+togSign).attr('src').replace('_closed','_open'));
			}
		}
			
	}
	//reset the openDivs
	top.openDivs=new Array();
}


function clearText(objID,area,newClass,newType){
	//alert('in clearText');
	if((curObj=findObjectPath(objID,area))!=null){
		curObj.value="";
		//if a newClass value was sent, apply this class to the current input
		if(newClass!=null && newClass!=0){curObj.className=newClass;}
		//if a new Type was sent, replace the current field with a new field of the new type
		if(newType){
		//if(isIE==true){
			//to get around the fact IE can not change the type property of an existing input, we create a new input object with the new type to replace the existing input.
			newClass=curObj.className;
			newSize=curObj.size;
			newWidth=curObj.style.width;
			//create new input object
			newObj = document.createElement('input');
			newObj.name=objID;
			newObj.id=objID;
			newObj.type=newType;
			newObj.value="";
			//now swap out old input, and pass old input class and size props to new input
			curObj.parentNode.replaceChild(newObj, curObj);
			curObj=findObjectPath(objID,area);
			curObj.className=newClass;
			curObj.size=newSize;
			curObj.style.width=newWidth;
			curObj.focus();
		//}else{
			//for non IE browsers, simply change the type property
			//curObj.type=newType;	
		//}
		}
		//run this here again - IE and safari have trouble with this - NOTE that safari does NOT retain focus if this field was reached via TAB... why? got me.
		curObj.focus();
	}
}


function clearAllText(area){
	//alert("in clearAllText");
	windowPrefix=window;
	if(area=='popWin'){windowPrefix=popWin;}else if(area!=null){windowPrefix=window[area];}
	//confirm to clear fields
	decision=windowPrefix.confirm('Are you sure you want clear all input fields?');
	if(decision){
		docForms=windowPrefix.document.forms;
		//alert("total forms="+docForms.length);
		//now walk though all form inputs, find text inputs and set their value=""
		for(i=0;i<docForms.length;i++){
		//alert("current form length="+docForms[i].length);
			for(ii=0;i<docForms[i].length;ii++){
				if(docForms[i][ii].type=="text" && docForms[i][ii].readonly==null){
					//alert("found text input, value="+docForms[i][ii].value);
					docForms[i][ii].value="";
				}
			}
		}
	}
}


function preloadImages(imageList) { 
	//alert('preloading images')
	var doc=document; //put the document object into a variable for abbreviated handling
	if(doc.images){ //if this browser is capable of finding document images, then proceed
		if(!doc.loadedImages) doc.loadedImages=new Array(); //if the loadedimages array doesn't yet exist, create it & attach it to the document object
		var i,len=doc.loadedImages.length; //set up variables
		for(i=0; i<imageList.length; i++){//cycle through the image paths passed as arguments and preload them
  			doc.loadedImages[len]=new Image(); 
			doc.loadedImages[len++].src=imageList[i];//note that putting the ++ after "len" increments "len" AFTER the current expression is evaluated!
    		//alert(doc.loadedImages.length + ' images have been preloaded');
		}
	}
}


/*function changeImageURL() { 
	//alert('preloading images')
	var doc=document; //put the document object into a variable for abbreviated handling
	if(doc.images){ //if this browser is capable of finding document images, then proceed
		//alert("there are "+doc.images.length+" images in this document")
		for(i=0;i<doc.images.length;i++){
			startPath=doc.images[i].src
			//alert(startPath)
			if(startPath.indexOf("_images")==-1){
				valueArray=startPath.split("images")
				//alert("subPath= "+valueArray[valueArray.length-1])
				newPath="http://www.jennieoturkeystore.com/images"+valueArray[valueArray.length-1]
				doc.images[i].src=newPath
				//return
			}
			//return
		}
	}
}*/


function closePopup() {
	//alert('in closePopup');
	//make sure the popUp is gone and update the main database display
	if(popWin){popWin.close(); popWin=0; popWin_h=0; popWin_w=0;}
}


//controls images swaping for both mouseEnter & mouseLeave actions
function imageSwap(mouseDir,objID,area) { 
	//alert('in imageSwap')
	imageInfo=null;
	if ((imgObjPath=findObjectPath(objID,area))!=null){
  		switch (mouseDir) {
			case'enter':
  				newImgPath=stringReplace(imgObjPath.src,'_norm','_over');
				imgObjPath.src = newImgPath;
			break;
			case'leave':
  				newImgPath=stringReplace(imgObjPath.src,'_over','_norm');
				imgObjPath.src = newImgPath;
			break;
			case'down':
  				newImgPath=stringReplace(imgObjPath.src,'_over','_down');
				imgObjPath.src = newImgPath;
			break;
			case'up':
  				newImgPath=stringReplace(imgObjPath.src,'_down','_over');
				imgObjPath.src = newImgPath;
			break;
			case'enterLive':
  				newImgPath=stringReplace(imgObjPath.src,'_live','_over');
				imgObjPath.src = newImgPath;
			break;
			case'leaveLive':
  				newImgPath=stringReplace(imgObjPath.src,'_over','_live');
				imgObjPath.src = newImgPath;
			break;
			case'liveToNorm':
  				newImgPath=stringReplace(imgObjPath.src,'_live','_norm');
				imgObjPath.src = newImgPath;
			break;
			case'normToLive':
  				newImgPath=stringReplace(imgObjPath.src,'_norm','_live');
				imgObjPath.src = newImgPath;
			break;
			case'overToLive':
  				newImgPath=stringReplace(imgObjPath.src,'_over','_live');
				imgObjPath.src = newImgPath;
			break;
			default:
				//if the mouseDir argument is none of the above, then just replace the last section of the image path with whatever was sent
				imgSrc=imgObjPath.src.split("_");
				imgSrc.pop();
				imgSrc=imgSrc.join("_");
				imgObjPath.src=(imgSrc+=mouseDir);
			break;
		}
	}
}


//controls images swaping for both mouseEnter & mouseLeave actions
function newImage(imagePath,objID) { 
	//alert('in imageSwap')
	imageInfo=null;
	if ((imgObjPath=findObjectPath(objID))!=null){
  		//newImgPath=stringReplace(imgObjPath.src,'_over','_norm');
		imgObjPath.src = imagePath;
	}
}

//toggle a group of checkboxes
function toggleCheckboxes(togList,area){
	//if the togList argument is not an array, assume it is a single object name and convert it to an array here
	if(!isArray(togList)){togList=new Array(togList);}
	//continue only if there are values in the togList
	if(togList.length>0){
		togBtn=findObjectPath('ckBoxToggle',area);
		if(togBtn.value=="Check All"){
			for(i=0;i<togList.length;i++){
				ckObj=findObjectPath(togList[i],area);
				ckObj.checked = true ;
			}
			togBtn.value="UnCheck All";
		}else if(togBtn.value=="UnCheck All"){
			for(i=0;i<togList.length;i++){
				ckObj=findObjectPath(togList[i],area);
				ckObj.checked = false ;
			}
			togBtn.value="Check All";
		}
	}
}

//chk if an object is an array or not.
function isArray(obj){
	//returns true is it is an array
	if(obj.constructor.toString().indexOf("Array") == -1){return false;}else{return true;}
}

function findObjectPath(objID,area){
	//alert('finding object path')
	//alert('objID='+objID+' area='+area);
	var pathInfo;
	var pathPrefix;
	//first come up with a path prefix depending on where the object is
	pathPrefix=getPathPrefix(area,1);
	//now track down the element using the pathPrefix
	//return the appropriate object path depending on what browser we are using.
	if(pathPrefix.getElementById){
		//alert('found getElementByID, objID= ' + objID)
		pathInfo=pathPrefix.getElementById(objID);
	}else if (pathPrefix.all){
		//alert('found all, objID= ' + objID)
		pathInfo=pathPrefix.all[objID];
	}else if(pathPrefix.layers){
		//alert('found layers, objID= ' + objID)
		pathInfo=pathPrefix.images[objID];
	}else{ 
		//alert('unable to process DHTML on this browser')
		pathInfo=null;
	}
	//alert('pathInfo=' + pathInfo)
	return pathInfo;
}


function getPathPrefix(area,includeDoc){
	var pathPrefix;
	//create the window level path prefix
	if(!area){
		pathPrefix=window;
	}else{
		switch(area){
			
			case(""):
			case(0):
			case(null):
			pathPrefix=window;
			break;
			
			case("popWin"):		
			pathPrefix=popWin;
			break;
			
			case("navBottom"):
			pathPrefix=window.top.bottomFrame;
			break;
			
			case("navTop"):
			pathPrefix=window.top.topFrame;
			break;
			
			case("navBottomEmailer"):
			pathPrefix=window.top.bottomFrame.iframe_emailer;
			break;
			
			default:
			//if another area argument was sent,assume it is the name of the target frame 
			pathPrefix=window.top[area];
			break;
		}
	}
	//add the document element if requested
	if(includeDoc){pathPrefix=pathPrefix.document;}
	return pathPrefix;
}


//this is a script to modify a given string with the given new string info
function stringReplace(modifyString,findString,replaceString) {
	//alert('in stringReplace')
	var pos=0,len=findString.length;
	pos=modifyString.indexOf(findString);
	//using the 'while(pos != -1)' here allows us to escape if the 'findString' we are sending isn't found in the 'modifyString' at all
	while(pos != -1) {
		preString=modifyString.substring(0,pos);
		postString=modifyString.substring(pos+len,modifyString.length);
		modifyString=preString+replaceString+postString;
		pos=modifyString.indexOf(findString);
	}
	return modifyString;
}


//-->
