

function inject_in_center(url) {
	jQuery('#injected_content').load(url);
	jQuery('#injected_content').hide();	
	jQuery('.sub').slideUp();
	jQuery('#injected_content').slideDown('slow');
	jQuery('.anythingSlider').slideUp('slow');
}



function load_in_center(url) {
	jQuery('#printReady').fadeOut();
	//jQuery('#printReady').css({ opacity: 0.4 });
	//please_wait();	
	jQuery('#printReady').load(url);
	//jQuery('#printReady').fadeTo('slow',1);
	//cancel_please_wait();
	jQuery('#printReady').fadeIn();
	jQuery('.anythingSlider').slideUp('slow');
}

//
//
// The open methods below were previously being called with async=true (third argument) however this
// was breaking with the Safari browser so they were set to false to behave synchronously.
//

function fetchDataSync(url,dataToSend,objectID){
  	var pageRequest = false;
  	document.getElementById("error").innerHTML = '';
  	if (window.XMLHttpRequest) pageRequest = new XMLHttpRequest();
  	else if (window.ActiveXObject) pageRequest = new ActiveXObject("Microsoft.XMLHTTP");
  	else return false;
  	pageRequest.onreadystatechange = function () {
	    filterData(pageRequest,objectID);
	}
	if (dataToSend) {
	  var sendData = 'sendData=' + dataToSend;
	  pageRequest.open('POST',url,false);
	  pageRequest.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	  pageRequest.send(sendData);
	} else {
	  pageRequest.open('GET',url,false);
	  pageRequest.send(null); 
	}
}


function fetchData(url,dataToSend,objectID){
  	var pageRequest = false;
  	document.getElementById("error").innerHTML = '';
  	if (window.XMLHttpRequest) pageRequest = new XMLHttpRequest();
  	else if (window.ActiveXObject) pageRequest = new ActiveXObject("Microsoft.XMLHTTP");
  	else return false;
  	pageRequest.onreadystatechange = function () {
	    filterData(pageRequest,objectID);
	}
	if (dataToSend) {
	  var sendData = 'sendData=' + dataToSend;
	  pageRequest.open('POST',url,true);
	  pageRequest.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	  pageRequest.send(sendData);
	} else {
	  pageRequest.open('GET',url,true);
	  pageRequest.send(null); 
	}
}

//
//
// There is still a bug in here that is causing an error on Safari browsers only
// pageRequest.status evaluates to 0 on Safari if the XMLhttpRequest is openened with async = true.
//
// Changed the open function aboce to "false" for async operation to accomodate Safari issue.
//
function filterData(pageRequest,objectID){
  	var object = document.getElementById(objectID);
  	
  	if (pageRequest.readyState == 4) {
  		//alert('In filter data - ready state is '+pageRequest.readyState);
  		//alert('page request status is '+pageRequest.status);
	    if (pageRequest.status==200) {
	    	//alert('Page response text is '+pageRequest.responseText);
	    	object.innerHTML = pageRequest.responseText;
	    }
	    else if (pageRequest.status==404)
	    	object.innerHTML = 'Sorry, this information could not be retrieved from the database';
	    else
	    	object.innerHTML = 'Sorry, but there was a problem retrieving information from the database in AJAX filterData() function.';
	}
}


function setEventField(eventlist, event)
{
	var eventlist, event;
	var mylist=document.getElementById(eventlist);
	//alert('setting to: '+mylist.options[mylist.selectedIndex].text);
	document.getElementById(event).value=mylist.options[mylist.selectedIndex].text
}

function setUserCategoryField(dropdown)
{
var mylist=document.getElementById("user_category_list")
document.getElementById("user_category").value=mylist.options[mylist.selectedIndex].text
}

function setUserSubCategoryField(dropdown)
{
var mylist=document.getElementById("user_subcategory_list")
document.getElementById("user_subcategory").value=mylist.options[mylist.selectedIndex].text
}

function setPhoneField(element)
{
var source1=document.getElementById(element+'phone1').value;
var source2=document.getElementById(element+'phone2').value; 
var source3=document.getElementById(element+'phone3').value;
var source4=document.getElementById(element+'phone4').value;
var num='('+source1+') '+source2+'-'+source3;
if (source4!='') num=num+' x'+source4;
document.getElementById(element).value=num ;
}

