<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Original:  Nick Baker -->
<!-- Begin
// Cookie Functions  ////////////////////  (:)
// Set the cookie.
// SetCookie('your_cookie_name', 'your_cookie_value', exp);
// Get the cookie.
// var someVariable = GetCookie('your_cookie_name');

var expDays = 100;
var exp = new Date(); 
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));

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;
}

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" : "");
}

// cookieForms saves form content of a page.
// use the following code to call it:
//  <body onLoad="cookieForms('open', 'form_1', 'form_2', 'form_n')" onUnLoad="cookieForms('save', 'form_1', 'form_2', 'form_n')">
// It works on text fields and dropdowns in IE 5+
// It only works on text fields in Netscape 4.5

function cookieForms() {  
	var mode = cookieForms.arguments[0];
	for(f=1; f<cookieForms.arguments.length; f++) {
		formName = cookieForms.arguments[f];
		if(mode == 'open') {	
			cookieValue = GetCookie('saved_'+formName);
			if(cookieValue != null) {
				var cookieArray = cookieValue.split('#cf#');
				if(cookieArray.length == document[formName].elements.length) {
					for(i=0; i<document[formName].elements.length; i++) {
						if(cookieArray[i].substring(0,6) == 'select') { document[formName].elements[i].options.selectedIndex = cookieArray[i].substring(7, cookieArray[i].length-1); }
						else if((cookieArray[i] == 'cbtrue') || (cookieArray[i] == 'rbtrue')) { document[formName].elements[i].checked = true; }
						else if((cookieArray[i] == 'cbfalse') || (cookieArray[i] == 'rbfalse')) { document[formName].elements[i].checked = false; }
						else { document[formName].elements[i].value = (cookieArray[i]) ? cookieArray[i] : ''; }
					}
				}
			}
		}

		if(mode == 'save') {	
			cookieValue = '';
			for(i=0; i<document[formName].elements.length; i++) {
				fieldType = document[formName].elements[i].type;
				if(fieldType == 'password') { passValue = ''; }
				else if(fieldType == 'checkbox') { passValue = 'cb'+document[formName].elements[i].checked; }
				else if(fieldType == 'radio') { passValue = 'rb'+document[formName].elements[i].checked; }
				else if(fieldType == 'select-one') { passValue = 'select'+document[formName].elements[i].options.selectedIndex; }
				else { passValue = document[formName].elements[i].value; }

				cookieValue = cookieValue + passValue + '#cf#';
			}
			cookieValue = cookieValue.substring(0, cookieValue.length-4); // Remove last delimiter
			SetCookie('saved_'+formName, cookieValue, exp);		
		}	
	}
}

//  End -->

<!-- This script does the following:
//	counts the total number of check boxes,
//	counts the number of boxes that are checked,
//	counts the number of boxes that are NOT checked
//		and displays the results in a text box.
-->
<!-- Begin
function anyCheck(form) {
var checked = 0;
var unchecked = 0;
var max = form.ckbox.length; //Returns the total number of form elements with the name cbox within form
for (var idx = 0; idx < max; idx++) {
if (eval("document.playlist.ckbox[" + idx + "].checked") == true) {
    checked += 1;
	}
if (eval("document.playlist.ckbox[" + idx + "].checked") == false) {
	unchecked += 1;
   }
}
var checkedPercent = (checked / max) * 100;
var uncheckedPercent = (unchecked / max) * 100;
//total boxes//
//alert("There are " + max + " Total Boxes.");
document.playlist.txtTotals.value = max; 
//boxes checked//
//alert("You selected " + checked + " boxes.");
document.playlist.txtChecked.value = (+ checkedPercent.toFixed(1) + "%");

//boxes NOT checked//
//alert("there are " + unchecked + " boxes unchecked.");
document.playlist.txtNotChecked.value = (+ uncheckedPercent.toFixed(1) + "%");
//("Unchecked " + unchecked + " boxes.");
}
function ChangeTitle() {
   var newtitle = document.playlist.txtTotals.value;
   var head1 = document.getElementById("totalSongs");
   var newchecked = document.playlist.txtChecked.value;
   var newunchecked = document.playlist.txtNotChecked.value;
   var head2 = document.getElementById("totalChecked");
   var head3 = document.getElementById("totalUnChecked");
   head1.firstChild.nodeValue=newtitle;
   head2.firstChild.nodeValue=newchecked;
   head3.firstChild.nodeValue=newunchecked;
}
//  End -->


// navigator detection : is it IE ?
    var ie = false; /*@cc_on ie = true; @*/

var C;
   
function init() {
if(ie) {
   // backgrounds gestion (colors) for IE
   // TR normal
       cel_normale        = "#FFFFFF";    // 'white'; 'skyblue'; //
   // TR normal over
       cel_normale_over   = 'gold';    // "#FFCC00"; "#CCCCCC"; 
   // TR selection
       cel_selection      = "#66FF66";    // 'lime';
   // TR selection over
       cel_selection_over = 'goldenrod';    // "#99CC00";
   // recup personal browser's color
   function getNavigatorColor(x) { 
     document.getElementById('aid').style.backgroundColor=x;
     return document.getElementById('aid').style.backgroundColor;
     }
   // colors traduction for the browser
   cel_normale  = getNavigatorColor(cel_normale);
   cel_normale_over  = getNavigatorColor(cel_normale_over);
   cel_selection   = getNavigatorColor(cel_selection);
   cel_selection_over = getNavigatorColor(cel_selection_over);
   getNavigatorColor('#ffb');
   }
// attribtting events to TRs from all tables
if( document.getElementById && document.getElementsByTagName) {
   // array cells of all tables
   C = document.getElementsByTagName('tr');
   // events to give to TRs
   for (var i=0;i<C.length;i++) {
   	   C[i].onclick = Function('highlight_row(this)');
   	   if(ie) {
   	          C[i].style.backgroundColor = cel_normale; // cell JS stylage
              C[i].onmouseover = Function('ovlt(this,true)');
              C[i].onmouseout  = Function('ovlt(this,false)');
              }
       }
   }
}

function highlight_row(elem) {
if(document.getElementById && document.getElementsByTagName) {
        if(ie)
        elem.style.backgroundColor = 
            (elem.style.backgroundColor==cel_selection||elem.style.backgroundColor==cel_selection_over)? cel_normale : cel_selection ;
        else
        elem.className = elem.className=='chk'? '' : 'chk'; 
    }
}

/*function ovlt(elem,kind) { // function of roll-over for IE
var c = elem.style.backgroundColor;
if(kind)
   elem.style.backgroundColor = c==cel_selection? cel_selection_over : cel_normale_over ;
else
  elem.style.backgroundColor = (c==cel_selection_over||c==cel_selection)? cel_selection : cel_normale ;
}*/
//put this in the body tag of the page...???
//onload = init;