/***********************************************************************
* Website Pyro Ajax Engine
* Author - Al Wolfson
* Changelog:
* 3/24/2008 - added checkObj to loop through all nodes of target obj
* 3/20/2008 - added optional updateField,no longer required to use callback functions
* 4/24/2007 - added support for POST form submission and form field checking
***********************************************************************/
function makeHttpRequest(link,callback_function,return_xml,parameters,updateField,adminPath){
	var http_request=false;
	
	if (window.XMLHttpRequest){ // Mozilla,Safari,...
		http_request=new XMLHttpRequest();
	}else if (window.ActiveXObject){ // IE
		try{
			http_request=new ActiveXObject("Msxml2.XMLHTTP");
		}catch (e){
			try{
				http_request=new ActiveXObject("Microsoft.XMLHTTP");
			}catch (e){}
		}
	}
	if (!http_request){
		jAlert('Unfortunately your browser doesn\'t support this feature.');
		return false;
	}
	http_request.onreadystatechange=function(){
		if (http_request.readyState == 4){
			if (http_request.status == 200){
				if (typeof updateField == "undefined"||updateField==''){
					if (return_xml)
						eval(callback_function+'(http_request.responseXML,adminPath)');
					else eval(callback_function+'(http_request.responseText,adminPath)');
				}else if(typeof callback_function != "undefined"){
					toField=document.getElementById(updateField);
					if (!toField)
						jAlert("can't find" +updateField);
					else{
						if (return_xml)
							toField.innerHTML=http_request.responseXML;
						else{
							var inData=http_request.responseText;
							toField.innerHTML=inData;
						}
					}
				}else jAlert('callback function ['+callback_function+'] not found,updateField ['+updateField+'] not found');
			}else jAlert('There was a problem with the request.(Code: '+http_request.status+')(debug: '+parameters+')');
		}
	}
	http_request.open('POST',link,true);
	http_request.setRequestHeader("Content-type","application/x-www-form-urlencoded");
	http_request.setRequestHeader("Content-length",parameters.length);
	http_request.setRequestHeader("Connection","close");
	http_request.send(parameters);
}

function getValues(obj,link,callback,return_xml,updateField){
	poststr=checkObj(obj);
	makeHttpRequest(link,callback,return_xml,poststr,updateField,'');
}
function getValues2(obj,link,callback,return_xml,updateField,adminPath){
	poststr=checkObj(obj);
	makeHttpRequest(link,callback,return_xml,poststr,updateField,adminPath);
}
function checkObj(obj){
	var poststr='';
	var j=0;
	poststr+=checkSingleObj(obj);
	for (j=0;j<obj.childNodes.length;j++)
		poststr+=checkObj(obj.childNodes[j]);
	return poststr;
}

function checkSingleObj(obj){
	var poststr='';
	if (obj.tagName == "INPUT"){
		if (obj.type == "text")
			poststr += obj.name+"="+escape(obj.value)+"&";
		else if (obj.type == "checkbox"){
			if (obj.checked)
				poststr += obj.name+"="+escape(obj.value)+"&";
			else poststr += obj.name+"=&";
		}else if (obj.type == "radio"){
			if (obj.checked)
				poststr += obj.name+"="+escape(obj.value)+"&";
		}else if (!obj.disabled)
	 		poststr += obj.name+"="+escape(obj.value)+"&";
	}else if (obj.tagName == "SELECT"){
		var sel=obj;
		poststr += sel.name+"="+escape(sel.options[sel.selectedIndex].value)+"&";
	}else if (obj.tagName == "Button")
		poststr += obj.name+"="+escape(obj.value)+"&";
	else if (obj.type == "textarea")
		poststr += obj.name+"="+escape(obj.value)+"&";
	else if (obj.disabled)
		obj.disabled=false;
	return poststr;
}

