/* ----------------------------- BROWSER SNIFFING VARS ----------------------------- */

var agt      = navigator.userAgent.toLowerCase();
var appVer   = navigator.appVersion.toLowerCase();
var is_minor = parseFloat(appVer);
var is_major = parseInt(is_minor);
var is_opera = (agt.indexOf("opera") != -1);
var is_safari = ((agt.indexOf('safari')!=-1)&&(agt.indexOf('mac')!=-1))?true:false;
var iePos  = appVer.indexOf('msie');
if (iePos !=-1) {
	is_minor = parseFloat(appVer.substring(iePos+5,appVer.indexOf(';',iePos)))
	is_major = parseInt(is_minor);
}
var is_ie   = (iePos!=-1);
var is_ie5   = (is_ie && is_major == 5);
var is_win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
var is_mac    = (agt.indexOf("mac")!=-1);
var is_ie5up = (is_ie && is_minor >= 5);


////Common Functions///////////////////////////////////////////////////////////////////

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); if(x){return x;}else{return false;};
}

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 MM_showHideLayers() { //v3.0
var i,p,v,obj,args=MM_showHideLayers.arguments;
for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
obj.visibility=v; }
}

function MM_displayLayers() { //v3.0
	var i,p,v,obj,args=MM_displayLayers.arguments;
	for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
	if (obj.style) { obj=obj.style; v=(v=='show')?'block':(v='hide')?'none':v; }
	obj.display=v; }
}


////use this for the dynamic popup layer///
function popup_Show(i,x){
	//getTellaFriendPosition(i,x); //lets set the position of the element
	popup_Position(i,x);
	MM_displayLayers(i,'','show'); //turn it on...

}

function popup_Hide(i){
	MM_displayLayers(i,'','hide'); //turn it on...
}

function popup_Position(i,y){
	obj=MM_findObj(y);
	popupobj=MM_findObj(i);
	//popupfixedlayer=MM_findObj(linkobj);
	//get popup objects location
	//ypopup=findPosY(popupfixedlayer);

	if(document.all){
		c = 9;
	}else{
		c = 0;
	}


	x = findPosX(obj) + 30;
	y = findPosY(obj) - 55;

	popupobj.style.top = y+'px' ;
	popupobj.style.left = x+'px';
}

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function getPosition(i){
	obj=MM_findObj(i);
	popupobj=MM_findObj('popup');

	x = findPosX(obj);
	y = findPosY(obj) - 115;


	popupobj.style.top = y+'px';
	popupobj.style.left = x+'px';


	MM_showHideLayers('popup','','show');

}


/*
	************************************************************************************
	        PRICE CHECK FUNCTIONS use this for the dynamic popup layer
    ************************************************************************************
 */
////use this for the dynamic popup layer///
function price_Show(i,x){
	//getTellaFriendPosition(i,x); //lets set the position of the element
	price_Position(i,x);
	MM_displayLayers(i,'','show'); //turn it on...

}

function price_Hide(i){
	MM_displayLayers(i,'','hide'); //turn it on...
}

function price_Position(i,y){
	obj=MM_findObj(y);
	popupobj=MM_findObj(i);

	if(document.all){
		c = 9;
	}else{
		c = 0;
	}


	x = findPosX(obj) + 130;
	y = findPosY(obj) - 155;

	popupobj.style.top = y+'px' ;
	popupobj.style.left = x+'px';
}

/////////////////////////////////////////////////////////////////////


function popup(link) {
    if (document.all)
        var xMax = screen.width, yMax = screen.height;
    else
        if (document.layers)
            var xMax = window.outerWidth, yMax = window.outerHeight;
        else
            var xMax = 640, yMax=480;

    var xOffset = (xMax - 600)/2, yOffset = (yMax - 400)/2;

    windowHandle = window.open(link,'','top='+yOffset+',left='+xOffset+',toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=800,height=600');
}

function win_popup(link,width,height) {
    if (document.all)
        var xMax = screen.width, yMax = screen.height;
    else
        if (document.layers)
            var xMax = window.outerWidth, yMax = window.outerHeight;
        else
            var xMax = 640, yMax=480;

    var xOffset = (xMax - width)/2, yOffset = (yMax - height)/2;

    windowHandle = window.open(link,'','top='+yOffset+',left='+xOffset+',toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width='+width+',height='+height);
}


/////////////////////////////////////////////////////////////////////////////////////

//Custom Functions for SchoolSoup////////////////////////////////////////////////////

var disableClick = true;

