// show/hide rows
	function toggle_rows(row_base_id,row_show_id,rows)
	{	
		show_row_id = row_base_id + "_" + row_show_id;
		obj_show = document.getElementById(show_row_id);
		for(i=1; i<=rows; i++) {
			row_id = row_base_id + "_" + i;
			obj = document.getElementById(row_id);
			if (row_id == show_row_id) {
			 	obj.style.display='';
			}
			else {
				obj.style.display='none';
			}
		}
	}

// switch the show/hide state of two IDs
function toggle_switch(show_id,hide_id) {
	document.getElementById(show_id).style.display = 'none';
	document.getElementById(hide_id).style.display = '';
}

// Simple show/hide
function toggle_simple(id)
{
	var obj = document.getElementById(id);
	if (obj.style.display == '')
	{
		obj.style.display='none';
	}
	else
	{
		obj.style.display='';
	}
}

function toggle_on(id)
{
	var obj = document.getElementById(id);
	obj.style.display='';
}

function toggle_off(id)
{
	var obj = document.getElementById(id);
	obj.style.display='none';
}

// ?
function toggle(id,status)
{
	var obj = document.getElementById(id);
	if (obj.style.display == '' && status == 'off')
	{
		obj.style.display='none';
	}
	else if (obj.style.display == 'none' && status == 'on')
	{
		obj.style.display='';
	}
}

// ?
function product_usage_select(prod_use_count) {	
	for(i=0; i<=prod_use_count; i++) {
		if (document.getElementById('product_usage_select').options[i].selected && document.getElementById('product_usage_select').options[i].value == i) {
			document.getElementById('prod_' + i).style.display = '';
		}
		else {
			document.getElementById('prod_' + i).style.display = 'none';
		}
	}
}

// Used on the contact us form
function check_subject() {
	subject_id = document.getElementById('destination');
	subject_value = subject_id.options[subject_id.selectedIndex].value;
	if (subject_value == '4') {
		alert("Please note: Return requests cannot be accepted via email at this time. \nPlease contact us by phone (listed above).");
		subject_id.selectedIndex = 0;
	}
}

// Clear form's default form value
function clearText(thefield){
	if (thefield.defaultValue==thefield.value) {
		thefield.value = ""
	}
}

Global = {
	FixPng: function( img ){
		if(document.all){
			img.parentNode.style.width = img.offsetWidth;
			img.parentNode.style.height = img.offsetHeight;
			img.parentNode.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale src='"+ img.src +"')"
		} else {
			img.style.visibility = "visible"
		}
	}
}

// Rollovers
	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_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_findObj(n, d) { //v4.01
	  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);
	  if(!x && d.getElementById) x=d.getElementById(n); 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];}
	}

function isValidDate(dateStr)
{
	var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
	var matchArray = dateStr.match(datePat); // is the format ok? 

	if (matchArray == null)
	{
		alert("Please enter date as either mm/dd/yyyy or mm-dd-yyyy.");
		return false;
	}

	month = matchArray[1]; // parse date into variables 
	day = matchArray[3]; 
	year = matchArray[5]; 

	if (month < 1 || month > 12)
	{
		// check month range
		alert("Month must be between 1 and 12.");
		return false;
	} 

	if (day < 1 || day > 31)
	{
		alert("Day must be between 1 and 31.");
		return false;
	}

	if ((month==4 || month==6 || month==9 || month==11) && day==31)
	{
		alert("Month "+month+" doesn't have 31 days!");
		return false;
	} 

	if (month == 2)
	{
		// check for february 29th
		var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
		if (day > 29 || (day==29 && !isleap))
		{
			alert("February " + year + " doesn't have " + day + " days!");
			return false; 
		}
	}
	return true; // date is valid 
}