//process individual elements
function adminEdit(text,adminPath){
	document.getElementById('adminEditField').innerHTML=text;
	var settings=new WYSIWYG.Settings();
	settings.ImagesDir=adminPath+"images/";
	settings.PopupsDir=adminPath+"popups/";
	settings.CSSFile=adminPath+"styles/wysiwyg.css";
	settings.ImagePopupFile=adminPath+"popups/insert_image.php";
	settings.ImagePopupWidth=600;
	settings.ImagePopupHeight=245;
	settings.DocPopupFile=adminPath+"popups/insert_file.php";
	settings.DocPopupWidth=600;
	settings.DocPopupHeight=245;
	settings.Width="100%";
	settings.Height="400px";
	WYSIWYG.setSettings('PageContent',settings);
	WYSIWYG._generate('PageContent');
}
function adminEdit2(text,adminPath){
	document.getElementById('adminEditField2').innerHTML=text;
	var settings=new WYSIWYG.Settings();
	settings.ImagesDir=adminPath+"images/";
	settings.PopupsDir=adminPath+"popups/";
	settings.CSSFile=adminPath+"styles/wysiwyg.css";
	settings.ImagePopupFile=adminPath+"popups/insert_image.php";
	settings.ImagePopupWidth=600;
	settings.ImagePopupHeight=245;
	settings.DocPopupFile=adminPath+"popups/insert_file.php";
	settings.DocPopupWidth=600;
	settings.DocPopupHeight=245;
	settings.Width="100%";
	settings.Height="400px";
	WYSIWYG.setSettings('Secondary_Content',settings);
	WYSIWYG._generate('Secondary_Content');
}

