function SetCookie (name, value) {
	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	var path = (argc > 3) ? argv[3] : null;
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;
	document.cookie = name + "=" + escape (value) +
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
	((path == null) ? "" : ("; path=" + path)) +
	((domain == null) ? "" : ("; domain=" + domain)) +
	((secure == true) ? "; secure" : "");
}




function DeleteCookie (name) {
	var argv = DeleteCookie.arguments;
	var argc = DeleteCookie.arguments.length;
	var path = (argc > 1) ? argv[3] : null;
	var domain = (argc > 2) ? argv[4] : null;
	var cval = GetCookie(name);
	var exp = new Date();
	exp.setTime (exp.getTime() - 100);

	document.cookie =	name + "=" + cval + 
		"; expires=" + exp.toGMTString() +
		((path == null) ? "; path=/" : ("; path=" + path)) +
		((domain == null) ? "; domain=.palmOne.com" : ("; domain=" + domain));
}




function getCookieVal(offset) {
   var endstr = document.cookie.indexOf (";", offset);
   if (endstr == -1) endstr = document.cookie.length;
   return unescape (document.cookie.substring(offset, endstr));
}




function GetCookie(name) {
   var arg = name+"=";
   var alen = arg.length;
   var clen = document.cookie.length;
   var i = 0;
   while (i < clen) {
      var j = i + alen;
      if (document.cookie.substring(i, j) == arg) return getCookieVal(j);
      i = document.cookie.indexOf(" ", i) + 1;
      if (i == 0) break;
   }
   return null;
}



// grabs a URI param and appends it to an href link in an html page
function addQueryParam(paramName, linkId) {
	if(GetCookie(paramName)) {
		var oLink		= document.getElementById(linkId);
		var currHref	= oLink.href;

		var delim		= '';
		if(parseQueryString(currHref)) { delim = '&'; } else { delim = '?'; }
		oLink.href		= currHref + delim + paramName + "=" + GetCookie(paramName);
	}
}




// parse the query string for any attributes
function parseQueryString (str) {
	str = str ? str : location.search;
	var queryLocation = str.indexOf("?");
	var query = str.charAt(queryLocation) == '?' ? str.substring(queryLocation + 1) : str;
	var args = new Object();

	if(query && queryLocation != -1) {
		var fields = query.split('&');
		for(var f = 0; f < fields.length; f++) {
			var field = fields[f].split('=');
			args[unescape(field[0].replace(/\+/g, ' '))] = unescape(field[1].replace(/\+/g, ' '));
		}
	} else {
		args = '';
	}

	return args;
}


//function for opening URLs in a parent window from a child popup window

function OpenInParentWindow(ExtURL,CloseChild){
if(top.opener==null){
window.open(ExtURL,"")
}
else{
top.opener.focus()
top.opener.location=ExtURL
}

	 				if(CloseChild=='close'){
parent.top.close()
}
}

//end


//"button" rollovers
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) { //v3.0
  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); return x;
}

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];}
}

//end


//preferred for "image" rollovers
/*
	Standards Compliant Rollover Script
	Author : Daniel Nolan
	http://www.bleedingego.co.uk/webdev.php
*/

function initRollovers() {
	if (!document.getElementById) return
	
	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {		
		if (aImages[i].className == 'imgover') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_over'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	
			
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_over'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}

window.onload = initRollovers;
 
//end



//popup windows
function NewWindow(pageurl,wide,tall,scroll) { 
	window.open(pageurl,"popup","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=" + scroll + ",resizable=0,width=" + wide + ",height=" + tall + ",left=25,top=25");
}	
//end


//named popup windows for Tours, Photo Galleries, User Guides, etc.
function NewNamedWindow(pageurl,winname,wide,tall,scroll) { 
	window.open(pageurl,winname,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=" + scroll + ",resizable=0,width=" + wide + ",height=" + tall + ",left=25,top=25");
}	
//end



//navigation from pull-down menus
function forward (whichItem) {
    var whichDest = whichItem[whichItem.selectedIndex].value;
    if (whichDest == "nothing") {
        whichItem.selectedIndex = 0;
    } else {
        document.location = whichDest; 
    }
} 
//end



// Begin Channel Intelligence, Inc.  All Rights Reserved, Copyright 2003
function manu_Purchase(rsCustomer,rsSKU,rnVendorID,rsClientTag,rbICI,rnCTID) {
	if (!rnCTID) { rnCTID = 4 };
	document.location = 'http://ci100.palmOne.com/pages/redirector.asp?nCTID=' + rnCTID + '&sSKU=' + escape(rsSKU).replace('+','%2B') + '&nVID=' + rnVendorID + (rsClientTag ? '&sCT=' + escape(rsClientTag).replace('+','%2B') : '') + (rbICI ? '&nICI=1' : '');
}

function manu_DirectCDLink(rsCustomer,rsSKU,rsClientTag) {
	document.location = 'http://ci100.palmOne.com/pages/prices.asp?sSKU=' + escape(rsSKU).replace('+','%2B') + (rsClientTag ? '&sCT=' + escape(rsClientTag).replace('+','%2B') : '');
}

function manu_DirectCDRuleGroupLink(rsCustomer,rsSKU,rnRGID,rsClientTag) {
	document.location = 'http://ci100.palmOne.com/pages/prices.asp?sSKU=' + escape(rsSKU).replace('+','%2B') + '&nRGID=' + rnRGID + (rsClientTag ? '&sCT=' + escape(rsClientTag).replace('+','%2B') : '');
}
// End Channel Intelligence, Inc.






// ------------------------  initialization code ------------------------ //

// check URI for source param and set cookie accordingly
// the buy now buttons will most likely use this cookie
var query = new Array();
query = parseQueryString();

if(query['source']) {
	SetCookie('source', query['source'], null, "/")
}

// Clears text on click in search widget field.
function clearText(thefield){
if (thefield.defaultValue==thefield.value)
thefield.value = ""
} 



//***Adds a new class to an object, preserving existing classes
function AddClass(obj,cName){ KillClass(obj,cName); return obj && (obj.className+=(obj.className.length>0?' ':'')+cName); }

//***Removes a particular class from an object, preserving other existing classes.
function KillClass(obj,cName){ return obj && (obj.className=obj.className.replace(new RegExp("^"+cName+"\\b\\s*|\\s*\\b"+cName+"\\b",'g'),'')); }

//***Returns true if the object has the class assigned, false otherwise.
function HasClass(obj,cName){ return (!obj || !obj.className)?false:(new RegExp("\\b"+cName+"\\b")).test(obj.className) }


function addLoadEvent(func)
{
	
	var oldonload = window.onload;

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