/***********************************************
* Sticky Note script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* Visit DynamicDrive.com for hundreds of DHTML scripts
* This notice must stay intact for legal use
* Go to http://www.dynamicdrive.com/ for full source code
***********************************************/
//http://www.dynamicdrive.com/dynamicindex17/stickynote.htm
//Specify display mode. 3 possible values are:
//1) "always"- This makes the fade-in box load each time the page is displayed
//2) "oncepersession"- This uses cookies to display the fade-in box only once per browser session
//3) integer (ie: 5)- Finally, you can specify an integer to display the box randomly via a frequency of 1/integer...
// For example, 2 would display the box about (1/2) 50% of the time the page loads.
var displaymode="always";
var enablefade="yes"; //("yes" to enable fade in effect, "no" to disable)
var showonscroll="yes"; //Should box remain visible even when user scrolls page? ("yes"/"no)
var IEfadelength=1; //fade in duration for IE, in seconds
var Mozfadedegree=0.05; //fade in degree for NS6+ (number between 0 and 1. Recommended max: 0.2)
////////No need to edit beyond here///////////
if (parseInt(displaymode)!=NaN)
var random_num=Math.floor(Math.random()*displaymode);
function displayfadeinbox(){
	var ie=document.all && !window.opera;
	var dom=document.getElementById;
	iebody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body;
	objref=(dom)? document.getElementById("fadeinbox") : document.all.fadeinbox;
	var scroll_top=(ie)? iebody.scrollTop : window.pageYOffset;
	var docwidth=(ie)? iebody.clientWidth : window.innerWidth;
	docheight=(ie)? iebody.clientHeight: window.innerHeight;
	var objwidth=objref.offsetWidth;
	objheight=objref.offsetHeight;
	objref.style.left=docwidth/2-objwidth/2+"px";
	objref.style.top=scroll_top+docheight/2-objheight/2+"px";	
	if (showonscroll=="yes")
		showonscrollvar=setInterval("staticfadebox()", 50);	
	if (enablefade=="yes" && objref.filters){
		objref.filters[0].duration=IEfadelength;
		objref.filters[0].Apply();
		objref.filters[0].Play();
	}
	objref.style.visibility="visible";
	if (objref.style.MozOpacity){
		if (enablefade=="yes")
			mozfadevar=setInterval("mozfadefx()", 90);
		else{
			objref.style.MozOpacity=1;
			controlledhidebox();
		}
	}
	else
		controlledhidebox();
}
function mozfadefx(){
if (parseFloat(objref.style.MozOpacity)<1)
objref.style.MozOpacity=parseFloat(objref.style.MozOpacity)+Mozfadedegree;
else{
clearInterval(mozfadevar);
controlledhidebox();
}
}
function staticfadebox(){
var ie=document.all && !window.opera;
var scroll_top=(ie)? iebody.scrollTop : window.pageYOffset;
objref.style.top=scroll_top+docheight/2-objheight/2+"px";
}
function hidefadebox(){
objref.style.visibility="hidden";
if (typeof showonscrollvar!="undefined")
clearInterval(showonscrollvar);
}
function controlledhidebox(){
if (autohidebox[0]=="yes"){
var delayvar=(enablefade=="yes" && objref.filters)? (autohidebox[1]+objref.filters[0].duration)*1000 : autohidebox[1]*1000;
setTimeout("hidefadebox()", delayvar);
}
}
function initfunction(){
setTimeout("displayfadeinbox()", 100);
}
function get_cookie(Name) {
var search = Name + "=";
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search);
if (offset != -1) {
offset += search.length;
end = document.cookie.indexOf(";", offset);
if (end == -1)
end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end));
}
}
return returnvalue;
}
function bringtoview(objid){
if (typeof objid=="undefined")
window.scrollTo(0,0);
else if (document.getElementById && document.getElementById(objid).scrollIntoView)
document.getElementById(objid).scrollIntoView();
else
window.location="#source";
}
/***********************************************
* Email Validation script- © Dynamic Drive (www.dynamicdrive.com)
***********************************************/
var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i
function checkemail(e){
var returnval=emailfilter.test(e.value)
if (returnval==false){
alert("Please enter a valid email address.")
e.select()
}
return returnval
}
//// pop-up window
// this is code to open up a detail window that will automatically close when not the primary window
// this script will open a child window
// and then close it when the focus comes back to this window
// the focus code is in the body tag
// it should look like this:
//       onFocus="show_window('','yes')"
var childWindow=null;
//function show_window(template_url, close_window, win_height, win_width) {
function show_window(template_url) {
	// are we closing the window?
	/*if (close_window == "yes" ) {
		if ( childWindow != null ) {
			if (!childWindow.closed) {
				childWindow.close();
				childWindow=null;
			}
		} // endif window !null
		return;		
	} // endif cancel window
	
	// make defaults for width and height
	if ( win_height == null ) {
		win_height = 700;
	}
	if ( win_width == null ) {
		win_width = 650;
	} */
	// open window
	var left = Math.floor( (screen.width) / 9);
	var top = Math.floor( (screen.height) / 9);
	var height = Math.floor(screen.height * 0.8); 
    var width = Math.floor(screen.width * 0.8);
	var winParms = ",top=" + top + ",left=" + left + ",height=" + height + ",width=" + width;
	//if (parms) { winParms += "," + parms; }

	var winOptions = "resizable=yes,"
		+"location=yes,"
		+"scrollbars=yes,"
		+"dependent=no,"
		+"status=yes,"
		+"toolbar=no,"
		+"directories=no,"
		+"menubar=no"+winParms;
		
	childWindow = open(
		template_url, 
		"tp_child_window",
		winOptions );
	//if (parseInt(navigator.appVersion) >= 4) { childWindow.window.focus(); }
	
	// set caller atributes
	childWindow.opener=this;

	// focus window
	childWindow.focus();
  
} // end show_window