/***********************************************
* Misc
***********************************************/
//display/hide div
function toggleLayer(whichLayer){
	var elem,vis;
	if(document.getElementById) // this is the way the standards work
		elem=document.getElementById(whichLayer);
	else if(document.all) // this is the way old msie versions work
		elem=document.all[whichLayer];
	else if(document.layers) // this is the way nn4 works
		elem=document.layers[whichLayer];
	vis=elem.style;
	// if the style.display value is blank we try to figure it out here
	if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
		vis.display=(elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
	vis.display=(vis.display==''||vis.display=='block')?'none':'block';
}
function popUp(URL){
	day=new Date();
	id=day.getTime();
	eval("page"+id+"=window.open(URL,'"+id+"','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=300,height=300,left=490,top=362');");
}
function popUpPlayer(URL,width,height){
	day=new Date();
	id=day.getTime();
	eval("page"+id+"=window.open(URL,'"+id+"','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width='+width+',height='+height+',left=490,top=362');");
}
function addBookmark(title,url){
	if (window.sidebar)
		window.sidebar.addPanel(title,url,"");
	else if(document.all)
		window.external.AddFavorite(url,title);
	else if(window.opera && window.print)
		return true;
}
function insertAtCursor(myField,myValue){
	if (document.selection){
		myField.focus();
		sel=document.selection.createRange();
		sel.text=myValue;
	}else if (myField.selectionStart || myField.selectionStart == '0'){
		var startPos=myField.selectionStart;
		var endPos=myField.selectionEnd;
		myField.value=myField.value.substring(0,startPos)
		+ myValue
		+ myField.value.substring(endPos,myField.value.length);
	}else myField.value += myValue;
}
function insertspecial(myField,ftag){
	var space=" ";
	if (ftag=='URL'){
		var url=prompt('Enter the URL:','http:\/\/');
		if (! url){ return;}
		var txt=prompt('Enter the text for the link or press enter to use the URL as the text:','Link Text');
		if (!txt || (txt == 'Link Text')){ txt=URL;}
		insertAtCursor(myField,"[URL="+url+"]"+txt+"[/URL]");
	}else if (ftag=='YOUTUBE'){
		var text=prompt("Enter the YouTube Video URL (not the EMBED):","");
		if (text != null){
			var text_to_insert='['+ftag+']'+text.substring(31)+'[/'+ftag+']';
			insertAtCursor(myField,text_to_insert);
		}
	}else if (ftag=='IMG'){
		var text=prompt("Enter the link to the image you would like to insert:",'http:\/\/');
		if (text != null){
			var text_to_insert='['+ftag+']'+text+'[/'+ftag+']';
			insertAtCursor(myField,text_to_insert);
		}
	}else{
		var text=prompt("Type the text you want to enter:","");
		if (text != null){
			var text_to_insert='['+ftag+']'+text+'[/'+ftag+']';
			insertAtCursor(myField,text_to_insert);
		}
	}
	myField.focus();
}
function displayOrder_Dropdown(pageLink){
	window.location=pageLink+'?sortOrder='+document.displayOrder.sortOrd.options[document.displayOrder.sortOrd.selectedIndex].value;
}
function ValidateLogin(theForm){
	var why="";
	why += isEmpty(theForm.access_login.value,'Login');
	why += isEmpty(theForm.access_password.value,'Password');
	if (why != ""){
		jAlert(why);
		return false;
	}
	return true;
}
function ValidateEmail(theForm){
	var why="";
	why += checkEmail(theForm.ml_Email.value);
	if (why != ""){
		jAlert(why);
		return false;
	}
	return true;
}
function make_blank(){document.SearchBox.words.value ="";}

/***********************************************************************
* Form Validation
***********************************************************************/
// email
function checkEmail(strng){
var error="";
if(strng == "")
	error="You didn't enter an email address.\n";

var emailFilter=/^.+@.+\..{2,3}$/;
if(!(emailFilter.test(strng)))
	error="Please enter a valid email address.\n";
else{
//test email for illegal characters
var illegalChars= "/[\(\)\<\>\,\;\:\\\"\[\]]/"
if(strng.match(illegalChars))
	error="The email address contains illegal characters.\n";
}
return error;
}

// phone number - strip out delimiters and check for 10 digits
function checkPhone(strng){
var error="";
var stripped=strng.replace(/[\(\)\.\-\ ]/g, '');
if(strng == "")
	error="You didn't enter a phone number.\n";
else if(isNaN(parseInt(stripped)))
	error="The phone number contains illegal characters.";
else if(!(stripped.length == 10))
	error="The phone number is the wrong length. Make sure you included an area code.\n";
return error;
}

// zipcode - strip out delimiters and check for 5 digits
function checkZip(strng){
var error="";
var stripped=strng.replace(/[\(\)\.\-\ ]/g, '');
if(strng == "")
	error="You didn't enter a zip code.\n";
else if(isNaN(parseInt(stripped)))
	error="The zip code contains illegal characters.";
else if(!(stripped.length == 5))
	error="The zip code should be 5 digits long.\n";
return error;
}

// password - between 6-10 chars, uppercase, lowercase, and numeral
function checkPassword(strng){
var error="";
if(strng == "")
	error="You didn't enter a password.\n";

var illegalChars=/[\W_]/; // allow only letters and numbers

if((strng.length < 6) ||(strng.length > 10))
	error="The password must be 6-10 characters long.\n";
else if(illegalChars.test(strng))
	error="The password contains illegal characters, only alphanumeric allowes.\n";
else if(!((strng.search(/(a-z)+/)) &&(strng.search(/(A-Z)+/)) &&(strng.search(/(0-9)+/))))
	error="The password must contain at least one uppercase letter, one lowercase letter, and one numeral.\n";
return error;
}

function checkRetype(strng,pwd){
var error="";
if(strng == "")
	error="You didn't retype the password.\n";
else if(strng!=pwd)
	error="Passwords entered do not match.\n";
return error;
}

function checkRetypeEmail(strng,pwd){
var error="";
if(strng == "")
	error="You didn't retype the email address.\n";
else if(strng!=pwd)
	error="Email Addresses entered do not match.\n";
return error;
}

// username - 4-20 chars, uc, lc, and underscore only.
function checkUsername(strng){
var error="";
if(strng == "")
	error="You didn't enter a username.\n";
	
var illegalChars=/\W/; // allow letters, numbers, and underscores
if((strng.length < 4) ||(strng.length > 20))
	error="The username must be 4-20 characters long.\n";
else if(illegalChars.test(strng))
	error="The username contains illegal characters.\n";
return error;
}

// non-empty textbox
function isEmpty(strng,fld){
var error="";
if(strng.length == 0)
	error="Please fill in the "+fld+".\n"
return error;	 
}

// exactly one radio button is chosen
function checkRadio(checkvalue){
var error="";
if(!(checkvalue))
	error="Please check a radio button.\n";
return error;
}

// valid selector from dropdown list
function checkDropdown(choice,fld){
var error="";
if(choice == 0)
	error="You didn't choose an option from the "+fld+" drop-down list.\n";
return error;
}

// username - 4-15 chars, uc, lc, and underscore only.
function checkPageName(strng){
var error="";
if(strng == "")
	error="You didn't enter a page name.\n";
	
var illegalChars=/[^a-zA-Z0-9 ]/; // allow letters, numbers, and spaces
if(illegalChars.test(strng))
	error="The page name contains illegal characters.\n";
return error;
}

//** All Levels Navigational Menu- (c) Dynamic Drive DHTML code library: http://www.dynamicdrive.com
//** Script Download/ instructions page: http://www.dynamicdrive.com/dynamicindex1/wspmenu/
//** Usage Terms: http://www.dynamicdrive.com/notice.htm

//** July 7th, 08'- Creation Date

//** July 16th, 08'- Updated to v 1.3:
	//1) Adds "Side Bar" orientation option. 
	//2) Drop Down Menus now auto adjust their positioning if too close to either right or bottom window edges.
	//3) Enhanced IFRAME shim "coverage" on the page.

//** July 19th, 08'- Updated to v 1.31: Drop down menu now positions at top of window edge if there's neither room downwards or upwards to settle.
//** Aug 13th, 08'- v1.32: Moved "rel" attribute from menu's <li> elements to inner <a>, for validation reasons

//** Sept 10th, 08'- Updated to v 1.4:
	//1) Added optional "sliding" animation when sub menus are revealed.
	//2) Arrow images now dynamically positioned, instead of relying on CSS's "right" property

//** Oct 11th, 08'- Updated to v 1.5:
	//1) Sliding animation behavior tweaked
	//2) Added ability to disable iframeshim, customize speed of sliding animation

//** Dec 23rd, 08'- Updated to v 2.0:
	//1) Animation speed refined to be function of time (ie: 1 sec)
	//2) Added two animations that can be individually enabled/disabled- "slide in" and "fade in".
	//3) Script now automatically moves HTML for all sub menus to the end of the page, to avoid any containership issues if they are nested in other elements.

//** Jan 12, 09'- Updated to v 2.1:
	//1) Added ability to disable the arrow images from the top level items (see option "showarrow")
	//2) For Top Level Menu items containing a SPAN element (for sliding doors technique), arrow images are inserted inside SPAN.

var wspmenu={

enableshim: true, //enable IFRAME shim to prevent drop down menus from being hidden below SELECT or FLASH elements? (tip: disable if not in use, for efficiency)

arrowpointers:{
	downarrow: ["http://www.websitepyro.com/images/arrow-down.gif", 11,7], //path to "down arrow" image that gets added to main menu items (last 2 parameters should be width/height of img)
	rightarrow: ["http://www.websitepyro.com/images/arrow-right.gif", 12,12], //path to "right arrow" image that gets added to LI elements within drop down menu containing additional menus
	showarrow: {toplevel: true, sublevel: true} //Show arrow images on top level items and sub level items, respectively?
},

hideinterval: 200, //delay in milliseconds before entire menu disappears onmouseout.
effects: {enableswipe: true, enablefade: true, duration: 500},
httpsiframesrc: "blank.htm", //If menu is run on a secure (https) page, the IFRAME shim feature used by the script should point to an *blank* page *within* the secure area to prevent an IE security prompt. Specify full URL to that page on your server (leave as is if not applicable).

///No need to edit beyond here////////////////////

topmenuids: [], //array containing ids of all the primary menus on the page
topitems: {}, //object array containing all top menu item links
subuls: {}, //object array containing all ULs
lastactivesubul: {}, //object object containing info for last mouse out menu item's UL
topitemsindex: -1,
ulindex: -1,
hidetimers: {}, //object array timer
shimadded: false,
nonFF: !/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent), //detect non FF browsers
getoffset:function(what, offsettype){
	return (what.offsetParent)? what[offsettype]+this.getoffset(what.offsetParent, offsettype) : what[offsettype]
},

getoffsetof:function(el){
	el._offsets={left:this.getoffset(el, "offsetLeft"), top:this.getoffset(el, "offsetTop")}
},

getwindowsize:function(){
	this.docwidth=window.innerWidth? window.innerWidth-10 : this.standardbody.clientWidth-10
	this.docheight=window.innerHeight? window.innerHeight-15 : this.standardbody.clientHeight-18
},

gettopitemsdimensions:function(){
	for (var m=0; m<this.topmenuids.length; m++){
		var topmenuid=this.topmenuids[m]
		for (var i=0; i<this.topitems[topmenuid].length; i++){
			var header=this.topitems[topmenuid][i]
			var submenu=document.getElementById(header.getAttribute('rel'))
			header._dimensions={w:header.offsetWidth, h:header.offsetHeight, submenuw:submenu.offsetWidth, submenuh:submenu.offsetHeight}
		}
	}
},

isContained:function(m, e){
	var e=window.event || e
	var c=e.relatedTarget || ((e.type=="mouseover")? e.fromElement : e.toElement)
	while (c && c!=m)try {c=c.parentNode} catch(e){c=m}
	if (c==m)
		return true
	else
		return false
},

addpointer:function(target, imgclass, imginfo, BeforeorAfter){
	var pointer=document.createElement("img")
	pointer.src=imginfo[0]
	pointer.style.width=imginfo[1]+"px"
	pointer.style.height=imginfo[2]+"px"
	if(imgclass=="rightarrowpointer"){
		pointer.style.left=target.offsetWidth-imginfo[2]-2+"px"
	}
	pointer.className=imgclass
	var target_firstEl=target.childNodes[target.firstChild.nodeType!=1? 1 : 0] //see if the first child element within A is a SPAN (found in sliding doors technique)
	if (target_firstEl && target_firstEl.tagName=="SPAN"){
		target=target_firstEl //arrow should be added inside this SPAN instead if found
	}
	if (BeforeorAfter=="before")
		target.insertBefore(pointer, target.firstChild)
	else
		target.appendChild(pointer)
},

css:function(el, targetclass, action){
	var needle=new RegExp("(^|\\s+)"+targetclass+"($|\\s+)", "ig")
	if (action=="check")
		return needle.test(el.className)
	else if (action=="remove")
		el.className=el.className.replace(needle, "")
	else if (action=="add" && !needle.test(el.className))
		el.className+=" "+targetclass
},

addshimmy:function(target){
	var shim=(!window.opera)? document.createElement("iframe") : document.createElement("div") //Opera 9.24 doesnt seem to support transparent IFRAMEs
	shim.className="ddiframeshim"
	shim.setAttribute("src", location.protocol=="https:"? this.httpsiframesrc : "about:blank")
	shim.setAttribute("frameborder", "0")
	target.appendChild(shim)
	try{
		shim.style.filter='progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)'
	}
	catch(e){}
	return shim
},

positionshim:function(header, submenu, dir, scrollX, scrollY){
	if (header._istoplevel){
		var scrollY=window.pageYOffset? window.pageYOffset : this.standardbody.scrollTop
		var topgap=header._offsets.top-scrollY
		var bottomgap=scrollY+this.docheight-header._offsets.top-header._dimensions.h
		if (topgap>0){
			this.shimmy.topshim.style.left=scrollX+"px"
			this.shimmy.topshim.style.top=scrollY+"px"
			this.shimmy.topshim.style.width="99%"
			this.shimmy.topshim.style.height=topgap+"px" //distance from top window edge to top of menu item
		}
		if (bottomgap>0){
			this.shimmy.bottomshim.style.left=scrollX+"px"
			this.shimmy.bottomshim.style.top=header._offsets.top + header._dimensions.h +"px"
			this.shimmy.bottomshim.style.width="99%"
			this.shimmy.bottomshim.style.height=bottomgap+"px" //distance from bottom of menu item to bottom window edge
		}
	}
},

hideshim:function(){
	this.shimmy.topshim.style.width=this.shimmy.bottomshim.style.width=0
	this.shimmy.topshim.style.height=this.shimmy.bottomshim.style.height=0
},


buildmenu:function(mainmenuid, header, submenu, submenupos, istoplevel, dir){
	header._master=mainmenuid //Indicate which top menu this header is associated with
	header._pos=submenupos //Indicate pos of sub menu this header is associated with
	header._istoplevel=istoplevel
	if (istoplevel){
		this.addEvent(header, function(e){
		wspmenu.hidemenu(wspmenu.subuls[this._master][parseInt(this._pos)])
		}, "click")
	}
	this.subuls[mainmenuid][submenupos]=submenu
	header._dimensions={w:header.offsetWidth, h:header.offsetHeight, submenuw:submenu.offsetWidth, submenuh:submenu.offsetHeight}
	this.getoffsetof(header)
	submenu.style.left=0
	submenu.style.top=0
	submenu.style.visibility="hidden"
	this.addEvent(header, function(e){ //mouseover event
		if (!wspmenu.isContained(this, e)){
			var submenu=wspmenu.subuls[this._master][parseInt(this._pos)]
			if (this._istoplevel){
				wspmenu.css(this, "selected", "add")
			clearTimeout(wspmenu.hidetimers[this._master][this._pos])
			}
			wspmenu.getoffsetof(header)
			var scrollX=window.pageXOffset? window.pageXOffset : wspmenu.standardbody.scrollLeft
			var scrollY=window.pageYOffset? window.pageYOffset : wspmenu.standardbody.scrollTop
			var submenurightedge=this._offsets.left + this._dimensions.submenuw + (this._istoplevel && dir=="topbar"? 0 : this._dimensions.w)
			var submenubottomedge=this._offsets.top + this._dimensions.submenuh
			//Sub menu starting left position
			var menuleft=(this._istoplevel? this._offsets.left + (dir=="sidebar"? this._dimensions.w : 0) : this._dimensions.w)
			if (submenurightedge-scrollX>wspmenu.docwidth){
				menuleft+= -this._dimensions.submenuw + (this._istoplevel && dir=="topbar" ? this._dimensions.w : -this._dimensions.w)
			}
			submenu.style.left=menuleft+"px"
			//Sub menu starting top position
			var menutop=(this._istoplevel? this._offsets.top + (dir=="sidebar"? 0 : this._dimensions.h) : this.offsetTop)
			if (submenubottomedge-scrollY>wspmenu.docheight){ //no room downwards?
				if (this._dimensions.submenuh<this._offsets.top+(dir=="sidebar"? this._dimensions.h : 0)-scrollY){ //move up?
					menutop+= - this._dimensions.submenuh + (this._istoplevel && dir=="topbar"? -this._dimensions.h : this._dimensions.h)
				}
				else{ //top of window edge
					menutop+= -(this._offsets.top-scrollY) + (this._istoplevel && dir=="topbar"? -this._dimensions.h : 0)
				}
			}
			submenu.style.top=menutop+"px"
			if (wspmenu.enableshim && (wspmenu.effects.enableswipe==false || wspmenu.nonFF)){ //apply shim immediately only if animation is turned off, or if on, in non FF2.x browsers
				wspmenu.positionshim(header, submenu, dir, scrollX, scrollY)
			}
			else{
				submenu.FFscrollInfo={x:scrollX, y:scrollY}
			}
			wspmenu.showmenu(header, submenu, dir)
		}
	}, "mouseover")
	this.addEvent(header, function(e){ //mouseout event
		var submenu=wspmenu.subuls[this._master][parseInt(this._pos)]
		if (this._istoplevel){
			if (!wspmenu.isContained(this, e) && !wspmenu.isContained(submenu, e)) //hide drop down ul if mouse moves out of menu bar item but not into drop down ul itself
				wspmenu.hidemenu(submenu)
		}
		else if (!this._istoplevel && !wspmenu.isContained(this, e)){
			wspmenu.hidemenu(submenu)
		}

	}, "mouseout")
},

setopacity:function(el, value){
	el.style.opacity=value
	if (typeof el.style.opacity!="string"){ //if it's not a string (ie: number instead), it means property not supported
		el.style.MozOpacity=value
		if (el.filters){
			el.style.filter="progid:DXImageTransform.Microsoft.alpha(opacity="+ value*100 +")"
		}
	}
},

showmenu:function(header, submenu, dir){
	if (this.effects.enableswipe || this.effects.enablefade){
		if (this.effects.enableswipe){
			var endpoint=(header._istoplevel && dir=="topbar")? header._dimensions.submenuh : header._dimensions.submenuw
			submenu.style.width=submenu.style.height=0
			submenu.style.overflow="hidden"
		}
		if (this.effects.enablefade){
			this.setopacity(submenu, 0) //set opacity to 0 so menu appears hidden initially
		}
		submenu._curanimatedegree=0
		submenu.style.visibility="visible"
		clearInterval(submenu._animatetimer)
		submenu._starttime=new Date().getTime() //get time just before animation is run
		submenu._animatetimer=setInterval(function(){wspmenu.revealmenu(header, submenu, endpoint, dir)}, 10)
	}
	else{
		submenu.style.visibility="visible"
	}
},

revealmenu:function(header, submenu, endpoint, dir){
	var elapsed=new Date().getTime()-submenu._starttime //get time animation has run
	if (elapsed<this.effects.duration){
		if (this.effects.enableswipe){
			if (submenu._curanimatedegree==0){ //reset either width or height of sub menu to "auto" when animation begins
				submenu.style[header._istoplevel && dir=="topbar"? "width" : "height"]="auto"
			}
			submenu.style[header._istoplevel && dir=="topbar"? "height" : "width"]=(submenu._curanimatedegree*endpoint)+"px"
		}
		if (this.effects.enablefade){
			this.setopacity(submenu, submenu._curanimatedegree)
		}
	}
	else{
		clearInterval(submenu._animatetimer)
		if (this.effects.enableswipe){
			submenu.style.width="auto"
			submenu.style.height="auto"
			submenu.style.overflow="visible"
		}
		if (this.effects.enablefade){
			this.setopacity(submenu, 1)
			submenu.style.filter=""
		}
		if (this.enableshim && submenu.FFscrollInfo) //if this is FF browser (meaning shim hasn't been applied yet
			this.positionshim(header, submenu, dir, submenu.FFscrollInfo.x, submenu.FFscrollInfo.y)
	}
	submenu._curanimatedegree=(1-Math.cos((elapsed/this.effects.duration)*Math.PI)) / 2
},

hidemenu:function(submenu){
	if (typeof submenu._pos!="undefined"){ //if submenu is outermost UL drop down menu
		this.css(this.topitems[submenu._master][parseInt(submenu._pos)], "selected", "remove")
		if (this.enableshim)
			this.hideshim()
	}
	clearInterval(submenu._animatetimer)
	submenu.style.left=0
	submenu.style.top="-1000px"
	submenu.style.visibility="hidden"
},


addEvent:function(target, functionref, tasktype) {
	if (target.addEventListener)
		target.addEventListener(tasktype, functionref, false);
	else if (target.attachEvent)
		target.attachEvent('on'+tasktype, function(){return functionref.call(target, window.event)});
},

init:function(mainmenuid, dir){
	this.standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body
	this.topitemsindex=-1
	this.ulindex=-1
	this.topmenuids.push(mainmenuid)
	this.topitems[mainmenuid]=[] //declare array on object
	this.subuls[mainmenuid]=[] //declare array on object
	this.hidetimers[mainmenuid]=[] //declare hide entire menu timer
	if (this.enableshim && !this.shimadded){
		this.shimmy={}
		this.shimmy.topshim=this.addshimmy(document.body) //create top iframe shim obj
		this.shimmy.bottomshim=this.addshimmy(document.body) //create bottom iframe shim obj
		this.shimadded=true
	}
	var menubar=document.getElementById(mainmenuid)
	var alllinks=menubar.getElementsByTagName("a")
	this.getwindowsize()
	for (var i=0; i<alllinks.length; i++){
		if (alllinks[i].getAttribute('rel')){
			this.topitemsindex++
			this.ulindex++
			var menuitem=alllinks[i]
			this.topitems[mainmenuid][this.topitemsindex]=menuitem //store ref to main menu links
			var dropul=document.getElementById(menuitem.getAttribute('rel'))
			document.body.appendChild(dropul) //move main ULs to end of document
			dropul.style.zIndex=2000 //give drop down menus a high z-index
			dropul._master=mainmenuid  //Indicate which main menu this main UL is associated with
			dropul._pos=this.topitemsindex //Indicate which main menu item this main UL is associated with
			this.addEvent(dropul, function(){wspmenu.hidemenu(this)}, "click")
			var arrowclass=(dir=="sidebar")? "rightarrowpointer" : "downarrowpointer"
			var arrowpointer=(dir=="sidebar")? this.arrowpointers.rightarrow : this.arrowpointers.downarrow
			if (this.arrowpointers.showarrow.toplevel)
				this.addpointer(menuitem, arrowclass, arrowpointer, (dir=="sidebar")? "before" : "after")
			this.buildmenu(mainmenuid, menuitem, dropul, this.ulindex, true, dir) //build top level menu
			dropul.onmouseover=function(){
				clearTimeout(wspmenu.hidetimers[this._master][this._pos])
			}
			this.addEvent(dropul, function(e){ //hide menu if mouse moves out of main UL element into open space
				if (!wspmenu.isContained(this, e) && !wspmenu.isContained(wspmenu.topitems[this._master][parseInt(this._pos)], e)){
					var dropul=this
					if (wspmenu.enableshim)
						wspmenu.hideshim()
					wspmenu.hidetimers[this._master][this._pos]=setTimeout(function(){
						wspmenu.hidemenu(dropul)
					}, wspmenu.hideinterval)
				}
			}, "mouseout")
			var subuls=dropul.getElementsByTagName("ul")
			for (var c=0; c<subuls.length; c++){
				this.ulindex++
				var parentli=subuls[c].parentNode
				if (this.arrowpointers.showarrow.sublevel)
					this.addpointer(parentli.getElementsByTagName("a")[0], "rightarrowpointer", this.arrowpointers.rightarrow, "before")
				this.buildmenu(mainmenuid, parentli, subuls[c], this.ulindex, false, dir) //build sub level menus
			}
		}
	} //end for loop
	this.addEvent(window, function(){wspmenu.getwindowsize(); wspmenu.gettopitemsdimensions()}, "resize")
},

setup:function(mainmenuid, dir){
	this.addEvent(window, function(){wspmenu.init(mainmenuid, dir)}, "load")
}

}

//used for ajax pic upload
function jsUpload(upload_field){
// check file extensions
var re_text=/\.jpg|\.png|\.gif/i;
var filename=upload_field.value;
/* Checking file type */
if (filename.search(re_text) == -1){
	jAlert("File does not have text(jpg, png, gif) extension");
	upload_field.form.reset();
	return false;
}
upload_field.form.submit();
document.getElementById('upload_status').innerHTML="uploading file...";
upload_field.disabled=true;
return true;
}

