<!--
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_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_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 toggleIt( checked, textbox )
{
	if ( checked ){
		textbox.disabled = false;
		//textbox.disabled = '';
	} else {
		textbox.disabled = true;
		//textbox.disabled = 'disabled';
	}
	
}
function JHshNumberText(){
	if ( !(((window.event.keyCode >= 48) && (window.event.keyCode <= 57)) 
			|| (window.event.keyCode == 13) || (window.event.keyCode == 46) 
			|| (window.event.keyCode == 45))){
				window.event.keyCode = 0 ;
	}
} 

/********************************************

				Cart Methods

********************************************/

function DeleteItem( ctrlToUpdate, cartItemId ){
	// ctrlToUpdate refers to the hidden text box that will
	// store the the cart item id to be removed.
	var ctrl = document.getElementById( ctrlToUpdate );
	ctrl.value = cartItemId;
}
function editSI(CartItemID) {
		window.open('cartEditSI.aspx?CartItemID=' + CartItemID, 'add_view_edit_Special_InStructions', 'height=500, width=500, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no,resizable=no');
}
function CheckDate( datestr ){
	var lthdatestr
	if (datestr != ''){
		lthdatestr= datestr.length ;
	} else {
		lthdatestr=0;
	}
	var tmpy='';
	var tmpm='';
	var tmpd='';
	//var datestr;
	var status;
	status=0;
	if ( lthdatestr== 0){ return 0 }

	for (i=0;i<lthdatestr;i++){ 
		if (datestr.charAt(i)== '/'){
			status++;
		}
		if (status>2){
			alert('Invalid format of date!');
			return 0;
		}
		if ((status==0) && (datestr.charAt(i)!='/')){
			tmpm=tmpm+datestr.charAt(i)
		}
		if ((status==1) && (datestr.charAt(i)!='/')){
			tmpd=tmpd+datestr.charAt(i)
		}
		if ((status==2) && (datestr.charAt(i)!='/')){
			tmpy=tmpy+datestr.charAt(i)
		}
	}
	
	year=new String (tmpy);
	month=new String (tmpm);
	day=new String (tmpd)
	//tempdate= new String (year+month+day);
	//alert(tempdate);
	if ((tmpy.length!=4) || (tmpm.length>2) || (tmpd.length>2)){
		alert('Invalid Date Format.');
		return 0;
	}
	if (!((1<=month) && (12>=month) && (31>=day) && (1<=day)) ){
		alert ('Invalid month or day.');
		return 0;
	}
	if (!((year % 4)==0) && (month==2) && (day==29)){
		alert ('This is not a leap year.');
		return 0;
	}
	if ((month<=7) && ((month % 2)==0) && (day>=31)){
		alert ('This month does not have 31 days.');
		return 0; 
	}
	if ((month>=8) && ((month % 2)==1) && (day>=31)){
		alert ('This month does not have 31 days.');
		return 0;
	}
	if ((month==2) && (day>29)){
		alert('Invalid Date.');
		return 0;
	}
 
	var dt = new Date();
	if ((parseInt(dt.getFullYear(), 10) > parseInt(year, 10)) ||
		((parseInt(dt.getFullYear(), 10) == parseInt(year, 10)) && 
		(parseInt(dt.getMonth(), 10) + 1 > parseInt(month, 10))) ||
		((parseInt(dt.getFullYear(), 10) == parseInt(year, 10)) && 
		(parseInt(dt.getMonth(), 10) + 1 == parseInt(month, 10)) && 
		(parseInt(dt.getDate(), 10) > parseInt(day, 10)))) {
			alert('Start date cannot be in the past.');
			return -1;
	}
	
	return 1;
}
function CopyBillingAddress(){
	var form = document.forms[0];
	var ctrlIDPrefix = clientControlId + '_txtBillingAddress';
	var ctrlIDUpdatePrefix = clientControlId + '_txtShippingAddress';
	
	document.getElementById(ctrlIDUpdatePrefix + 'Line1').value = document.getElementById(ctrlIDPrefix + 'Line1').value;
	document.getElementById(ctrlIDUpdatePrefix + 'Line2').value = document.getElementById(ctrlIDPrefix + 'Line2').value;
	document.getElementById(ctrlIDUpdatePrefix + 'City').value = document.getElementById(ctrlIDPrefix + 'City').value;
	document.getElementById(ctrlIDUpdatePrefix + 'State').value = document.getElementById(ctrlIDPrefix + 'State').value;
	document.getElementById(ctrlIDUpdatePrefix + 'ZipCode').value = document.getElementById(ctrlIDPrefix + 'ZipCode').value;
	document.getElementById(ctrlIDUpdatePrefix + 'Country').value = document.getElementById(ctrlIDPrefix + 'Country').value;
	document.getElementById(ctrlIDUpdatePrefix + 'Phone').value = document.getElementById(ctrlIDPrefix + 'Phone').value;
	document.getElementById(ctrlIDUpdatePrefix + 'EmailAddress').value = document.getElementById(ctrlIDPrefix + 'EmailAddress').value;
	
	
}

function AgreeTerms( checked, checkbox, textbox ){
	checkbox.disabled = !checked;
	checkbox.checked = checked && checkbox.checked;
}
//-->

/*****************************************************

 General Utility Functions
 
 ****************************************************/
function checkUncheckAll(theElement) {
	
	//var theForm = theElement.form;
	var theForm = document.forms[0];
	for( var z = 0; z < theForm.length; z++ ){
		if( theForm[z].type == 'checkbox' ){
			theForm[z].checked = !theForm[z].checked;
		}
	}
}
function uncheckAll(theElement) {
	
	//var theForm = theElement.form;
	var theForm = document.forms[0];
	for( var z = 0; z < theForm.length; z++ ){
		if( theForm[z].type == 'checkbox' && !theForm[z].disabled ){
			theForm[z].checked = false;
		}
	}
}
function checkAll(theElement) {
	
	//var theForm = theElement.form;
	var theForm = document.forms[0];
	for( var z = 0; z < theForm.length; z++ ){
		if( theForm[z].type == 'checkbox' && !theForm[z].disabled ){
			theForm[z].checked = true;
		}
	}
}
function CheckIfSelected(elementToSet){
	var theForm = document.forms[0];
	var isSelected = false;
	for( var z = 0; z < theForm.length; z++ ){
		if( theForm[z].type == 'checkbox' && !theForm[z].disabled ){
			if ( theForm[z].checked == true ){
				isSelected = true;
				break;
			}
		}
	}
	document.forms[0][elementToSet].value = isSelected;
}