function dim_input(x,y) {
if (x!='yes') {		
	document.getElementById(y).disabled = true;
	document.getElementById(y).value = '';
	document.getElementById(y).style.background="#cccccc";
} else {
	document.getElementById(y).disabled = false;
	document.getElementById(y).style.background="white";
}
}

function set_checkbox(x,y) {
document.getElementById(x).style.background="#ffffdd";
document.getElementById(y).checked = true;
}

function set_radiobox(x,y,z) {
//document.getElementById(x).style.background="#ffffdd";
//c=document.getElementById(y+z);
//c.checked = true;
//alert('setting #'+y+z+' to checked');
jQuery('#'+y+z).attr('checked', true);

}


function setAlert(x)
{
document.all.alertform.alerttext.value = x;
}

function clearAlert()
{
document.all.alertform.alerttext.value = '';
}

function gscopytext(control1,control2)
{
		var text = document.getElementById(control1).value;
		document.getElementById(control2).value = text;				
}



function updateTime(th,control,t_h,t_m) 
{
if (document.getElementById("autocalc").checked == true) {
	if (control.match("ev_start")) {
    
  	var hr = document.getElementById(control+"_hr").value;
  	var min = document.getElementById(control+"_min").value;
  	//alert('hour found to be: '+hr);
  	tm = (Number(hr)*60)+Number(min);
  	nt = tm+Number(document.getElementById("minutes").value);
  	nh=Math.floor(nt/60);
  	//alert('nh found to be: '+nh);
  	nm=nt-(60*nh);
  	for (var i=0; i < document.getElementById(t_h).length; i++) {
  	
	    if (Number(document.getElementById(t_h).options[i].value)==nh) {
		    document.getElementById(t_h).options[i].selected=true;
		    
		}
	}
	
	for (var i=0; i < document.getElementById(t_m).length; i++) {
  	     
	    if (Number(document.getElementById(t_m).options[i].text)==nm) {
		    document.getElementById(t_m).options[i].selected=true;
		     
		}
	}
	}
}
}

function recalcDuration(th1,tm1,th2,tm2,index)
{
	if (index == 0) {
		//alert('Changing class length  ' + th1 + ' ' + tm1 + ' '+ th2 + ' ' + tm2);
	  	var start_hr  = document.getElementById(th1).value;		
	  	var start_min = document.getElementById(tm1).value;	
	  	var end_hr  = document.getElementById(th2).value;		
	  	var end_min = document.getElementById(tm2).value;	
	  	
	  	//alert('Changing class length  ' + start_hr + ' ' + start_min + ' '+ end_hr + ' ' + end_min);
	  	
	  	var diff = ((parseInt(end_min)+(parseInt(end_hr)*60))-((parseInt(start_min))+(parseInt(start_hr*60))));
		  		  	
		//alert('Difference ' + diff);
		if (diff > 0) {
			document.getElementById("minutes").value = diff;
		}
	  	
	}
}



