function test() {
	alert("test pop up");
}

// Returns true if the given text is a number between 0 to 9.
function isInteger(sText) {
	var ValidChars = "0123456789";
	var IsInteger=true;
	var Char;

	for (i = 0; i < sText.length && IsInteger == true; i++) { 
		Char = sText.charAt(i); 
		if (ValidChars.indexOf(Char) == -1) {
			IsInteger = false;
		}
	}
	return IsInteger;   
}

function isPercentage(sText) {
	var validChars = "0123456789.";
	var isPercentage=true;
	var Char;

	for (i = 0; i < sText.length && isPercentage == true; i++) { 
		Char = sText.charAt(i); 
		if (validChars.indexOf(Char) == -1) {
			isPercentage = false;
		}
	}
	
	floatValue = parseFloat(sText)
	if (floatValue > 100) {
		isPercentage = false;
	}
	return isPercentage;   
	
}

// Returns true if the given date has validate date format of YYYY/MM/DD
function isCorrectDateFormat(sDate) {
	var isCorrectDateFormat = false;		
	
	if (sDate.length == 10) {					
		var year = sDate.substring(6,10)//(0,4)	
		var month = sDate.substring(0,2)//(5,7)
		var dd = sDate.substring(3,5)//(8,10)
		
		var firstDelimiter = sDate.substring(2,3)//(4,5)
		var secondDelimiter = sDate.substring(5,6)//(7,8)
		if (isInteger(year) && isInteger(month) && isInteger(dd)) {
		
			if (firstDelimiter == "/" && secondDelimiter == "/") {
				isCorrectDateFormat = true;
			}
		}
	}
	return isCorrectDateFormat;
}

// Returns true if the given year is a leap year			
function isLeapYear(year) {
	leapYear = false;
	if (isInteger(year)) {
		if (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)) {
			leapYear = true;
		}
	}
	return leapYear;
}

// Returns true if the given date is a valid date, leap year is also accounted
function isCorrectDaysInTheDate(strDay, strMonth, strYear) {
	rValue = false;
	
	// radix, Optional. A number (from 2 to 36) that represents the 
	//numeral system to be used, MUST use radix=10
	radix=10
	
	day = parseInt(strDay, radix)
	month = parseInt(strMonth, radix)
	year = parseInt(strYear, radix)				
	
	switch(month) {
		case 1: 
		case 3:
		case 5:
		case 7:
		case 8:
		case 10:
		case 12:
			if (day <= 31) {
				rValue = true;
			}
			break;
		case 4:
		case 6:
		case 9:
		case 11:
			if (day <= 30) {
				rValue = true;
			}
			break;
		case 2:
			// leap year has 29 days in February
			if (isLeapYear(year) && day == 29) {
				rValue = true;
			} else {
				if (day <= 28) {
					rValue = true;
				}
			}
			break;
		default:
			rValue = false;					
	}
	return rValue;
}


function check_select_box_for_zero(form)
{
	if (form.bgs.selectedIndex == 0)
	{
		return;
	}
	form.submit();
}


function check_select_box_for_zero_aseq(form)
{
	if (form.aseq.selectedIndex == 0)
	{
		return;
	}
	form.submit();
}

function check_select_box_for_zero_PROD(form)
{
	if (form.prodtype_id.selectedIndex == 0)
	{
		return;
	}
	form.submit();
}
function check_select_box_for_zero_subcat(form)
{
	if (form.subcat.selectedIndex == 0)
	{
		return;
	}
	form.submit();
}
function Clickheretoprint()
{ 
  var disp_setting="toolbar=yes,location=no,directories=yes,menubar=yes,"; 
      disp_setting+="scrollbars=yes,width=650, height=600, left=100, top=25"; 
  var content_vlue = document.getElementById("print_content").innerHTML; 
  
 content_vlue = content_vlue.replace("img","img style='display:none'");
 content_vlue = content_vlue.replace("height=290","height=0");
  content_vlue = content_vlue.replace("width=265","width=0");
  var docprint=window.open("","",disp_setting); 
   docprint.document.open(); 
   docprint.document.write('<html><head><title>Birthday in a box</title>'); 
   docprint.document.write('<style type="text/css">#floater {visible : false;}</style></head><body onLoad="self.print()"><center>');          
   docprint.document.write(content_vlue);          
   docprint.document.write('</center></body></html>'); 
   docprint.document.close(); 
   docprint.focus(); 
}
function changersku(dropdown) {
	 var myindex  = document.form10.optionalskus.selectedIndex
    var SelValue = document.form10.optionalskus.options[myindex].value
document.form10.changesku.name = SelValue;
	}

 function openWindowWithSize(file, width, height) {
            var winl = (screen.width - width) / 2;
            var wint = (screen.height - height) / 2;
            popupWin = window.open(file, 'remote', 'menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,top='+wint+',left='+winl+',width='+width+',height='+height);
            popupWin.window.focus()
        }        function openTheWindow( strBody ) {
            w = window.open( "", "MyWindow", "width=280,height=350"); 
            w.document.write("<html><HEAD><title>Birthday in a Box</title></HEAD>");
            w.document.write("<body><center><b>Birthday in a Box Party Tips</b></center><p style='font-Size: 10pt; Font-Family: Arial, Helvetica, sans-serif'>" + strBody + "<br></p><p>&nbsp;<p><div align='center'><a href='javascript:window.close();'><img src='images/done.gif' width='62' height='12' alt='done' border='0'></a></div></body></html>");
            w.document.close();
        }
