﻿// Common Routines JScript File
 var horizontal_offset="9px" //horizontal offset of hint box from anchor link
 var vertical_offset="0"     //horizontal offset of hint box from anchor link. No need to change.
 var ie=document.all
 var ns6=document.getElementById&&!document.all

 function isObject(a) 
 {
     return (typeof a == 'object' && !!a) || isFunction(a);
 }
 function isUndefined(a) 
 {
     return typeof a == 'undefined';
 }
//************ HINT FUNCTIONS ********************* 
function getposOffset(what, offsettype){
  var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
  var parentEl=what.offsetParent;
  while (parentEl!=null){
    totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
    parentEl=parentEl.offsetParent;
  }
return totaloffset;
}

function iecompattest(){
  return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
  var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1
  if (whichedge=="rightedge"){
     var windowedge=ie && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-30 : window.pageXOffset+window.innerWidth-40
     dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
     if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
        edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth+parseInt(horizontal_offset)
  }
  else{
     var windowedge=ie && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
     dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
     if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
     edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight
  }
  return edgeoffset
}
       
function showhint(menucontents, obj, e, tipwidth)
{  
  if ((ie||ns6) && document.getElementById("hintbox"))
  { dropmenuobj=document.getElementById("hintbox")
    dropmenuobj.innerHTML=menucontents
    dropmenuobj.style.left=dropmenuobj.style.top=-500
    if (tipwidth!="")
    {
      dropmenuobj.widthobj=dropmenuobj.style
      dropmenuobj.widthobj.width=tipwidth
    }
    dropmenuobj.x=getposOffset(obj, "left")
    dropmenuobj.y=getposOffset(obj, "top")
    dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+obj.offsetWidth+"px"
    dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px"
    dropmenuobj.style.visibility="visible"    
    obj.onmouseout=hidehint
  }
}

function hidehint(e){
    dropmenuobj.style.visibility="hidden"
    dropmenuobj.style.left="-500px"
}

function createhintbox(){
    var divblock=document.createElement("div")
    divblock.setAttribute("id", "hintbox")
    document.body.appendChild(divblock)
}

function MM_findObj(n, d) { 
  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 && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() {
  var i,j=0,x,arg=MM_swapImage.arguments; 
  document.MM_sr=new Array;

  if (( x=MM_findObj(arg[0])) != null)
     { document.MM_sr[0]=x; 
 	   x.oSrc=x.src; 
	   x.src=arg[1];
     }
}

function OpenChildWindow(url, name, args)
{
	if (typeof(popupWin) != "object")
		{ popupWin = window.open(url,"Child",args);} 
	else 
		{ if (!popupWin.closed)
			{ popupWin.location.href = url; }
			else 
			{ popupWin = window.open(url, "Child",args); }
		}
	popupWin.focus();
}

if (window.addEventListener)
   window.addEventListener("load", createhintbox, false)
else if (window.attachEvent)
   window.attachEvent("onload", createhintbox)
   else if (document.getElementById)
     window.onload=createhintbox;		 

/*
	FlashReplace is developed by Robert Nyman, http://www.robertnyman.com. License and downloads: http://code.google.com/p/flashreplace/
*/
// ---
var FlashReplace = {
	elmToReplace : null,
	flashIsInstalled : null,
	defaultFlashVersion : 7,
	replace : function (elmToReplace, src, id, width, height, version, params){
		this.elmToReplace = document.getElementById(elmToReplace);
		this.flashIsInstalled = this.checkForFlash(version || this.defaultFlashVersion);
		if(this.elmToReplace && this.flashIsInstalled){
			var obj = '<object' + ((window.ActiveXObject)? ' id="' + id + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" data="' + src + '"' : '');
			obj += ' width="' + width + '"';
			obj += ' height="' + height + '"';
			obj += '>';
			var param = '<param';
			param += ' name="movie"';
			param += ' value="' + src + '"';
			param += '>';
			param += '';
			
			var extraParams = '';
			var extraAttributes = '';
			for(var i in params){
				extraParams += '<param name="' + i + '" value="' + params[i] + '">';
				extraAttributes += ' ' + i + '="' + params[i] + '"';
			}
			var embed = '<embed id="' + id + '" src="' + src + '" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '"';
			var embedEnd = extraAttributes + '></embed>';
			var objEnd = '</object>';			
			this.elmToReplace.innerHTML = obj + param + extraParams + embed + embedEnd + objEnd;			
		}
	},
	
	checkForFlash : function (version){
		this.flashIsInstalled = false;
		var flash;
		if(window.ActiveXObject){
			try{
				flash = new ActiveXObject(("ShockwaveFlash.ShockwaveFlash." + version));
				this.flashIsInstalled = true;
			}
			catch(e){
				// Throws an error if the version isn't available			
			}
		}
		else if(navigator.plugins && navigator.mimeTypes.length > 0){
			flash = navigator.plugins["Shockwave Flash"];
			if(flash){
				var flashVersion = navigator.plugins["Shockwave Flash"].description.replace(/.*(\d+\.\d+).*/, "$1");
				if(flashVersion >= version){
					this.flashIsInstalled = true;
				}
			}
		}
		return this.flashIsInstalled;
	}
};
// ---