// 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(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"
		}
	}
}


function checknewsletter(myform,firstname,lastname,email)
{
		checkfirstname = document.getElementById(firstname).value;
		checklastname = document.getElementById(lastname).value;
		checkemail = document.getElementById(email).value;
		
		if(checkfirstname == "" || checkfirstname == "first name")
        {
   			 alert("This field is required. Please enter in your first name.")
        	 return false;
        }
		
		if(checklastname == "" || checklastname == "last name")
        {
   			 alert("This field is required. Please enter in your last name.")
        	 return false;
        }
		
		if(checkemail == "" || checkemail == "email")
        {
   			 alert("This field is required. Please enter in your email.")
        	 return false;
        }
   			
		var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   		var address = document.getElementById(email).value;
   		if(reg.test(address) == false) {
      		alert('Invalid Email Address. Please re-enter your email.');
      	return false;
   		}
	
		
	document.getElementById(myform).submit();
}	
