var newWindow = null;

function closeWin(){
	if (newWindow != null){
		if(!newWindow.closed)
			newWindow.close();
	}
}

function popUpWin(url, type, strWidth, strHeight){
	
	closeWin();
	
	if (type == "fullScreen"){
		strWidth = screen.availWidth - 10;
		strHeight = screen.availHeight - 160;
	}
	
	var tools="";
	if (type == "standard" || type == "fullScreen") tools = "resizable,toolbar=yes,location=yes,scrollbars=yes,menubar=yes,width="+strWidth+",height="+strHeight+",top=0,left=0";
	if (type == "console") tools = "resizable,toolbar=no,location=no,scrollbars=no,left=200,top=200,screenX=200,screenY=200,width="+strWidth+",height="+strHeight+",left=0,top=0";
	newWindow = window.open(url, 'newWin', tools);
	newWindow.focus();
}


// Dropdown script

var tim;
var tim2;
var tim3;
var previousLayer = "";
var open_sub_layer = "";
var timeout_time = 0;

function showLayer(id) 
{
	var div = returnDiv(id);
	div.visibility = "visible";
}

function hideLayer(id) 
{
	var div = returnDiv(id);
	div.visibility = "hidden";
}
   

function mouseOutOfLayer(id)
{
	func = "hideLayer('"+id+"');previousLayer = \"\";";
	tim = setTimeout(func, timeout_time);
}
 
function mouseIntoLayer(id)
{
	if(tim)
		clearTimeout(tim);

	if(id.indexOf("sub_") >= 0)
	{  // we're mousing into a sub_layer
		if(open_sub_layer != id && open_sub_layer != "")
			hideLayer(open_sub_layer);
		clearTimeout(tim3);
		showLayer(id);
		showLayer(previousLayer);
		open_sub_layer = id;
	}
	else
	{  // we're just mousing into a regular layer
		if(previousLayer != id && previousLayer != "")
			hideLayer(previousLayer);
		showLayer(id);
		previousLayer = id;
	}
}

function returnDiv(id) {
	if (document.all) // IE
	{
		var div = document.all(id).style;
	}
	else if (document.layers) // NS4
	{
		var div = document.layers[id];
	}
	else if (document.getElementById) // NS6
	{
		var div = document.getElementById(id).style;
	}
	return div;
}

// BEGIN subnav LAYER SCRIPT
// var sections = new Array(4,0); // set the number of sublayers per section
var timeout_time = 100; // set the timeout time

var sub_tim;
var sub_tim2;
var sub_tim3;
// var previousSubLayer = "";
var open_sub_layer = "";

var previousSection = "-1";

function mouseIntoSection(section)
{
	if(sub_tim)
		clearTimeout(sub_tim);

	if(section != previousSection)
	{
		if(previousSection != "-1")
			hideSection(previousSection);
		for(i=0; i<sections[section]; i++)
			showLayer("subnav_" + section + "_" + i);
	}
	previousSection = section;
}

function mouseOutOfSection(section)
{
	func = "hideSection('"+section+"')";
	sub_tim = setTimeout(func, timeout_time);
}

function hideSection(section)
{
	for(i=0; i<sections[section]; i++)
		hideLayer("subnav_" + section + "_" + i);
		
	previousSection = "-1";
}

function mouseOverSubnavLayer(layerID)
{
	if(document.all)
	{
		var div = returnDiv("subnav_" + layerID);
		div.bgColor = "#101084";
		div.backgroundColor = "#101084";
		div.color = "#ffffff";
	}
}

function mouseOutOfSubLayer(layerID)
{
	if (document.all)
	{
		var div = returnDiv("subnav_" + layerID);
		div.bgColor = "#C6C7C6";
		div.backgroundColor = "#C6C7C6";
		div.color = "#000000";
	}
}

