// JavaScript Document
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


/*
	Open Pop-Up editor window;
*/

function getEdit(objLocation){
	tempWin = window.open(objLocation,"na","width=750,height=450,resizable=yes,left=0,top=0");
	tempWin.focus();
	tempWin.onunload = function (){
		window.location.reload();
	}
}

/*
	Open Pop-Up editor window off of the quick menu;
*/

function getEdit2(objLocation,w,h){
	tempWin = window.open(objLocation,"na","width="+w+",height="+h+",resizable=yes,scrollbars=yes,left=0,top=0");
	tempWin.focus();
	tempWin.onunload = function (){
		window.location.reload();
	}
}

/*
	Pop-up menu functions;
*/
function showMenu(vname,obj){
	var sens_x = 250;
	if(typeof tempTimer!="undefined")clearInterval(tempTimer);	
	pageQueryObject = obj;
	current_ID.innerText=vname;
	document.all.menu.style.visibility="visible";
	document.all.menu.style.filter = 'alpha(Opacity=0, FinishOpacity=0, Style=1, StartX=0, StartY=0, FinishX=200, FinishY=0)';	
	xMousePos = window.event.x+document.body.scrollLeft;
    yMousePos = window.event.y+document.body.scrollTop;
	document.all.menu.style.top=(yMousePos+5);	
	if(xMousePos >=(document.body.clientWidth-sens_x)){
		document.all.menu.style.left=(xMousePos-sens_x);			
	}else{
		document.all.menu.style.left=(xMousePos+7);				
	}	
	
	tempTimer = setInterval("fadeIn()",40);
	timeCount = 0;
	
	//alert("x: "+xMousePos+" - limit: "+(screen.width-300)+" sc: "+document.body.clientWidth);
}

