// JavaScript Document

function isFunction(a) 
 {
      return typeof a == 'function';
 }
 
 function isObject(a) 
 {
     return (typeof a == 'object' && !!a) || isFunction(a);
 }

function playFlash(target){
	
	if (isFunction(document.getElementById(target).passGo) == true) {
		document.getElementById(target).passGo();
	} else {
		playFlash(target);
	}
	
}

function moveFlash(target, name) {

	if (navigator.appName.indexOf("Microsoft Internet")==-1){
		var cleft = 277;
	} else {
		var cleft = 277;
	}
	var ctop = 0;	
	var an = document.getElementById(target)
	var obj = an;
	while (obj.offsetParent) {
    	cleft += obj.offsetLeft;
	    ctop += obj.offsetTop;
		obj = obj.offsetParent;
	}
	box = document.getElementById(name);
	box.style.left = cleft + 'px';
	if (document.body.currentStyle && document.body.currentStyle['marginTop']) {
		ctop += parseInt(document.body.currentStyle['marginTop']);
	}
	box.style.top = ctop + 'px';
	
	if(document.getElementById('myFlash')){
		
		setTimeout("playFlash('myFlash')",1000); 
		
	}


}



function updateFlash() {
	
		moveFlash("pageTable", "flashmenu");
				
}
	
function swapImage(target, newImage, intOptions) {
	
		//declare variables
		var x;
		
		//get new image number
		x = Math.floor(Math.random() * intOptions) + 1;
		//alert(x);
		
		//replace image
		document.getElementById(target).src = "Images/" + newImage + x + ".jpg";
		
}

function move_box(left, top, an, box) {
  var cleft = left;
  var ctop = top;
  var obj = an;
  while (obj.offsetParent) {
    cleft += obj.offsetLeft;
    ctop += obj.offsetTop;
    obj = obj.offsetParent;
  }
  box.style.left = cleft + 'px';
  ctop += an.offsetHeight + 0;
  if (document.body.currentStyle && document.body.currentStyle['marginTop']) {
    ctop += parseInt(document.body.currentStyle['marginTop']);
  }
  box.style.top = ctop + 'px';
}

function hideMenu(name) {
  var child = document.getElementById('DropDownMenu').getElementsByTagName("div");
  for(var j =0;j<child.length;j++){
    if(child[j].id !=name){
      child[j].style.display = "none";
    }
  }

}

function closeMenu() {
	if (typeof(CountKeep) != "undefined") {
		clearTimeout(CountKeep)
	}	
	counter = setTimeout("hideMenu('')", 600)
	
}

function keepMenu() {
	if (typeof(counter) != "undefined") {
		clearTimeout(counter)
	}	
	CountKeep = setTimeout("keepMenu()", 500)
}

function showMenu(left, top, an, name) {
  
  var href = an.href;
  var a = document.getElementById('menutop');
  var boxdiv = document.getElementById(name);
  keepMenu();
  hideMenu(name);

  if (boxdiv != null) {
    if (boxdiv.style.display=='none') {
      //move_box(left, top, a, boxdiv);
      boxdiv.style.display='block';
    } 
  }
}

cookie_name = "flashCookie";

function setCookie() {
	
	var expdate = new Date();
	expdate.setTime(expdate.getTime() +  (24 * 60 * 60 * 1000 * 365)); 

	if(document.cookie != document.cookie) {
		index = document.cookie.indexOf(cookie_name);
	} else { 
		index = -1;
	}

	if (index == -1){
		document.cookie=cookie_name+"=no; expires=" + expdate.toGMTString() + ";";
	}

}

function getCookie() {

	if(document.cookie){

		index = document.cookie.indexOf(cookie_name);
		
		if (index != -1){
		
			flashstart = (document.cookie.indexOf("=", index) + 1);
			flashend = document.cookie.indexOf(";", index);
			
			if (flashend == -1) {
				flashend = document.cookie.length;
			}
			
			wantsFlash = document.cookie.substring(flashstart, flashend);
			
			return wantsFlash;
			
		}
	}
}


	
		