//top promos
var layerTopCount;
var currentTopLayer;
var topColumns;
var currentTopColumn;
function countTopLayers(){
		var i=1;
		var layerExists=true;
		while (layerExists)
		{
		layerToCheck='toppromo'+i;
		if (document.getElementById(layerToCheck)) 
		  {
		  i++;
		  } else {
		  layerExists=false;
		  }
		}
		layerTopCount=i-1;
		currentTopColumn=1;
		if (layerTopCount>1){
			topColumns=Math.ceil(layerTopCount / 1);
			currentTopLayer=1;
			var t=setTimeout("flipTopPromos()",4000)
		}
}

function flipTopPromos(){
	if (currentTopColumn == topColumns) {
		j=1;	
		while (j <=1) {
			var toplayertohide='toppromo'+currentTopLayer;
			setObjVis(toplayertohide,'hidden');
			currentTopLayer=currentTopLayer - 1;
			j++;
		}
		currentTopLayer=1;	
		while (currentTopLayer <= 1) {
			var toplayertoshow='toppromo'+currentTopLayer;
			setObjVis(toplayertoshow,'visible');
			currentTopLayer++;
		}
		currentTopLayer=currentTopLayer - 1;
		currentTopColumn=1;		
	} else {
		currentTopLayer++;			
		currentMax = (currentTopColumn * 1) + 1;
		while ((currentTopLayer <= currentMax) && (currentTopLayer <= layerTopCount)) {
			var toplayertohide='toppromo'+ (currentTopLayer-1);
			setObjVis(toplayertohide,'hidden');
			var toplayertoshow='toppromo'+currentTopLayer;
			setObjVis(toplayertoshow,'visible');
			currentTopLayer++;
		}
		currentTopLayer=currentTopLayer - 1;
		currentTopColumn++;
	}
	var t=setTimeout("flipTopPromos()",4000);
}


// Browser Window Size and Position
// copyright Stephen Chapman, 3rd Jan 2005, 8th Dec 2005
// you may copy these functions but please keep the copyright notice as well
function pageWidth() {return window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ?       document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;} function pageHeight() {return  window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ?  document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;} function posLeft() {return typeof window.pageXOffset != 'undefined' ? window.pageXOffset :document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0;} function posTop() {return typeof window.pageYOffset != 'undefined' ?  window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;} function posRight() {return posLeft()+pageWidth();} function posBottom() {return posTop()+pageHeight();}
// end window size

function setObjWidth(objectID,w) {
	var objs = xDOM(objectID,1);
	objs.width = w;
}            

// More Object Functions
// copyright Stephen Chapman, 18th Jan 2005
// you may copy these functions but please keep the copyright notice as well
// begin hide, toggle, move
function setObjVis(objectID,vis) {
	var objs = xDOM(objectID,1);
	objs.visibility = vis;
} 

function toggleObjVis(objectID) {
	var objs = xDOM(objectID,1);
	var vis = objs.visibility;
	objs.visibility = (vis == "visible" || vis == "show") ? 'hidden' : 'visible';
}

function moveObjTo(objectID,x,y) {
	var objs = xDOM(objectID,1);
	objs.left = x;
	objs.top = y;
}

function moveObjBy(objectID,x,y) {
	var obj = xDOM(objectID,0);
	var objs = xDOM(objectID,1);
	if (obj.offsetLeft != null) {
		 var l = obj.offsetLeft;
		 var t = obj.offsetTop;
		 objs.left = l+x; objs.top = t+y;
	} else if (objs.pixelLeft != null) {
		 objs.pixelLeft += x;
		 objs.pixelTop += y;
	} else obj.moveBy(x,y);
}

function moveObjLayer(objectID,z) {
	var objs = xDOM(objectID,1);
	objs.zIndex = z;
}
// end hide, toggle, move

// begin  measurables
// Object Functions
// copyright Stephen Chapman, 4th Jan 2005
//  you may copy these functions but please keep the copyright notice as well
function objWidth(objectID) {
  var obj = xDOM(objectID,0);
  if(obj.offsetWidth) return  obj.offsetWidth;
  if (obj.clip) return obj.clip.width;
  return 0;
}