function change(id, newClass) {
	for(i=1;i<=4;i++){
		document.getElementById('layer'+i).className="bodycontentoff";
	}
	document.getElementById('layer'+id).className = newClass;
}
var timer;

function moveLayer(id, activelayer){



	 /* Height of section (i.e. how much tabs must slide up or down) */
	 	/* mainheight = 215; */
	 	mainheight = 215;

	/* NUMBER OF TABS */
		tabnumber = 5;

	if(activelayer || disableClick){

		if(isEmpty(activelayer)){//lets find the active layer; the one that will be getting smaller
			for(i=1;i<=tabnumber;i++){
				layer = MM_findObj('layer'+i);
				layer = layer.offsetHeight;
				if(layer > 0){
					activelayer = i;
					break;
				}
			}

			if(activelayer != id){
				newlayer=document.getElementById('layer'+id);
				newlayertxt = document.getElementById('navbartxt'+id);
				oldlayer = document.getElementById('layer'+activelayer);
				oldlayertxt = document.getElementById('navbartxt'+activelayer);
				MM_swapImgRestore() //resets all the images//
				MM_swapImage('navbararrow1','','/images/hm_bar-bg-arrow.gif',1); // hard reset for this image because its default is on...  I need it off//
				MM_swapImage('navbararrow'+id,'','/images/hm_bar-bg-arrowon.gif',1);
				newlayertxt.style.color = '#fff';
				oldlayertxt.style.color = '#054589';
			}else{
				return;	 //exits the function prematurely...
			}
		}



		if(oldlayer.offsetHeight > 0 || newlayer.offsetHeight < mainheight){
			movelayer = oldlayer.offsetHeight * .2;
			movelayer = parseInt(Math.round(movelayer));
			if(movelayer == 0 && oldlayer.style.height != 0){  //fixes rounding issues...
				movelayer = 1;
			}

			oldlayer.style.height =  (parseInt(oldlayer.offsetHeight) - movelayer)+'px';
			newlayer.style.height =  (parseInt(newlayer.offsetHeight) + movelayer)+'px';
		}

		if(newlayer.offsetHeight < mainheight){
			timer = setTimeout('moveLayer('+id+','+activelayer+')', 10);
			disableClick = false;

		}else{
			clearTimeout(timer);
			disableClick = true;
		}
	}
}


function movelayerie55(id){
	for(i=1;i<=4;i++){
		layer=document.getElementById('layer'+i);
		layer.style.display = 'none';
		layer.style.height = '0px';
	}

	newlayer=document.getElementById('layer'+id);
	newlayer.style.display = 'block';
	newlayer.style.height = '237px';

}

function isEmpty(input) {
	return (input==null || input =="")
}

////////Check List for IE/////////////////
/*-----------------------------------------------------------+
| addLoadEvent: Add event handler to body when window loads |
+-----------------------------------------------------------*/
function addLoadEvent(func) {
	var oldonload = window.onload;

	if (typeof window.onload != "function") {
		window.onload = func;
	} else {
		window.onload = function () {
			oldonload();
			func();
		}
	}
}

/*------------------------------------+
| Functions to run when window loads |
+------------------------------------*/
addLoadEvent(function () {
	initChecklist('checklist');
	if(is_ie5up){
		buttonhover();
	}
});

/*----------------------------------------------------------+
| initChecklist: Add :hover functionality on labels for IE |
+----------------------------------------------------------*/
function initChecklist(x) {
	if (document.all && document.getElementById) {
		// Get all unordered lists
		var lists = document.getElementsByTagName("ul");

		for (i = 0; i < lists.length; i++) {
			var theList = lists[i];

			// Only work with those having the class "checklist"
			//if (theList.className.indexOf("checklist") > -1) {
			if (theList.className.indexOf(x) > -1) {
				var labels = theList.getElementsByTagName("label");

				// Assign event handlers to labels within
				for (var j = 0; j < labels.length; j++) {
					var theLabel = labels[j];
					theLabel.onmouseover = function() { this.className += " hover"; };
					theLabel.onmouseout = function() { this.className = this.className.replace(" hover", ""); };
				}
			}
		}
	}
}

/* ----------------------------- ID HOVER PSEUDO CLASS FIXES ----------------------------- */

/*

Since PC IE versions 6 and below don't support the CSS :hover pseudo class on any element

but <a> we use these functions to apply onMouseOver and onMouseOut to the elements

*/

// mouse overs for form buttons

