<!--

function openwindow(url)
{
	var newwindow;
	newwindow=window.open(url,'name','height=600,width=600,scrollbars=yes,resizable=yes,toolbar=yes');
	if (window.focus) {newwindow.focus()}
}


// Client-side JS functions for form validation

function validateCheck(control, msg)
{
	for (counter=0;counter<control.length;counter++)
	{
		if(control[counter].checked)
		var ans=true;
	}
	if(!ans)
	{
		alert(msg)
		control[1].focus()
		return false;
	}
}

function ToggleMe(obj)
{
	if(obj.style.display=='none'){obj.style.display = '';
	}
	else{ obj.style.display = 'none';}
}

function ShowMe(obj)
{
	obj.style.display = '';
}

function HideMe(obj)
{
	obj.style.display = 'none';
}

function ShowRadioKids(grandparent,showfamily)
{
	var i;
	for (i = 0; i < grandparent.length; i++){
	HideMe(document.all[grandparent[i].value]);}
	ShowMe(showfamily);
}

function echeck(str) 
{

	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	   alert("Invalid E-mail ID")
	   return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   alert("Invalid E-mail ID")
	   return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
	    alert("Invalid E-mail ID")
	    return false
	}

	 if (str.indexOf(at,(lat+1))!=-1){
	    alert("Invalid E-mail ID")
	    return false
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
	    alert("Invalid E-mail ID")
	    return false
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
	    alert("Invalid E-mail ID")
	    return false
	 }
		
	 if (str.indexOf(" ")!=-1){
	    alert("Invalid E-mail ID")
	    return false
	 }

	 return true					
}

function ValidateControl( control, strName, focus )
// ===================================================================
// pr_ValidateControl
// Parameters:		control		form control
//					strName		Userfriendly name for the control
//					focus		1: Set focus to control; 0: do not set focus to control
// Returns:			alert message and False if validation fails, else True
// ===================================================================
{
	var tmpValue	= control.value;
	if( control.type.substring(0,6) == "select" )
	{
		if( control.selectedIndex == -1) {
			tmpValue = ""
		} else {
			tmpValue = control.options[control.selectedIndex].value
		}
	}
	if( tmpValue == "none" )
	{
		alert( strName + ": please choose." );
		if (focus) control.focus();
		return false;
	}
	if( tmpValue == null || tmpValue == "" )
	{
		alert( strName + ": this is a required field." );
		if (focus) control.focus();
		return false;
	}
	return true;
}