function objHeight(objectID) {
  var obj = xDOM(objectID,0);
  if(obj.offsetHeight) return  obj.offsetHeight;
  if (obj.clip) return obj.clip.height; return 0;
}    

function objLeft(objectID) {
  var obj = xDOM(objectID,0);
  var objs = xDOM(objectID,1); 
  if(objs.left) return objs.left; 
  if (objs.pixelLeft) return objs.pixelLeft; 
  if (obj.offsetLeft) return obj.offsetLeft; 
  return 0;
} 

function objTop(objectID) {
  var obj = xDOM(objectID,0);
  var objs = xDOM(objectID,1); 
  if(objs.top) return objs.top; 
  if (objs.pixelTop) return objs.pixelTop; 
  if (obj.offsetTop) return obj.offsetTop; 
  return 0;
} 

function objRight(objectID) {
	return objLeft(objectID)+objWidth(objectID);
}

function objBottom(objectID) {
	return objTop(objectID)+objHeight(objectID);
}

function objLayer(objectID) {
  var objs = xDOM(objectID,1); 
  if(objs.zIndex) return objs.zIndex; 
  return 0;
} 

function objVisible(objectID) {
  var objs = xDOM(objectID,1); 
  if(objs.visibility == 'hide' || objs.visibility == 'hidden') return 'hidden';
  return 'visible';
}
// end measurables                    

// Cross Browser DOM
// copyright Stephen Chapman, 4th Jan 2005
// you may copy this code but please keep the copyright notice as well
var aDOM = 0, ieDOM = 0, nsDOM = 0; var stdDOM = document.getElementById;
if (stdDOM) aDOM = 1; else {ieDOM = document.all; if (ieDOM) aDOM = 1; else {
var nsDOM = ((navigator.appName.indexOf('Netscape') != -1)
&& (parseInt(navigator.appVersion) ==4)); if (nsDOM) aDOM = 1;}}
function xDOM(objectId, wS) {
if (stdDOM) return wS ? document.getElementById(objectId).style:
document.getElementById(objectId);
if (ieDOM) return wS ? document.all[objectId].style: document.all[objectId];
if (nsDOM) return document.layers[objectId];
}                  
// end cross browser DOM

var xxx = 0; var yyy = 0;
var endPos = 0;
function start() {
var w = objWidth('myobj');
xxx = 10;
yyy = 10;
endPos = xxx - 100;
moveit();
setObjVis('myobj','visible');
}
function moveit() {
var x = (posLeft()+xxx) + 'px';
var y = (posTop()+yyy) + 'px';
moveObjTo('myobj',x,y);
}

function moveDown(layerToMove) {
moveObjLayer(layerToMove,3);
var endY = sn1StartY + sn1Height;
o = document.getElementById(layerToMove);
y = o.offsetTop;
if (y < endY) {
	y+=2;
	var x = sn1StartX + 'px';
	var y = y + 'px';
	moveObjTo(layerToMove,x,y);
	moveagain = layerToMove;
	setTimeout('moveDown(moveagain)',5);}
}

function moveUp(layerToMove) {
var endY = sn1StartY;
o = document.getElementById(layerToMove);
y = o.offsetTop;
if (y > endY) {
	y-=5;
	var x = sn1StartX + 'px';
	var y = y + 'px';
	moveObjTo(layerToMove,x,y);
	moveagain = layerToMove;
	setTimeout('moveUp(moveagain)',5);}
}

function collapse(id)
{
	moveObjLayer(id,1);
	func = "moveUp('"+id+"')";
	tim = setTimeout(func, 500);
}

function stopHide () {
	clearTimeout(tim);
}

var sn1StartX = 0;
var sn1StartY = 16;
var sn1Height = 20;

	

	