/***********************************************
* AnyLink Vertical Menu- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function parseUrl(data) {
	//REGULAR EXPRESSION TO PARSE THE DOCUMENT URL
    var e=/^((http|ftp):\/)?\/?([^:\/\s]+)((\/\w+)*\/)([\w\-\.]+\.[^#?\s]+)(#[\w\-]+)?$/;

    if (data.match(e)) {
        return  {url: RegExp['$&'],
                protocol: RegExp.$2,
                host:RegExp.$3,
                path:RegExp.$4,
                file:RegExp.$6,
                hash:RegExp.$7};
    }
    else {
        return  {url:"", protocol:"",host:"",path:"",file:"",hash:""};
    }
}

//Contents for menu 1
var menu1=new Array()
menu1[0]='<a href="vendorListingsGeneral.cfm?Vendor_Category_ID=76&Vendor_Type_ID=5" onfocus="if (this.blur) this.blur();">Academics</a>';
menu1[1]='<a href="vendorListingsGeneral.cfm?Vendor_Category_ID=79&Vendor_Type_ID=5" onfocus="if (this.blur) this.blur();">Art</a>';
menu1[2]='<a href="vendorListingsGeneral.cfm?Vendor_Category_ID=77&Vendor_Type_ID=5" onfocus="if (this.blur) this.blur();">Music</a>';
menu1[3]='<a href="vendorListingsGeneral.cfm?Vendor_Category_ID=80&Vendor_Type_ID=5" onfocus="if (this.blur) this.blur();">Sports/Health &amp; Fitness</a>';
menu1[4]='<a href="vendorListingsGeneral.cfm?Vendor_Category_ID=81&Vendor_Type_ID=5" onfocus="if (this.blur) this.blur();">Theatre Arts</a>';
menu1[5]='<a href="vendorListingsGeneral.cfm?Vendor_Category_ID=82&Vendor_Type_ID=5" onfocus="if (this.blur) this.blur();">Other</a>';

//Contents for menu 2, and so on
var menu2=new Array()
menu2[0]='<a href="vendorListingsGeneral.cfm?Vendor_Category_ID=10&Vendor_Type_ID=2" onfocus="if (this.blur) this.blur();">Academics/Tutoring</a>';
menu2[1]='<a href="vendorListingsGeneral.cfm?Vendor_Category_ID=9&Vendor_Type_ID=2" onfocus="if (this.blur) this.blur();">Music</a>';
menu2[2]='<a href="vendorListingsGeneral.cfm?Vendor_Category_ID=36&Vendor_Type_ID=2" onfocus="if (this.blur) this.blur();">Art</a>';
menu2[3]='<a href="vendorListingsGeneral.cfm?Vendor_Category_ID=11&Vendor_Type_ID=2" onfocus="if (this.blur) this.blur();">Sports/Health &amp; Fitness</a>';
menu2[4]='<a href="vendorListingsGeneral.cfm?Vendor_Category_ID=44&Vendor_Type_ID=2" onfocus="if (this.blur) this.blur();">Theatre Arts</a>';
menu2[5]='<a href="vendorListingsGeneral.cfm?Vendor_Category_ID=56&Vendor_Type_ID=2" onfocus="if (this.blur) this.blur();">Other Private Instruction</a>';

var menu3=new Array()
menu3[0]='<a href="vendorListingsGeneral.cfm?Vendor_Category_ID=140&Vendor_Type_ID=4" onfocus="if (this.blur) this.blur();">Coed</a>';
menu3[1]='<a href="vendorListingsGeneral.cfm?Vendor_Category_ID=141&Vendor_Type_ID=4" onfocus="if (this.blur) this.blur();">Single Gender</a>';
		
var menu4=new Array()
menu4[0]='<a href="vendorListingsGeneral.cfm?Vendor_Category_ID=8&Vendor_Type_ID=1" onfocus="if (this.blur) this.blur();">Business Opportunities</a>';
menu4[1]='<a href="vendorListingsGeneral.cfm?Vendor_Category_ID=2&Vendor_Type_ID=1" onfocus="if (this.blur) this.blur();">Child Care</a>';
menu4[2]='<a href="vendorListingsGeneral.cfm?Vendor_Category_ID=1&Vendor_Type_ID=1" onfocus="if (this.blur) this.blur();">Entertainment & Parties</a>';
menu4[3]='<a href="vendorListingsGeneral.cfm?Vendor_Category_ID=7&Vendor_Type_ID=1" onfocus="if (this.blur) this.blur();">Extra Curricular / Enrichment</a>';
menu4[4]='<a href="vendorListingsGeneral.cfm?Vendor_Category_ID=5&Vendor_Type_ID=1" onfocus="if (this.blur) this.blur();">Food & Entertainment</a>';
menu4[5]='<a href="vendorListingsGeneral.cfm?Vendor_Category_ID=4&Vendor_Type_ID=1" onfocus="if (this.blur) this.blur();">Personal Care & Safety</a>';
menu4[6]='<a href="vendorListingsGeneral.cfm?Vendor_Category_ID=6&Vendor_Type_ID=1" onfocus="if (this.blur) this.blur();">Professional Services</a>';
menu4[7]='<a href="vendorListingsGeneral.cfm?Vendor_Category_ID=3&Vendor_Type_ID=1" onfocus="if (this.blur) this.blur();">Shopping</a>';
menu4[8]='<a href="vendorListingsGeneral.cfm?Vendor_Category_ID=57&Vendor_Type_ID=1" onfocus="if (this.blur) this.blur();">Travel</a>';


var disappeardelay=200  	//menu disappear speed onMouseout (in miliseconds)
var offsetXadjuster=0 		//horizontal offset of menu from default location. (0-5 is a good value)
var offsetYadjuster=0		//vertical offset of menu from default location. (0-5 is good value)

var IE=document.all;		//DOM selector for Internet Explorer
var FF=document.getElementById&&!document.all;  //DOM selector for Compliant Browsers
var bVer=parseInt(navigator.appVersion);
var ie7 = (document.all && !window.opera && window.XMLHttpRequest) ? true : false;

if (IE||FF){//Create the Drop Menu Object
	document.write('<div id="dropmenudiv" style="visibility:hidden;width: 170px;z-index:1000;" onMouseover="clearHideMenu()" onMouseout="dynamicHide(event)"></div>');
}

function populatemenu(what){
	if (IE||FF){objDropMenu.innerHTML=what.join("");}
}

// Get X location of the Menu Item
function getOffsetX(what){
	var offsetX= what.offsetLeft;
	var parentEl=what.offsetParent;
	while (parentEl!=null){
		offsetX = offsetX+parentEl.offsetLeft;
		parentEl=parentEl.offsetParent;
	}
	return offsetX;
}
// Get Y location of Menu Item
function getOffsetY(what){
	var offsetY= what.offsetTop;
	var parentEl=what.offsetParent;
	while (parentEl!=null){
		offsetY= offsetY + parentEl.offsetTop;
		parentEl=parentEl.offsetParent;
	}
	offsetY = offsetY + 16;
	return offsetY;
}

function ShowHide(obj, e, visible, hidden, menuwidth){
	if (IE||FF){
		objDropMenu.style.left=objDropMenu.style.top=-500;
		objDropMenu.objWidth=objDropMenu.style;
		objDropMenu.objWidth.width=menuwidth;
		if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover"){
			obj.visibility='visible';
		}
		else if (e.type=="click"){
			obj.visibility='hidden';
		}
	}
}

function dropdownmenu(obj, e, menucontents, menuwidth){
	if (window.event){event.cancelBubble=true;}
	else if (e.stopPropagation){e.stopPropagation();}

	clearHideMenu();
	objDropMenu=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv;
	populatemenu(menucontents);
	if (IE||FF){
		ShowHide(objDropMenu.style, e, "visible", "hidden", menuwidth);
		objDropMenu.x=getOffsetX(obj);
		objDropMenu.y=getOffsetY(obj);
		var docURL = parseUrl(document.URL);
		var thePage = docURL.file;
function Left(str, n)
{
   if (n <= 0)
         return "";
   else if (n > String(str).length)
         return str;
   else
         return String(str).substring(0,n);
}
		if (ie7) {
		 if(Left(document.URL,49)=="http://www.campzoom.com/vendorListingsGeneral.cfm"){
			objDropMenu.y=objDropMenu.y - 10;
		 }
		 if(thePage=="index.cfm"||thePage==""){
			objDropMenu.y=objDropMenu.y + 10;
		 }
		}
		if (IE&&bVer<=6) {
			objDropMenu.y=objDropMenu.y - 10;
		}
		if (window.opera) {
			objDropMenu.y=objDropMenu.y - 0;
		}
		objDropMenu.style.left=objDropMenu.x + "px";
		objDropMenu.style.top=objDropMenu.y + "px";
	}
	return clickValue();
}

function clickValue(){
	if (IE||FF){return false;}
	else {return true;}
}

function contains_FF(a, b) {
	while (b.parentNode){
		if ((b = b.parentNode) == a){return true;}
		else {return false;}
	}
}

function dynamicHide(e){
	if (IE&&!objDropMenu.contains(e.toElement)){delayHideMenu();}
	else if (FF&&e.currentTarget!= e.relatedTarget&& !contains_FF(e.currentTarget, e.relatedTarget)){
		delayHideMenu();
	}
}

function hideMenu(e){
	if (typeof objDropMenu!="undefined"){
		if (IE||FF)
			objDropMenu.style.visibility="hidden"
	}
}

function delayHideMenu(){
	if (IE||FF){
		delayhide=setTimeout("hideMenu()",disappeardelay);
	}
}

function clearHideMenu(){
	if (typeof delayhide!="undefined"){
		clearTimeout(delayhide);
	}
}

/* SAVE TO ORGANIZER */
var xhrSave = false;

