// Example:
// simplePreload( '01.gif', '02.gif' ); 
function SimplePreload()
{ 
  var args = simplePreload.arguments;
  document.imageArray = new Array(args.length);
  for(var i=0; i<args.length; i++)
  {
    document.imageArray[i] = new Image;
    document.imageArray[i].src = args[i];
  }
}

//
// set page to show via page variable
//
function SetPage(value) {
	setQueryString('page', value);
}

//
// set the querystring arg value
//
function setQueryString(argname, value) {
	var url = window.location.href.toString();
	var query = window.location.search.substring(1);
	var rExp = new RegExp(argname + "=[a-z0-9]+");
	url = url.substring(0, url.indexOf('?'));
	if (query.search(rExp) != -1)
	{
		query = query.replace(rExp, argname + '=' + value);
	} else {
		query += ((query.length > 0) ? '&' : '') + argname + '=' + value;
	}
	window.location.href = url +'?'+ query;
}

//
// select the a value from dropdown list and populate a textbox value 
//
function PopulateTextboxFromDropdown(which, target) {
	if (which.selectedIndex != 0) {
		target.value=which[which.selectedIndex].value;
	}
}

//
// selects a drop down list option by it's value
//
function SelectOptionByValue(which, val) {
	for (i=0; i<which.options.length; i++) {
		if (which.options[i].value == val) {
			which.options[i].selected = true;
		}
	}
}

// date drop down selection boxes
function DateDropDownGenerator(n)
{
	var d=new Date();
	this.name = "dd";
	this.day = '';
	this.month = '';	
	this.year = '';
	this.InsertDayDropDown=function(){document.write("<select class=\"dropdownDay\" name=\""+this.name+"day\">");for(var i=1;i<=31;i++){document.write("<option value=\""+i+"\""+((i==this.day)?"selected":"")+">"+i+"</option>");}document.write("</select> ");}
	this.InsertMonthDropDown=function(){var months=Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");document.write("<select class=\"dropdownMonth\" name=\""+this.name+"month\">");for(var i=0;i<months.length; i++){document.write("<option value=\"" + (i+1) + "\""+(((i+1)==this.month)?"selected":"")+">" + months[i] + "</option>");}document.write("</select> ");}
	this.InsertYearDropDown=function(){document.write("<select class=\"dropdownYear\" name=\""+this.name+"year\">");for(var i=d.getFullYear();i<=d.getFullYear()+3;i++){document.write("<option value=\""+i+"\""+((i==this.year)?"selected":"")+">"+i+"</option>");}document.write("</select> ");}
	this.Generate=function(){this.InsertDayDropDown();this.InsertMonthDropDown();this.InsertYearDropDown();}
}
