function getWebguiProperty (propName) {
	var props = new Array();
	props["extrasURL"] = "http://files7.atomiclearning.com/extras";
	props["pageURL"] = "/home";
	return props[propName];
}

var ie5=document.all&&document.getElementById;
var contextMenu_items = new Array();

if (contextMenu_old == undefined)
{
  var contextMenu_old = (document.onclick) ? document.onclick : function () {};
  document.onclick= function () {contextMenu_old();contextMenu_hide();};
}

function contextMenu_renderLeftClick(menuId,e) {
	contextMenu_hide(e);
	contextMenu_show(menuId,e);
	e.cancelBubble=true;
	e.returnValue=false;
	return false;
} 


function contextMenu_show(menuId,e){
	var menuobj=document.getElementById(menuId);
	var posx = 0;
	var posy = 0;
	var yoffset = 0;
	var xoffset = 0;
    var firedobj = ie5 ? e.srcElement : e.target;
    while (firedobj!=null && firedobj.tagName!="HTML")
    {
        //this is a hack, need to revisit
        if (firedobj.tagName == "DIV") {
            xoffset+=firedobj.offsetLeft;
            yoffset+=firedobj.offsetTop;
        }
        firedobj=firedobj.offsetParent;
   }
    var el = document.documentElement;
    posx = e.clientX - xoffset + (ie5? el.scrollLeft : window.pageXOffset);
    posy = e.clientY - yoffset + (ie5? el.scrollTop : window.pageYOffset);
	menuobj.style.left=posx;
	menuobj.style.top=posy;
    menuobj.style.visibility="visible";
	return false;
}

function contextMenu_hide(){
	for (i=0;i<contextMenu_items.length;i++) {
		document.getElementById("contextMenu_"+contextMenu_items[i]+"_menu").style.visibility="hidden";
	}
	return false;
}

function contextMenu_createWithImage(imagePath, id, name){
	contextMenu_items.push(id);
	this.id = id;
	this.name = name;
	this.type = "image";
	this.imagePath=imagePath;
	this.linkLabels = new Array();
	this.linkUrls = new Array();
	this.draw = contextMenu_draw;
	this.print = contextMenu_print;
	this.addLink = contextMenu_addLink;
}

function contextMenu_createWithLink(id, name){
	contextMenu_items.push(id);
	this.id = id;
	this.name = name;
	this.type = "link";
	this.linkLabels = new Array();
	this.linkUrls = new Array();
	this.draw = contextMenu_draw;
	this.print = contextMenu_print;
	this.addLink = contextMenu_addLink;
}

function contextMenu_draw(){
	var output = "";
	output += '<div id="contextMenu_' + this.id + '_menu" class="contextMenu_skin">';
	for (i=0;i<this.linkUrls.length;i++) {
		output += "<a href=\"" + this.linkUrls[i] + "\">" + this.linkLabels[i] + "</a><br />";
	}
	output += '</div>';
	if (this.type == "image") {
		output += '<img src="' + this.imagePath + '" id="contextMenu_' + this.id + '" onclick="return contextMenu_renderLeftClick(\'contextMenu_' + this.id + '_menu\',event)" alt="' + this.name + '" title="' + this.name + '" align="absmiddle" />';
	} else {
		output += '<a href="#" id="contextMenu_' + this.id + '" onclick="return contextMenu_renderLeftClick(\'contextMenu_' + this.id + '_menu\',event)">' + this.name + '</a>';
		//output += '<a href="javascript:contextMenu_renderLeftClick(\'contextMenu_' + this.id + '_menu\',event)" id="contextMenu_' + this.id + '">' + this.name + '</a>';
	}
	return output;
}

function contextMenu_print(){
	document.write(this.draw());
}

function contextMenu_addLink(linkUrl,linkLabel){
	this.linkUrls.push(linkUrl);
	this.linkLabels.push(linkLabel);
}

function clearText(thefield){
if (thefield.defaultValue==thefield.value)
thefield.value = "";
}