function saveVendor(a,b){
	var dtToday = new Date();
	var v_div = document.getElementById('vsave_'+a);

	v_div.innerHTML = '<img src="includes/images/ajax/geo_animation.gif" border="none" alt="Processing..." />';

	var url = 'async/organizer_save.cfm?vendor_id='+a+'&active='+b+'&uti='+dtToday.getHours() + dtToday.getMinutes() + dtToday.getMilliseconds();

	try{xhrSave=new XMLHttpRequest();}	// Firefox, Opera 8.0+, Safari
	catch (e){	// Internet Explorer
		try{xhrSave=new ActiveXObject("Msxml2.XMLHTTP");}
		catch (e){	// IE 7 on Vista
			try{xhrSave=new ActiveXObject("Microsoft.XMLHTTP");}
			catch (e){        
				alert("Asynchronis Data Transfer unavailable, please use Internet Explorer!");        
				return false;
			}
		}
	}

	if (xhrSave) {
		xhrSave.onreadystatechange = function(){
			if (xhrSave.readyState == 4 || xhrSave.readyState == 'undefined') {
				if (xhrSave.status == 200){
					result = trim(xhrSave.responseText);
					switch(result){
					case '0': v_div.innerHTML = '<a href="javascript: saveVendor(\''+a+',\'1\');"><font face="wingdings"><</font>Save to CZ Organizer</a>';break;
					case '1': v_div.innerHTML = '';break;
					case '2': window.location = 'index.cfm';
					}
					xhrSave.abort();
				}
				else{
					v_div.innerHTML = 'Error: ' + xhrSave.status + ': ' + showStatus(xhrSave.status);
					xhrSave.abort();
				}
			}
		}
		xhrSave.open("GET", url, true);
		xhrSave.send(null);
	}
	else {
		alert("Asynchronous Data Error!");
	}}

