/*--------------------------------------------------------------------------
/ Copyright (c) 2007 SilkSystem Solutions, All Rights Reserved
/
/ 20070701	CH	Initial Version
/
/ This js file has many of the global js functions used throughout the app
/ As well it holds global js variables for behavior control
/
/--------------------------------------------------------------------------*/

//global variables
// change the following based on production or dev pathway
var rootURL 	= "http://www.iRibbit.com"
//var rootURL 	= "http://www.iRibbit.com/_dev"

//create a cookie with a name value pair
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

//read a variable from the cookie
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

//kill the cookie with a past date
function eraseCookie(name) {
	createCookie(name,"",-1000);
}

function goMyEbay() {
	document.location.href = rootURL + "/index.asp";
}

//validation functions
function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}