/*********************
//* jQuery Drop Line Menu- By Dynamic Drive: http://www.dynamicdrive.com/
//* Last updated: June 27th, 09'
//* Menu avaiable at DD CSS Library: http://www.dynamicdrive.com/style/
*********************/

//get the base_url and write it:
//baseurl = document.write(base_url);

var droplinemenu={

arrowimage: {classname: 'downarrowclass', src: 'img/down.gif', leftpadding: 7}, //customize down arrow image
animateduration: {over: 100, out: 100}, //duration of slide in/ out animation, in milliseconds

buildmenu:function(menuid){
	jQuery(document).ready(function($){
		var $mainmenu=$("#"+menuid+">ul")
		var $headers=$mainmenu.find("ul").parent()
		$headers.each(function(i){
			var $curobj=$(this)
			var $subul=$(this).find('ul:eq(0)')
			this._dimensions={h:$curobj.find('a:eq(0)').outerHeight()}
			this.istopheader=$curobj.parents("ul").length==1? true : false
			if (!this.istopheader)
				$subul.css({left:0, top:this._dimensions.h})
			var $innerheader=$curobj.children('a').eq(0)
			$innerheader=($innerheader.children().eq(0).is('span'))? $innerheader.children().eq(0) : $innerheader //if header contains inner SPAN, use that
			$innerheader.append(
				'<img src="' + base_url + droplinemenu.arrowimage.src
				+'" class="' + droplinemenu.arrowimage.classname
				+ '" style="border:0; padding-left: '+droplinemenu.arrowimage.leftpadding+'px" />'
			)
			$curobj.hover(
				function(e){
					var $targetul=$(this).children("ul:eq(0)")
					if ($targetul.queue().length<=1) //if 1 or less queued animations
						if (this.istopheader)
							$targetul.css({left: $mainmenu.offset().left, top: $mainmenu.offset().top+this._dimensions.h})
						if (document.all && !window.XMLHttpRequest) //detect IE6 or less, fix issue with overflow
							$mainmenu.find('ul').css({overflow: (this.istopheader)? 'hidden' : 'visible'})
						$targetul.slideDown(droplinemenu.animateduration.over)
				},
				function(e){
					var $targetul=$(this).children("ul:eq(0)")
					$targetul.slideUp(droplinemenu.animateduration.out)
				}
			) //end hover
		}) //end $headers.each()
		$mainmenu.find("ul").css({display:'none', visibility:'visible', width:$mainmenu.width()})
	}) //end document.ready
}
}

/****END OF DROP BAR MENU*****/
//
//
/*****************************/

function runajax(objID, serverPage, objHeight, objWidth, objTop, objLeft) {
		
		//Create a boolean variable to check for a valid Internet Explorer instance.
		var xmlhttp = false;
		
		//Check if we are using IE.
		try {
			//If the javascript version is greater than 5.
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			//If not, then use the older active x object.
			try {
				//If we are using Internet Explorer.
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (E) {
				//Else we must be using a non-IE browser.
				xmlhttp = false;
			}
		}
		//If we are using a non-IE browser, create a javascript instance of the object.
		if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
			xmlhttp = new XMLHttpRequest();
		}
		//create the obj var for the if's to use below.
		var obj = document.getElementById(objID);
		
			xmlhttp.open("GET", serverPage);
			xmlhttp.onreadystatechange = function() {

				if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
					obj.style.visibility = "visible";
					obj.style.display = "block";
					obj.style.height = objHeight;
					obj.style.width = objWidth;
					obj.style.top = objTop;
					obj.style.left = objLeft;
					obj.innerHTML = xmlhttp.responseText;
				}
			}
			xmlhttp.send(null);
		
}

function showTooltip(msg, objID, e){
		
		theObject = document.getElementById(objID);
		
		theObject.style.visibility = "visible";
		theObject.style.height = "auto";
		//theObject.style.min-height = "30px";
		theObject.style.width = "300px";

		var posx = 0;
		var posy = 0;
		
		posx = e.clientX + document.body.scrollLeft;
		posy = e.clientY + document.body.scrollTop;
		
		theObject.style.left = posx + 1 + "px";
		theObject.style.top = posy + 1 + "px";
		
		theObject.innerHTML = msg;
		//time the tooltip out after 10 seconds
		//setTimeout("showTooltip()",1000);

}

function openColorBox(objID, objHeight, objWidth) {
	$(objID).colorbox({iframe:true, width:objWidth, height:objHeight});
}

function destroy(objID){
		//This fuction will destroy (or rather make them invisible) an element, which is passed to it.
		tObject = document.getElementById(objID);
		
		//use jquery to make all the children hide.
		$("#" + objID + " div").css("visibility", "hidden");
		$("#" + objID + " div").css("display", "none");
		$("#" + objID + " div").css("height", "0px");
		$("#" + objID + " div").css("width", "0px");
		
		//use regular javascript to make the parent hide.
		tObject.style.visibility = "hidden";
		tObject.style.display = "none";
		tObject.style.height = "0px";
		tObject.style.width = "0px";
}
function popup(form, ht, wd) {
	window.open('', 'formpopup', 'height=' + ht + ',width=' + wd + ',scrollbars=yes,resizeable=no');
	form.target = 'formpopup';
}

	