function buttonhover() {
	for(i=0; i<document.forms.length; i++){
		for(j=0; j<document.forms[i].elements.length; j++){
			if(document.forms[i].elements[j].className == 'button'){
				button = document.forms[i].elements[j];
				button.onmouseover = function() { this.className = 'buttonover'; }
				button.onmouseout  = function() { this.className = 'button'; }
			}
		}
	}
}

function validateZip(form) {
	if (form.zip) {
		if (form.zip.value != "") {
			return true;
		} else {
			alert("Please Enter Your Zip Code");
			form.zip.focus();
			return false;
		}
	}
}


/*------------------- IS NUMERIC for text form feilds-------------------------------*/
//how to use: onkeypress="return numbersonly(this, event)"
function numbersonly(myfield, e, dec){
	var key;
	var keychar;

	if (window.event){
		key = window.event.keyCode;
	}else if (e){
		key = e.which;
	}else{
		return true;
	}

	keychar = String.fromCharCode(key);

	// control keys
	if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27) ){
		return true;
	}else if ((("0123456789").indexOf(keychar) > -1)) {// numbers
		return true;
	}else if (dec && (keychar == ".")) {  // decimal point jump
		myfield.form.elements[dec].focus();
		return false;
	}else{
		return false;
	}
}


/* FLASH JS FILE */

/**
 * SWFObject v1.4: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2006 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * **SWFObject is the SWF embed script formarly known as FlashObject. The name was changed for
 *   legal reasons.
 */

function hello()
{
	alert('hello');
}





if(typeof deconcept == "undefined") var deconcept = new Object();
if(typeof deconcept.util == "undefined") deconcept.util = new Object();
if(typeof deconcept.SWFObjectUtil == "undefined") deconcept.SWFObjectUtil = new Object();
deconcept.SWFObject = function(swf, id, w, h, ver, c, useExpressInstall, quality, xiRedirectUrl, redirectUrl, detectKey){
	if (!document.createElement || !document.getElementById) { return; }
	this.DETECT_KEY = detectKey ? detectKey : 'detectflash';
	this.skipDetect = deconcept.util.getRequestParameter(this.DETECT_KEY);
	this.params = new Object();
	this.variables = new Object();
	this.attributes = new Array();
	if(swf) { this.setAttribute('swf', swf); }
	if(id) { this.setAttribute('id', id); }
	if(w) { this.setAttribute('width', w); }
	if(h) { this.setAttribute('height', h); }
	if(ver) { this.setAttribute('version', new deconcept.PlayerVersion(ver.toString().split("."))); }
	this.installedVer = deconcept.SWFObjectUtil.getPlayerVersion(this.getAttribute('version'), useExpressInstall);
	if(c) { this.addParam('bgcolor', c); }
	var q = quality ? quality : 'high';
	this.addParam('quality', q);
	this.setAttribute('useExpressInstall', useExpressInstall);
	this.setAttribute('doExpressInstall', false);
	var xir = (xiRedirectUrl) ? xiRedirectUrl : window.location;
	this.setAttribute('xiRedirectUrl', xir);
	this.setAttribute('redirectUrl', '');
	if(redirectUrl) { this.setAttribute('redirectUrl', redirectUrl); }
}
deconcept.SWFObject.prototype = {
	setAttribute: function(name, value){
		this.attributes[name] = value;
	},
	getAttribute: function(name){
		return this.attributes[name];
	},
	addParam: function(name, value){
		this.params[name] = value;
	},
	getParams: function(){
		return this.params;
	},
	addVariable: function(name, value){
		this.variables[name] = value;
	},
	getVariable: function(name){
		return this.variables[name];
	},
	getVariables: function(){
		return this.variables;
	},
	getVariablePairs: function(){
		var variablePairs = new Array();
		var key;
		var variables = this.getVariables();
		for(key in variables){
			variablePairs.push(key +"="+ variables[key]);
		}
		return variablePairs;
	},
	getSWFHTML: function() {
		var swfNode = "";
		if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { // netscape plugin architecture
			if (this.getAttribute("doExpressInstall")) this.addVariable("MMplayerType", "PlugIn");
			swfNode = '<embed type="application/x-shockwave-flash" src="'+ this.getAttribute('swf') +'" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'"';
			swfNode += ' id="'+ this.getAttribute('id') +'" name="'+ this.getAttribute('id') +'" ';
			var params = this.getParams();
			 for(var key in params){ swfNode += [key] +'="'+ params[key] +'" '; }
			var pairs = this.getVariablePairs().join("&");
			 if (pairs.length > 0){ swfNode += 'flashvars="'+ pairs +'"'; }
			swfNode += '/>';
		} else { // PC IE
			if (this.getAttribute("doExpressInstall")) this.addVariable("MMplayerType", "ActiveX");
			swfNode = '<object id="'+ this.getAttribute('id') +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'">';
			swfNode += '<param name="movie" value="'+ this.getAttribute('swf') +'" />';
			var params = this.getParams();
			for(var key in params) {
			 swfNode += '<param name="'+ key +'" value="'+ params[key] +'" />';
			}
			var pairs = this.getVariablePairs().join("&");
			if(pairs.length > 0) {swfNode += '<param name="flashvars" value="'+ pairs +'" />';}
			swfNode += "</object>";
		}
		return swfNode;
	},
	write: function(elementId){
		if(this.getAttribute('useExpressInstall')) {
			// check to see if we need to do an express install
			var expressInstallReqVer = new deconcept.PlayerVersion([6,0,65]);
			if (this.installedVer.versionIsValid(expressInstallReqVer) && !this.installedVer.versionIsValid(this.getAttribute('version'))) {
				this.setAttribute('doExpressInstall', true);
				this.addVariable("MMredirectURL", escape(this.getAttribute('xiRedirectUrl')));
				document.title = document.title.slice(0, 47) + " - Flash Player Installation";
				this.addVariable("MMdoctitle", document.title);
			}
		}
		if(this.skipDetect || this.getAttribute('doExpressInstall') || this.installedVer.versionIsValid(this.getAttribute('version'))){
			var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId;
			n.innerHTML = this.getSWFHTML();
			return true;
		}else{
			if(this.getAttribute('redirectUrl') != "") {
				document.location.replace(this.getAttribute('redirectUrl'));
			}
		}
		return false;
	}
}