function setCmd(formElement, theValue){
	theForm = formElement.form;
	theForm.cmd.value = theValue;
	theForm.submit();
}


function WriteLayer(ID,parentID,sText){ 
 //http://www.sitepoint.com/article/layers-content-javascript
 if (document.layers) { 
   var oLayer; 
   if(parentID){ 
     oLayer = eval('document.' + parentID + '.document.' + ID + '.document'); 
   }else{ 
     oLayer = document.layers[ID].document; 
   } 
   oLayer.open(); 
   oLayer.write(sText); 
   oLayer.close(); 
 } 
 else if (parseInt(navigator.appVersion)>=5&&navigator. 
appName=="Netscape") { 
   document.getElementById(ID).innerHTML = sText; 
 } 
 else if (document.all) document.all[ID].innerHTML = sText 
} 
/*
Sample uses: <a href='' onclick="JavaScript:confirm_entry('confirm action msg')">Anchor text</a>
<form onSubmit="confirm_entry('confirm action msg')">
<input type="submit" >
</form>
*/
function confirm_entry(dispMessage){
	input_box=confirm(dispMessage);
	if (input_box==true){ 
		// Output when OK is clicked
		return true;
	} else {
		// Output when Cancel is clicked
		return false;
	}
}
//////////
function toggle_visibility(id) {
   var e = document.getElementById(id);
   if(e.style.display == 'block')
      e.style.display = 'none';
   else
      e.style.display = 'block';
}
function set_visibility(id,state) {
   var e = document.getElementById(id);
   if(state == 1)
      e.style.display = 'block';
   else
      e.style.display = 'none';
}
function setCookie(c_name,value,expiredays){
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}
function encode64(inp){
var key="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
var chr1,chr2,chr3,enc3,enc4,i=0,out="";
while(i<inp.length){
chr1=inp.charCodeAt(i++);if(chr1>127) chr1=88;
chr2=inp.charCodeAt(i++);if(chr2>127) chr2=88;
chr3=inp.charCodeAt(i++);if(chr3>127) chr3=88;
if(isNaN(chr3)) {enc4=64;chr3=0;} else enc4=chr3&63
if(isNaN(chr2)) {enc3=64;chr2=0;} else enc3=((chr2<<2)|(chr3>>6))&63 
out+=key.charAt((chr1>>2)&63)+key.charAt(((chr1<<4)|(chr2>>4))&63)+key.charAt(enc3)+key.charAt(enc4);
}
return encodeURIComponent(out);
}
//  End -->