function ValidateDateTime( control, strName, focus, strSwitch )
{
	var tmpValue = control.value;

	switch (strSwitch) {
	case "month" :
		if( tmpValue < 1 || tmpValue > 12  )
		{
			alert( strName + ": must be between 1 and 12." );
			if (focus) control.focus();
			return false;
		}
		break;
	case "day" :
		if( tmpValue < 1 || tmpValue > 31)
		{
			alert( strName + ": Must be between 1 and 31." );
			if (focus) control.focus();
			return false;
		}
		break;
	case "year" :
		if ( tmpValue == "00" ) 
			{}
		else
			if ( tmpValue == null || tmpValue == "" ) 		
			{
				alert( strName + ": you must have a year" );
				if (focus) control.focus();
				return false;
			}
		else	

			if( tmpValue < 1 || tmpValue > 99)
			{
				alert( strName + ": year must be between 00 and 99" );
				if (focus) control.focus();
				return false;
			}
		break;
	case "hour" :
		if( tmpValue < 1 || tmpValue > 12)
		{
			alert( strName + ": hour must be between 1 and 12." );
			if (focus) control.focus();
			return false;
		}
		break;
	case "minute" :
		if ( tmpValue == "00" )
			{}
		else
			if ( tmpValue == null || tmpValue == "" ) 		
			{
				alert( strName + ": you must have minutes entered" );
				if (focus) control.focus();
				return false;
			}
		else
			if( tmpValue < 0 || tmpValue > 59)
			{
				alert( strName + ": minutes must be between 00 and 59" );
				if (focus) control.focus();
				return false;
			}
		break;
	}
	return true;
}
function validateIsNumber(control)
{
	var checkStr	= control.value;
	var checkOk	= "0123456879";
	var allValid	= true;

	for(i=0;i<checkStr.length;i++)
	{
		ch = checkStr.charAt(i);
		for(j=0;j<checkOk.length;j++)
		{
			if ( ch == checkOk.charAt(j) ) 
				break;
		}
		if ( j == checkOk.length )
		{
			allValid=false;
			break;
		}
	}
	if ( !allValid )
	{
		alert("All Number's must be a whole number");	
		return false;
	} 
	else return true;
}
function validateNumber(control, intLength)
{
	var checkStr	= control.value;
	var checkOk	= "0123456879";
	var allValid	= true;

	for(i=0;i<checkStr.length;i++)
	{
		ch = checkStr.charAt(i);
		for(j=0;j<checkOk.length;j++)
		{
			if ( ch == checkOk.charAt(j) ) 
				break;
		}
		if ( j == checkOk.length )
		{
			allValid=false;
			break;
		}
		if ( intLength == 0 )
			{break;}
		else
			if ( intLength != checkStr.length )
			{
				allValid=false;
				break;
			}
	}
	if ( !allValid )
	{
		alert("Not a valid number for this field");	
		return false;
	} 
	else return true;
}
function validateCheckBox(control, controlHide, hidControl ) {
	if (control.checked == true) {
		controlHide.value++
		hidControl.value = "Yes"
	}
	else
		{controlHide.value--
		hidControl.value = ""
		}
}
function blinkIt() {
 if (!document.all) return;
 else {
   for(i=0;i<document.all.tags('blink').length;i++){
      s=document.all.tags('blink')[i];
      s.style.visibility=(s.style.visibility=='visible')?'hidden':'visible';
   }
 }
}
function deliverTime(frmSearch, intTime)
{
    year = "20" + frmSearch.Year.value
    month = frmSearch.Month.value -1

    if (frmSearch.AMPM.value == "PM")
	{hour = parseInt(frmSearch.Hour.value) + 12; }
    else
	{hour = frmSearch.Hour.value; }
	
	gmtDate = new Date(year, month, frmSearch.Day.value, hour, frmSearch.Minute.value, 00)
	gmtNow = new Date()

    var number = gmtDate-gmtNow;
    interval = "h"
    rounding = "roundDays"
    
    // what kind of add to do? 
    switch (interval.charAt(0))
    {
        case 'd': case 'D': 
            iOut = parseInt(number / 86400000) ;
            if(rounding) iOut += parseInt((number % 86400000)/43200001) ;
            break ;
        case 'h': case 'H':
            iOut = parseInt(number / 3600000 ) ;
            if(rounding) iOut += parseInt((number % 3600000)/1800001) ;
            break ;
        case 'm': case 'M':
            iOut = parseInt(number / 60000 ) ;
            if(rounding) iOut += parseInt((number % 60000)/30001) ;
            break ;
        case 's': case 'S':
            iOut = parseInt(number / 1000 ) ;
            if(rounding) iOut += parseInt((number % 1000)/501) ;
            break ;
        default:
	    alert("Unknown Issue");
	    return null;
    }


   // check to see if it's within 24 hours of order
   if (iOut < intTime)
	{
	  alert("We appologize; however, " + intTime + " hour notice is required")
	  return true;
	}
	
}
function checkDate(month, day, year, intTime, interval)
{
    year = year
    month = month-1
    day = day

    gmtDate = new Date(year, month, day)
    var gmtNow = new Date()
	
	var number = gmtDate-gmtNow;
    var timeframe
    rounding = "roundDays"
    
    // what kind of add to do? 
    switch (interval.charAt(0))
    {
        case 'd': case 'D': 
            iOut = parseInt(number / 86400000) ;
            if(rounding) iOut += parseInt((number % 86400000)/43200001) ;
	    timeframe = " Day"
            break ;
        case 'h': case 'H':
            iOut = parseInt(number / 3600000 ) ;
            if(rounding) iOut += parseInt((number % 3600000)/1800001) ;
	    timeframe = " Hour"
            break ;
        case 'm': case 'M':
            iOut = parseInt(number / 60000 ) ;
            if(rounding) iOut += parseInt((number % 60000)/30001) ;
	    timeframe = " Month"
            break ;
        case 's': case 'S':
            iOut = parseInt(number / 1000 ) ;
            if(rounding) iOut += parseInt((number % 1000)/501) ;
	    timeframe = " Second"
            break ;
        default:
	    alert("Unknown Issue");
	    return null;
    }


   // check to see if it's within x time frame
   if (iOut < intTime)
	{
	  alert("We appologize; however, " + intTime + timeframe + " notice is required")
	  return true;
	}
	
}

function seekarray(varName, intarray)
{
    for(x=0; prod.length; x++)
      {
	if(varName==prod[x][0])
	  {
	    return prod[x][intarray]
	  }
      }
}
function addArray(varName)
{
    for (x=0; x < userinfo.length ; x++)
	{
	  if(varName.name==userinfo[x][0])
	    {
	      userinfo[x][2] = varName.value
	      break;
	    }
	}
}
function addDateTime(Month, Day, Year, Hour, Minute, AMPM, x)
{
	DateTime = Month.value+"/"+Day.value+"/"+Year.value+" "+Hour.value+":"+Minute.value+" "+AMPM.value
	userinfo[x][2] = DateTime
}
function addPhone(Area, Prefix, Suffix, Ext, x)
{
	phone = "(" + Area.value + ")" + " " + Prefix.value + "-" + Suffix.value + " " + Ext.value
	userinfo[x][2] = phone
}

function calcTotal(varName)
{

    total = 0
    // set array quantity
    for (x=0; prod.length ; x++)
	{
	  if(varName.name==prod[x][0])
	    {
	      prod[x][2] = varName.value
	      break;
	    }
	}

    // calculate total
    for (x=0; x < prod.length ; x++)
	{
	  var price = (prod[x][1])
	  var quantity = (prod[x][2])
	  total = (price*quantity)+total
	}
    total = Math.round(total*100)/100

    total = formatCurrency(total)
    html = "<p align=center>Your Total is:&nbsp;" +total+ ", this amount does not include taxes."

    if(LC_NS){
	var l=document.layers[c.Name+"GrandTotal"].document.layers[c.Name].document;
	l.open();
	l.write(html);
	l.close();
    }else if(LC_N6||LC_IE){
	document.getElementById("GrandTotal").innerHTML=html;
    }else{
	document.write(html);
    }
}

function formatCurrency(num) 
{
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
	  num = "0";

	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();

	if(cents<10)
	  cents = "0" + cents;

	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
	num = num.substring(0,num.length-(4*i+3))+','+
	num.substring(num.length-(4*i+3));
	return (((sign)?'':'-') + '$' + num + '.' + cents);
}

//-->