/***********************************************
* Pausing up-down scroller- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/

function pausescroller(content, divId, divClass, delay){
this.content=content //message array content
this.tickerid=divId //ID of ticker div to display information
this.delay=delay //Delay between msg change, in miliseconds.
this.mouseoverBol=0 //Boolean to indicate whether mouse is currently over scroller (and pause it if it is)
this.hiddendivpointer=1 //index of message array for hidden div
document.write('<div id="'+divId+'" class="'+divClass+'" style="position: relative; overflow: hidden"><div class="innerDiv" style="position: absolute; width: 100%" id="'+divId+'1">'+content[0]+'</div><div class="innerDiv" style="position: absolute; width: 100%; visibility: hidden" id="'+divId+'2">'+content[1]+'</div></div>')
var scrollerinstance=this
if (window.addEventListener) //run onload in DOM2 browsers
window.addEventListener("load", function(){scrollerinstance.initialize()}, false)
else if (window.attachEvent) //run onload in IE5.5+
window.attachEvent("onload", function(){scrollerinstance.initialize()})
else if (document.getElementById) //if legacy DOM browsers, just start scroller after 0.5 sec
setTimeout(function(){scrollerinstance.initialize()}, 500)
}

// -------------------------------------------------------------------
// initialize()- Initialize scroller method.
// -Get div objects, set initial positions, start up down animation
// -------------------------------------------------------------------

pausescroller.prototype.initialize=function(){
this.tickerdiv=document.getElementById(this.tickerid)
this.visiblediv=document.getElementById(this.tickerid+"1")
this.hiddendiv=document.getElementById(this.tickerid+"2")
this.visibledivtop=parseInt(pausescroller.getCSSpadding(this.tickerdiv))
//set width of inner DIVs to outer DIV's width minus padding (padding assumed to be top padding x 2)
this.visiblediv.style.width=this.hiddendiv.style.width=this.tickerdiv.offsetWidth-(this.visibledivtop*2)+"px"
this.getinline(this.visiblediv, this.hiddendiv)
this.hiddendiv.style.visibility="visible"
var scrollerinstance=this
document.getElementById(this.tickerid).onmouseover=function(){scrollerinstance.mouseoverBol=1}
document.getElementById(this.tickerid).onmouseout=function(){scrollerinstance.mouseoverBol=0}
if (window.attachEvent) //Clean up loose references in IE
window.attachEvent("onunload", function(){scrollerinstance.tickerdiv.onmouseover=scrollerinstance.tickerdiv.onmouseout=null})
setTimeout(function(){scrollerinstance.animateup()}, this.delay)
}


// -------------------------------------------------------------------
// animateup()- Move the two inner divs of the scroller up and in sync
// -------------------------------------------------------------------

pausescroller.prototype.animateup=function(){
var scrollerinstance=this
if (parseInt(this.hiddendiv.style.top)>(this.visibledivtop+2)){
this.visiblediv.style.top=parseInt(this.visiblediv.style.top)-2+"px"
this.hiddendiv.style.top=parseInt(this.hiddendiv.style.top)-2+"px"
setTimeout(function(){scrollerinstance.animateup()}, 50)
}
else{
this.getinline(this.hiddendiv, this.visiblediv)
this.swapdivs()
setTimeout(function(){scrollerinstance.setmessage()}, this.delay)
}
}

// -------------------------------------------------------------------
// swapdivs()- Swap between which is the visible and which is the hidden div
// -------------------------------------------------------------------

pausescroller.prototype.swapdivs=function(){
var tempcontainer=this.visiblediv
this.visiblediv=this.hiddendiv
this.hiddendiv=tempcontainer
}

pausescroller.prototype.getinline=function(div1, div2){
div1.style.top=this.visibledivtop+"px"
div2.style.top=Math.max(div1.parentNode.offsetHeight, div1.offsetHeight)+"px"
}

// -------------------------------------------------------------------
// setmessage()- Populate the hidden div with the next message before it's visible
// -------------------------------------------------------------------

pausescroller.prototype.setmessage=function(){
var scrollerinstance=this
if (this.mouseoverBol==1) //if mouse is currently over scoller, do nothing (pause it)
setTimeout(function(){scrollerinstance.setmessage()}, 100)
else{
var i=this.hiddendivpointer
var ceiling=this.content.length
this.hiddendivpointer=(i+1>ceiling-1)? 0 : i+1
this.hiddendiv.innerHTML=this.content[this.hiddendivpointer]
this.animateup()
}
}

pausescroller.getCSSpadding=function(tickerobj){ //get CSS padding value, if any
if (tickerobj.currentStyle)
return tickerobj.currentStyle["paddingTop"]
else if (window.getComputedStyle) //if DOM2
return window.getComputedStyle(tickerobj, "").getPropertyValue("padding-top")
else
return 0
}


/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Robert Nyman | http://robertnyman.com/ */
function removeHTMLTags(strInputCode){
 	// if(document.getElementById && document.getElementById("input-code")){
 		/* var strInputCode = document.getElementById("input-code").innerHTML; */
 		/* 
  			This line is optional, it replaces escaped brackets with real ones, 
  			i.e. < is replaced with < and > is replaced with >
 		*/	
 	 	strInputCode = strInputCode.replace(/&(lt|gt);/g, function (strMatch, p1){
 		 	return (p1 == "lt")? "<" : ">";
 		});
 		var strTagStrippedText = strInputCode.replace(/<\/?[^>]+(>|$)/g, "");
 		// alert("Output text:\n" + strTagStrippedText);	
   // Use the alert below if you want to show the input and the output text
   //		alert("Input code:\n" + strInputCode + "\n\nOutput text:\n" + strTagStrippedText);	
 	// }
   return strTagStrippedText;	
}




var gAutoPrint = true; // Tells whether to automatically call the print function

