/*
Author: Michele
Date: 09/10/2004 
Description: Cookie Mix
*/



/* Function: popWindow
 * -------------------
 * Generic popup window function, can be called from pretty much anywhere.
 * opens a popup window with passed in url, height, width, and name.  The
 * popup window should open centered on the computer screen.
 *
 */

function popSmmWindow(url, name, width, height) {
	var x = (screen.width - width)/2;
	var y = (screen.height - height)/2;
	var opts = 'height=' + height + ',width=' + width + ",screenX=" + x + ",left=" + x + ",screenY=" + y + ",top=" + y + ',location=no,scrollbars=yes,menubar=no,resizable=no,status=no,toolbar=no';
	//var opts = "height=" + height + ",width=" + width + ",scrollbars=yes,menubar=no,resizable=yes,status=no,toolbar=no";
	_nw = window.open(url, name, opts);
	_nw.focus();

}



function GetCookie(Name) {
	var search = Name + "="
  	var returnvalue = "";
  	if (document.cookie.length > 0) {
    	offset = document.cookie.indexOf(search);
    	if (offset != -1) { // if the cookie exists
      		offset += search.length;
      		end = document.cookie.indexOf(";", offset); // set the index of beginning value
      		if (end == -1) {// set the index of the end of cookie value
        		end = document.cookie.length;
      			returnvalue=unescape(document.cookie.substring(offset, end));
    		}
  		}
  		return returnvalue;
  	}
}

function SetCookie (name, value) {
  	var argv = SetCookie.arguments;
  	var argc = SetCookie.arguments.length;
 	var expires = (argc > 2) ? argv[2] : null;
 	var domain = (argc > 3) ? argv[3] : null;
  	var path = (argc > 4) ? argv[4] : null;
  	var delay = (argc > 5) ? argv[5] : null;
	var secure = (argc > 6) ? argv[6] : false;
   	document.cookie = name + "=" + escape (value) +
  	((expires == null) ? "" : ("; expires=" + expires)) +
	((domain == null) ? "" : ("; domain=" + domain)) +
	((path == null) ? "" : ("; path=" + path)) +
   	((delay == null) ? "" : ("; delay=" + delay)) +
    ((secure == true) ? "; secure" : "");
}

function DeleteCookie (name) {
	var exp = new Date();
	exp.setTime (exp.getTime() - 1);
	var cval = GetCookie (name);
	document.cookie = name + "=" + cval + "; expires=" + exp.setTime (exp.getTime() - 1);
}

function SimpleCookie (cookieName, cookieValue, expires_in_minutes,thisdomain,path) {
  	var expDate = new Date();
  	expDate.setTime( expDate.getTime() + (expires_in_minutes * 60 * 1000*24*60) );
  	SetCookie(cookieName,cookieValue,expDate.toGMTString(),thisdomain,path);
}


function img_act(imgName) {
if (document.images) {
       	document.images[imgName].src = eval(imgName + "on.src");
}
}
    
function img_inact(imgName) {
if (document.images) {
        document.images[imgName].src = eval(imgName + "off.src");
}
}


/*
Author: Michele
Date: 07/29/2004 
Description: new window
*/
function NewWindow(mypage,myname,w,h,pos,infocus){
	if(pos=="random"){myleft=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;mytop=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
	if(pos=="center"){myleft=(screen.width)?(screen.width-w)/2:100;mytop=(screen.height)?(screen.height-h)/2:100;}
	else if((pos!='center' && pos!="random") || pos==null){myleft=0;mytop=20}
	settings="width=" + w + ",height=" + h + ",top=" + mytop + ",left=" + myleft + ",scrollbars=yes,location=yes,directories=yes,status=yes,menubar=yes,toolbar=yes,resizable=yes";win=window.open(mypage,myname,settings);
	win.focus();
}

function NewWindow1(mypage,myname,w,h,pos,infocus){
	if(pos=="random"){myleft=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;mytop=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
	if(pos=="center"){myleft=(screen.width)?(screen.width-w)/2:100;mytop=(screen.height)?(screen.height-h)/2:100;}
	else if((pos!='center' && pos!="random") || pos==null){myleft=0;mytop=20}
	settings="width=" + w + ",height=" + h + ",top=" + mytop + ",left=" + myleft + ",scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes";win=window.open(mypage,myname,settings);
	win.focus();
}

function launchWin(urlPath, winName, params) {
	winName = window.open (urlPath,winName,params);
	winName.focus();
}


/*
Author: Michele
Date: 02/08/2005 
Description: show hide divs
*/
function showDiv(layer) {
  	elem = document.getElementById(layer);
  	elem.style.display = "block"; 
}
function hideDiv(layer) {
  	elem = document.getElementById(layer);
  	elem.style.display = "none";  	
}
function hideparentDiv(layer) {
  	elem = parent.document.getElementById(layer);
  	elem.style.display = "none";  	
}
function showRow(rowid) {
  	elem = document.getElementById(rowid);
  	if (elem.style.display == 'none') {
	  	elem.style.display = "table-row"; 
	} else {
	  	elem.style.display = "none"; 
	}
}
function hideRow(rowid) {
  	elem = document.getElementById(rowid);
  	elem.style.display = "none"; 
}

/*
Author: Michele
Date: 02/23/2005 
Description: remove email
*/
var effaced=0;

function efface (elem) {
	if (effaced == 1){
		elem.value='';
	}
	if (effaced > 0) {
		effaced=1;
	} else {
		effaced=effaced+1;
	}
}


function cliff(){
var popurl="games/cliffie/cliffie.htm"
winpops=window.open(popurl,"","width=670,height=405,top=100,left=100,")
}

function bap(){
var popurl="nemesis.html"
winpops=window.open(popurl,"","width=640,height=450,top=100,left=100,")
}


 //FORMS/AUTOTAB: Auto Tab with phone numbers
 /////////////////////////////////////////
 var isNN = (navigator.appName.indexOf("Netscape")!=-1);
 function autoTab(input,len, e) {
 var keyCode = (isNN) ? e.which : e.keyCode;
 var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
 if(input.value.length >= len && !containsElement(filter,keyCode)) {
 input.value = input.value.slice(0, len);
 input.form[(getIndex(input)+1) % input.form.length].focus();
 }
 function containsElement(arr, ele) {
 var found = false, index = 0;
 while(!found && index < arr.length)
 if(arr[index] == ele)
 found = true;
 else
 index++;
 return found;
 }
 function getIndex(input) {
 var index = -1, i = 0, found = false;
 while (i < input.form.length && index == -1)
 if (input.form[i] == input)index = i;
 else i++;
 return index;
 }
 return true;
}