function hideMenu(){
	//document.all.menu.style.visibility="hidden";
	//document.getElementById('menu').style.visibility="hidden";
	alert(document.getElementById('menu'));
}
function quickMenu(){
	//Properties;
		this.w=200;
		this.elements 	 = 	new Array();	
		this.popup = false;
		this.popup_w = 750;
		this.popup_h = 450;				
	
	//Methods;
	
	this.create = function(){
	/*
		document.onclick = function (){
			if(window.event.srcElement.id!="edit")document.all.menu.style.visibility='hidden';
		}	
	*/	
								
		document.write('<DIV ID="menu" STYLE="position:absolute;z-index:20;width:'+this.w+'px;background-color:#FFFFFF; visibility:hidden;overflow: border-top:1px solid #c6c6c6;border-left:1px solid #c6c6c6;border-right:1px solid #000000;border-bottom:1px solid #000000;filter:alpha(Opacity=100, FinishOpacity=0, Style=1, StartX=0, StartY=0, FinishX=200, FinishY=0);filter:progid:DXImageTransform.Microsoft.Shadow(direction=135,color=#A2A2A2,strength=4);">');
		document.write('<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="2" WIDTH="100%" BGCOLOR="#FFFFFF">');
		document.write('		<TR>');
		document.write('			<TD BGCOLOR="#CCCCCC" COLSPAN="2">');
		document.write('				<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" WIDTH="100%">');
		document.write('					<TR>');
		document.write('						<TD><SPAN CLASS="form_display"><B></B><SPAN CLASS="menu_header" ID="current_ID"></SPAN></TD>');
		document.write('						<TD ALIGN="RIGHT" VALIGN="TOP"><IMG SRC="images/x.gif" WIDTH="14" HEIGHT="14" ALT="Close" BORDER="0" onClick="document.all.menu.style.visibility=\'hidden\';" ALIGN="RIGHT"></TD>');
		document.write('					</TR>');
		document.write('				</TABLE>');
		document.write('			</TD>');
		document.write('		</TR>');
		document.write('		<TR onMouseOver="table_mouseOver(this)" onMouseOut="table_mouseOut(this)" STYLE="cursor:hand" CLASS="tableRow" ID="m1">');
		document.write('			<TD COLSPAN="2" BGCOLOR="#f9f9f9" HEIGHT="1"></TD>');			
		document.write('		</TR>');	
		document.write('		<TR onMouseOver="table_mouseOver(this)" onMouseOut="table_mouseOut(this)" STYLE="cursor:hand" CLASS="tableRow" ID="m1">');
		document.write('			<TD COLSPAN="2" BGCOLOR="#7e7e7e" HEIGHT="1"></TD>');			
		document.write('		</TR>');		
	
			
		for(var x=0;x<this.elements.length;x++){
			var temp = this.elements[x].split("|");
			var image 	 = (temp[0]!="" ? "<IMG SRC='"+temp[0]+"' BORDER='0' ALIGN='absmiddle' ALT='menu icon'>" : " ");
			var location = temp[1];
			var display	 = temp[2];
			location = (location.indexOf("?")>0 ? location : location+"?");
			
			if(display=="<HR>"){
					document.write('		<TR onMouseOver="table_mouseOver(this)" onMouseOut="table_mouseOut(this)" STYLE="cursor:hand" CLASS="tableRow" ID="m1">');
					document.write('			<TD COLSPAN="2" BGCOLOR="#b4b4b4" HEIGHT="1"></TD>');			
					document.write('		</TR>');
			}else{
				if(this.popup){
					document.write('		<TR onMouseOver="table_mouseOver(this)" onMouseOut="table_mouseOut(this)" STYLE="cursor:hand" CLASS="tableRow" ID="m1">');
					document.write('			<TD VALIGN="TOP">'+image+'</TD>');
					document.write('			<TD><A HREF="#" onClick="document.all.menu.style.visibility=\'hidden\';getEdit2(\''+location+'\'+getPageQueryObject(),'+this.popup_w+','+this.popup_h+');return false;"  STYLE="text-decoration:none;color:#000000"><SPAN CLASS="form_display">'+display+'</A></TD>');
					document.write('		</TR>');
				}else{
					document.write('		<TR onMouseOver="table_mouseOver(this)" onMouseOut="table_mouseOut(this)" STYLE="cursor:hand" CLASS="tableRow" ID="m1">');
					document.write('			<TD VALIGN="TOP">'+image+'</TD>');
					document.write('			<TD><A HREF="#" onClick="document.location=\''+location+'\'+getPageQueryObject();return false;"  STYLE="text-decoration:none;color:#000000"><SPAN CLASS="form_display">'+display+'</A></TD>');
					document.write('		</TR>');
				}	
			}			
		}
		document.write('</TABLE>');		
		document.write('</DIV>');
	}
	
	this.createUpload = function(){
								
		document.write('<DIV ID="menu" STYLE="position:absolute;z-index:20;width:'+this.w+'px;background-color:#FFFFFF; visibility:hidden;overflow: border-top:1px solid #c6c6c6;border-left:1px solid #c6c6c6;border-right:1px solid #000000;border-bottom:1px solid #000000;filter:alpha(Opacity=100, FinishOpacity=0, Style=1, StartX=0, StartY=0, FinishX=200, FinishY=0)">');
		document.write('<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="2" WIDTH="100%" BGCOLOR="#FFFFFF">');
		document.write('		<TR>');
		document.write('			<TD BGCOLOR="#CCCCCC" COLSPAN="2">');
		document.write('				<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" WIDTH="100%">');
		document.write('					<TR>');
		document.write('						<TD><SPAN CLASS="form_display"><B></B><SPAN CLASS="menu_header" ID="current_ID"></SPAN></TD>');
		document.write('						<TD ALIGN="RIGHT" VALIGN="TOP"><IMG SRC="../Images/x.gif" WIDTH="14" HEIGHT="14" ALT="Close" BORDER="0" onClick="document.all.menu.style.visibility=\'hidden\';" ALIGN="RIGHT"></TD>');
		document.write('					</TR>');
		document.write('				</TABLE>');
		document.write('			</TD>');
		document.write('		</TR>');
		document.write('		<TR STYLE="cursor:hand" CLASS="tableRow" ID="m1">');
		document.write('			<TD VALIGN="TOP" COLSPAN="2"><INPUT TYPE="file" NAME="uploadFile"><input type="image" name="UPLOAD" value="Upload PDF" src="../Images/Icons/upload.gif" alt="Upload PDF" align="absmiddle" border="0"></TD>');
		document.write('		</TR>');
		document.write('</TABLE>');		
		document.write('</DIV>');
	}	
}

function fadeIn(){
	timeCount = (timeCount+1);
	if(timeCount<10){
		document.getElementById('menu').style.filter = 'alpha(Opacity='+(timeCount*10)+', FinishOpacity='+(timeCount*10)+', Style=1, StartX=0, StartY=0, FinishX=200, FinishY=0)';
	}else{
		document.getElementById('menu').style.filter = 'alpha(Opacity=100, FinishOpacity=100, Style=1, StartX=0, StartY=0, FinishX=200, FinishY=0)';
		clearInterval(tempTimer);
		timeCount=0;
	}
}
/*
	This gets the query string and appends it to the end of an object;
*/
function getPageQueryObject(){
	if(pageQueryObject){
		var tmp= new Array();	
		for (var i in pageQueryObject)tmp.push(i+"="+pageQueryObject[i]);
		return tmp.join("&");
	}else{
		return false;
	}
}