/* ---- detection functions ---- */
deconcept.SWFObjectUtil.getPlayerVersion = function(reqVer, xiInstall){
	var PlayerVersion = new deconcept.PlayerVersion([0,0,0]);
	if(navigator.plugins && navigator.mimeTypes.length){
		var x = navigator.plugins["Shockwave Flash"];
		if(x && x.description) {
			PlayerVersion = new deconcept.PlayerVersion(x.description.replace(/([a-z]|[A-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
		}
	}else{
		try{
			var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			for (var i=3; axo!=null; i++) {
				axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+i);
				PlayerVersion = new deconcept.PlayerVersion([i,0,0]);
			}
		}catch(e){}
		if (reqVer && PlayerVersion.major > reqVer.major) return PlayerVersion; // version is ok, skip minor detection
		// this only does the minor rev lookup if the user's major version
		// is not 6 or we are checking for a specific minor or revision number
		// see http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
		if (!reqVer || ((reqVer.minor != 0 || reqVer.rev != 0) && PlayerVersion.major == reqVer.major) || PlayerVersion.major != 6 || xiInstall) {
			try{
				PlayerVersion = new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
			}catch(e){}
		}
	}
	return PlayerVersion;
}
deconcept.PlayerVersion = function(arrVersion){
	this.major = parseInt(arrVersion[0]) != null ? parseInt(arrVersion[0]) : 0;
	this.minor = parseInt(arrVersion[1]) || 0;
	this.rev = parseInt(arrVersion[2]) || 0;
}
deconcept.PlayerVersion.prototype.versionIsValid = function(fv){
	if(this.major < fv.major) return false;
	if(this.major > fv.major) return true;
	if(this.minor < fv.minor) return false;
	if(this.minor > fv.minor) return true;
	if(this.rev < fv.rev) return false;
	return true;
}
/* ---- get value of query string param ---- */
deconcept.util = {
	getRequestParameter: function(param){
		var q = document.location.search || document.location.hash;
		if(q){
			var startIndex = q.indexOf(param +"=");
			var endIndex = (q.indexOf("&", startIndex) > -1) ? q.indexOf("&", startIndex) : q.length;
			if (q.length > 1 && startIndex > -1) {
				return q.substring(q.indexOf("=", startIndex)+1, endIndex);
			}
		}
		return "";
	}
}

/* add Array.push if needed (ie5) */
if (Array.prototype.push == null) { Array.prototype.push = function(item) { this[this.length] = item; return this.length; }}

/* add some aliases for ease of use/backwards compatibility */
var getQueryParamValue = deconcept.util.getRequestParameter;
var FlashObject = deconcept.SWFObject; // for legacy support
var SWFObject = deconcept.SWFObject;