function setCookie(name, value, expires, path, domain, secure)
{
    domain = ".atomiclearning.com";
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

function get_cookie ( cookie_name )
{
  var results = document.cookie.match ( cookie_name + '=(.*?)(;|$)' );

  if ( results )
    return ( unescape ( results[1] ) );
  else
    return null;
}



// DOM Rollovers

function imageholderclass(){
	this.over=new Array();
	this.down=new Array();
	this.src=new Array();
	this.store=store;
	
	function store(src, down, over)
    {
		var AL=this.src.length;
        
        /* null values cause empty calls back to the server */
        //alert("storing " + src);
        //alert("over: " + over);
        //alert("down: " + down);
        
		this.src[AL]=new Image();
        if(src)
            this.src[AL].src=src;
            
		this.over[AL]=new Image();
        if(over)
            this.over[AL].src=over;
            
		this.down[AL]=new Image();
        if(down)
            this.down[AL].src=down;
	}
}

var ih = new imageholderclass();
var mouseisdown=0;

function preloader(t)
{
	for(i=0;i<t.length;i++){
		if(t[i].getAttribute('srcover')||t[i].getAttribute('srcdown')){
			
			storeimages(t[i]);
			var checker='';
			checker=(t[i].getAttribute('srcover'))?checker+'A':checker+'';
			checker=(t[i].getAttribute('srcdown'))?checker+'B':checker+'';
			
			switch(checker){
			case 'A' : mouseover(t[i]);mouseout(t[i]); break;
			case 'B' : mousedown(t[i]); mouseup2(t[i]); break;
			case 'AB' : mouseover(t[i]);mouseout(t[i]); mousedown(t[i]); mouseup(t[i]); break;
			default : return;			
			}
			
			if(t[i].src){t[i].setAttribute("oldsrc",t[i].src);}
		}
	}
}
function mouseup(t){
	var newmouseup;
	if(t.onmouseup){
		t.oldmouseup=t.onmouseup;
		newmouseup=function(){mouseisdown=0;this.src=this.getAttribute("srcover");this.oldmouseup();};

	}
	else{newmouseup=function(){mouseisdown=0;this.src=this.getAttribute("srcover");};}
	t.onmouseup=newmouseup;
}

function mouseup2(t){
	var newmouseup;
	if(t.onmouseup){
		t.oldmouseup=t.onmouseup;
		newmouseup=function(){mouseisdown=0;this.src=this.getAttribute("oldsrc");this.oldmouseup();};
		}
	else{newmouseup=function(){mouseisdown=0;this.src=this.getAttribute("oldsrc");};}
	t.onmouseup = newmouseup;
}

function mousedown(t){
	var newmousedown;
	if(t.onmousedown){
		t.oldmousedown=t.onmousedown;
		newmousedown=function(){if(mouseisdown==0){this.src=this.getAttribute("srcdown");this.oldmousedown();}};
	}
	else{newmousedown=function(){if(mouseisdown==0){this.src=this.getAttribute("srcdown");}};}
	t.onmousedown=newmousedown;
}

function mouseover(t){
	var newmouseover;
	if(t.onmouseover){
		t.oldmouseover=t.onmouseover;
		newmouseover=function(){this.src=this.getAttribute("srcover");this.oldmouseover();};
	}
	else{newmouseover=function(){this.src=this.getAttribute("srcover");};}
	t.onmouseover=newmouseover;
}

function mouseout(t){
	var newmouseout;
	if(t.onmouseout){
		t.oldmouseout=t.onmouseout;
		newmouseout=function(){this.src=this.getAttribute("oldsrc");this.oldmouseout();};
	}
	else{newmouseout=function(){this.src=this.getAttribute("oldsrc");};}
	t.onmouseout=newmouseout;
}

function storeimages(t){
	var s=(t.getAttribute('src'))?t.getAttribute('src'):'';
	var d=(t.getAttribute('srcdown'))?t.getAttribute('srcdown'):'';
	var o=(t.getAttribute('srcover'))?t.getAttribute('srcover'):'';
	ih.store(s,d,o);
}

function preloadimgsrc(){
	if(!document.getElementById) return;
	var it=document.getElementsByTagName('IMG');
	var it2=document.getElementsByTagName('INPUT');
	preloader(it);
	preloader(it2);
}

if(window.addEventListener)
{
    window.addEventListener("load", preloadimgsrc, false);
} 
else
{
	if(window.attachEvent)
    {
        window.attachEvent("onload", preloadimgsrc);
    }
	else if (document.getElementById)
    {
        window.onload=preloadimgsrc;
    }
}


/* mouseover magic for /home imgs  ... ugly. CSS rollovers would be nicer. */
var preloadFlag = true;

CSInit = new Array;
function CSScriptInit() {
if(typeof(skipPage) != "undefined") { if(skipPage) return; }
idxArray = new Array;
for(var i=0;i<CSInit.length;i++)
	idxArray[i] = i;
CSAction2(CSInit, idxArray);
}
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}
function changeImagesArray(array) {
	if (preloadFlag == true) {
		var d = document; var img;
		for (var i=0; i<array.length; i+=2) {
			img = null; var n = array[i];
			if (d.images) {img = d.images[n];}
			if (!img && d.getElementById) {img = d.getElementById(n);}
			if (img) {img.src = array[i+1];}
		}
	}
}
function changeImages() {
	changeImagesArray(changeImages.arguments);
}
CSStopExecution=false;
function CSAction(array) {return CSAction2(CSAct, array);}
function CSAction2(fct, array) { 
	var result;
	for (var i=0;i<array.length;i++) {
		if(CSStopExecution) return false; 
		var aa = fct[array[i]];
		if (aa == null) return false;
		var ta = new Array;
		for(var j=1;j<aa.length;j++) {
			if((aa[j]!=null)&&(typeof(aa[j])=="object")&&(aa[j].length==2)){
				if(aa[j][0]=="VAR"){ta[j]=CSStateArray[aa[j][1]];}
				else{if(aa[j][0]=="ACT"){ta[j]=CSAction(new Array(new String(aa[j][1])));}
				else ta[j]=aa[j];}
			} else ta[j]=aa[j];
		}			
		result=aa[0](ta);
	}
	return result;
}
CSAct = new Object;
// Version 1.1. A Michael Ahgren action.
function CSRemoveIEbox(){
if (document.images&&navigator.userAgent.indexOf("MSIE")!=-1){
	for(i=0;i<document.links.length;i++){
		target=eval("document.links[i]")
		target.onfocus=blurHandler
		}
	}
}
function blurHandler(){
obj=window.event.srcElement
if(obj.tagName == "A"||obj.tagName=="AREA") obj.blur()
}


function irritating_popup_window( url, name )
{
    var popup = window.open( url, name, 'width=450, height=500' );
    return false;   // so href doesn't follow
}
