/*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_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_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];}
}

*/function limitText(limitField, limitCount, limitNum) {
	//from http://www.mediacollege.com/internet/javascript/form/limit-characters.html
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		limitCount.value = limitNum - limitField.value.length;
	}
}

var editing_on_page=false;
function showEditLink(editID) {
	document.getElementById(editID+"_overlay").setAttribute("class", "overlayOn");
	document.getElementById(editID+"_overlay").setAttribute("className", "overlayOn");
	document.getElementById(editID+"_overlayText").setAttribute("class", "overlayTextOn");
	document.getElementById(editID+"_overlayText").setAttribute("className", "overlayTextOn");
	return false;
}
function hideEditLink(editID) {
	if(!editing_on_page) {
		document.getElementById(editID+"_overlay").setAttribute("class", "overlayOff");
		document.getElementById(editID+"_overlay").setAttribute("className", "overlayOff");
		document.getElementById(editID+"_overlayText").setAttribute("class", "overlayTextOff");
		document.getElementById(editID+"_overlayText").setAttribute("className", "overlayTextOff");
	}
	return false;
}
function showEditDiv(editID) {
	document.getElementById(editID+"_overlayEdit").setAttribute("class", "overlayEditOn");
	document.getElementById(editID+"_overlayEdit").setAttribute("className", "overlayEditOn");
	document.getElementById(editID+"_overlay").setAttribute("class", "overlayEditing");
	document.getElementById(editID+"_overlay").setAttribute("className", "overlayEditing");
	document.getElementById(editID+"_overlayText").setAttribute("class", "overlayTextOn");
	document.getElementById(editID+"_overlayText").setAttribute("className", "overlayTextOn");
	document.getElementById("overlayEditContainer_underlay").setAttribute("class", "overlayEditContainer_underlayOn");
	document.getElementById("overlayEditContainer_underlay").setAttribute("className", "overlayEditContainer_underlayOn");
	editing_on_page=true;
	return false;
}
function hideEditDiv(editID) {
	document.getElementById(editID+"_overlayEdit").setAttribute("class", "overlayEditOff");
	document.getElementById(editID+"_overlayEdit").setAttribute("className", "overlayEditOff");
	document.getElementById(editID+"_overlay").setAttribute("class", "overlayOff");
	document.getElementById(editID+"_overlay").setAttribute("className", "overlayOff");
	document.getElementById("overlayEditContainer_underlay").setAttribute("class", "overlayEditContainer_underlayOff");
	document.getElementById("overlayEditContainer_underlay").setAttribute("className", "overlayEditContainer_underlayOff");
	editing_on_page=false;
	return false;
}


/*+begin+ Draggable div*/
//Draggable Div by surren @ http://www.diffusedreality.com
var x;
var y;
var element;
var being_dragged = false;
function mouser(event){
	if(event.offsetX || event.offsetY) { //For Internet Explorer
		x=event.offsetX;
		y=event.offsetY;
	} else { //For FireFox
		x=event.pageX;
		y=event.pageY;
	}/*
	document.getElementById('X').innerHTML = x +'px';
	document.getElementById('Y').innerHTML = y +'px';
	document.getElementById('X-coord').innerHTML = x +'px';
	document.getElementById('Y-coord').innerHTML = y +'px';*/
	if(being_dragged == true) {
		document.getElementById(element).style.left = x-20 +'px';
		document.getElementById(element).style.top = y-10 +'px';
	}
}
function mouse_down(ele_name) {
	being_dragged = true;
	element = ele_name;
	document.getElementById(element).style.cursor = 'move';
}
function mouse_up() {
	being_dragged = false;
	document.getElementById(element).style.top = y-20 +'px';
	document.getElementById(element).style.left = x-10 +'px';
	document.getElementById(element).style.cursor = 'auto';
}
/*+end+ Draggable div*/


function addLoadEvent(func) {
	//Copied from http://www.webreference.com/programming/javascript/onloads/
	//Function written by Simon Willison (http://simonwillison.net/)
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			if (oldonload) {
				oldonload();
			}
			func();
		}
	}
}

//addLoadEvent(function1toadd);//Add another line like this for every additional "onload" function to add
//addLoadEvent(function2toadd);//Add another line like this for every additional "onload" function to add
//addLoadEvent(function3toadd);//Add another line like this for every additional "onload" function to add
//addLoadEvent(function() {document.body.style.backgroundColor = '#EFDF95';});