function printSpecial()
{
if (document.getElementById != null)
{
var html = '<HTML>\n<HEAD>\n';

if (document.getElementsByTagName != null)
{
var headTags = document.getElementsByTagName("head");
if (headTags.length > 0)
html += headTags[0].innerHTML;

}
var html = '<HTML>\n<HEAD></HEAD><BODY>\n';

var printReadyElem = document.getElementById("printReady");

if (printReadyElem != null)
{
html += printReadyElem.innerHTML;
}
else
{
alert("Could not find the printReady function");
return;
}

html += '\n</BODY>\n</HTML>';

var printWin = window.open("","_self","menubar=0, status=0, toolbar=0, location=0, scrollbars=1, height=800");
 printWin.document.open();
 printWin.document.write(html);
 printWin.document.write('<br/>');
 printWin.document.close();
 

 if (gAutoPrint) {
   alert("The page has been formatted for printing. \r\nThe printer dialog will be started automatically\r\nwhen you press OK.\r\n\r\nAfter you are done printing, please use the browser\r\nback button to return to your web page.");
   printWin.print();
 }
 
}
else
{
alert("The print ready feature is only available if you are using a recent browser. Please update your browser.");
}
}

var vis=1;
function show_cover() 
{  

	var cover=document.getElementById('cover');

	if(vis)
	{
		vis=0;
		cover.style.display='block';      
	} 
	else 
	{   
		vis=1;
		cover.style.display='none'; 
	}

}

var cover_vis=1;
function please_wait(arg) 
{  
	scroll(0,0);
	arg = arg || 'Loading...';
	var string = '<div id="progress"><img src="./images/indicator.gif">'+arg+'</div>'
	jQuery('body').append(string);
	var wait_popup=document.getElementById('wait_popup');

	if(cover_vis)
	{
		cover_vis=0;
		//wait_popup.style.display='block';
		//jQuery('#wait_popup').fadeIn();      
	} 
	else 
	{   
		cover_vis=1;
		wait_popup.style.display='none'; 
	}

}

function cancel_please_wait()
{
	jQuery('#progress').fadeOut();
	jQuery('#progress').remove();
	//alert('test remove indicator from DOM');  
}

// Function limit the length of text placed into a text field
// not that the form must have a name attribute set.
// there should be a span set equivalent to the element name with the suffix _display

function textarea_maxlength(element, maxvalue, form)
     {
     var q = eval("document."+form+"."+element+".value.length");
     var r = q - maxvalue;
     document.getElementById(element+"_display").innerHTML = "Length:"+q+" Remaining: "+(maxvalue - q);
     //alert ("in textarea_maxlength"+element+maxvalue+form);
     var msg = "Sorry, you have input "+q+" characters into the "+
       "text area box you just completed. It can return no more than "+
       maxvalue+" characters to be processed. Please abbreviate "+
       "your text by at least "+r+" characters";
     if (q > maxvalue) alert(msg);
     }


function load()
{
	window.status="Page is loaded";

	if (document.getElementById('side_menu')) { document.getElementById('side_menu').style.display = "block"; }
	if (document.getElementById('top_menu')) { document.getElementById('top_menu').style.display = "block"; }
	if (document.getElementById('scroll_area')) { document.getElementById('scroll_area').style.display = "block"; }
}

/**
Vertigo Tip by www.vertigo-project.com
Requires jQuery
*/
this.vtip=function(){this.xOffset=-10;this.yOffset=10;jQuery(".vtip").unbind().hover(function(a){this.t=this.title;this.title="";this.top=(a.pageY+yOffset);this.left=(a.pageX+xOffset);jQuery("body").append('<p id="vtip"><img id="vtipArrow" />'+this.t+"</p>");jQuery("p#vtip #vtipArrow").attr("src","images/vtip_arrow.png");jQuery("p#vtip").css("top",this.top+"px").css("left",this.left+"px").fadeIn("slow")},function(){this.title=this.t;jQuery("p#vtip").fadeOut("slow").remove()}).mousemove(function(a){this.top=(a.pageY+yOffset);this.left=(a.pageX+xOffset);jQuery("p#vtip").css("top",this.top+"px").css("left",this.left+"px")})};jQuery(document).ready(function(a){vtip()});


function showSidePanelBranch(branch) {
	
	var objSidePanelBranch = document.getElementById(branch).style;
	if(objSidePanelBranch.display=="block")
		objSidePanelBranch.display="none";
	else
		objSidePanelBranch.display="block";
}


