//POPUP WINDOW FUNCTION
//
function popUpWindow(sPage,sWindow,iTop,iLeft,iHeight,iWidth,sScrollbars){
	popup=window.open(sPage,sWindow,"top=" + iTop + ",left=" + iLeft + ",height=" + iHeight + ",width=" + iWidth + ",scrollbars=" + sScrollbars);
	popup.focus();
}

function showHide(id) { // This gets executed when the user clicks on the checkbox
	var obj = document.getElementById(id);
	if (obj.style.visibility=="hidden") { // if it is checked, make it visible, if not, hide it
		obj.style.visibility = "visible";
	} else {
		obj.style.visibility = "hidden";
	}
}


function copyAddr(theForm) {

	if (theForm.chkSame.checked == true) {
		theForm.ship_company.value = theForm.bill_company.value;
		theForm.ship_address.value = theForm.bill_address.value;
		theForm.ship_city.value = theForm.bill_city.value;
		theForm.ship_state.value = theForm.bill_state.value;
		theForm.ship_ZIP.value = theForm.bill_ZIP.value;
		theForm.ship_country.value = theForm.bill_country.value;
		theForm.ship_prov.value = theForm.bill_prov.value;
	}
}

/* ----------Higlight Functions -------------------*/

function high(which2){
	theobject=which2
	highlighting=setInterval("highlightit(theobject)",40)
}

function low(which2){
	clearInterval(highlighting)
	which2.filters.alpha.opacity=60
}	

function highlightit(cur2){
	if (cur2.filters.alpha.opacity<100)
		cur2.filters.alpha.opacity+=5
	else if (window.highlighting)
		clearInterval(highlighting)
}

/* ------------------------ END Highlight Functions ---------------------- */


/* ------- Increase Size on Hover Functions ---------- */

/**
The JavaScript functions below will gradually enlarge or shrink an image
on the current page. I use this for mouseover effects, but there might be
some other interesting applications of it as well.

You can use these scripts in any way you'd like, just don't pretend like
you wrote them yourself.

version 1.0
March 17, 2005
Julian Robichaux, http://www.nsftools.com
*/

/**** adjust these two parameters to control how fast or slow
 **** the images grow/shrink ****/
// how many milliseconds we should wait between resizing events
var resizeDelay = 10;
// how many pixels we should grow or shrink by each time we resize
var resizeIncrement = 5;

// this will hold information about the images we're dealing with
var imgCache = new Object();


/**
The getCacheTag function just creates a (hopefully) unique identifier for
each <img> that we resize.
*/
function getCacheTag (imgElement) {
	return imgElement.src + "~" + imgElement.offsetLeft + "~" + imgElement.offsetTop;
}


/**
We're using this as a class to hold information about the <img> elements
that we're manipulating.
*/
function cachedImg (imgElement, increment) {
	this.img = imgElement;
	this.cacheTag = getCacheTag(imgElement);
	this.originalSrc = imgElement.src;
	
	var h = imgElement.height;
	var w = imgElement.width;
	this.originalHeight = h;
	this.originalWidth = w;
	
	increment = (!increment) ? resizeIncrement : increment;
	this.heightIncrement = Math.ceil(Math.min(1, (h / w)) * increment);
	this.widthIncrement = Math.ceil(Math.min(1, (w / h)) * increment);
}


/**
This is the function that should be called in the onMouseOver and onMouseOut
events of an <img> element. For example:

<img src='onesmaller.gif' onMouseOver='resizeImg(this, 150, "onebigger.gif")' onMouseOut='resizeImg(this)'>

The only required parameter is the first one (imgElement), which is a
reference to the <img> element itself. If you're calling from onMousexxx, 
you can just use "this" as the value.

The second parameter specifies how much larger or smaller we should resize
the image to, as a percentage of the original size. In the example above,
we want to resize it to be 150% larger. If this parameter is omitted, we'll
assume you want to resize the image to its original size (100%).

The third parameter can specify another image that should be used as the
image is being resized (it's common for "rollover images" to be similar but
slightly different or more colorful than the base images). If this parameter
is omitted, we'll just resize the existing image.
*/
function resizeImg (imgElement, percentChange, newImageURL) {
	// convert the percentage (like 150) to an percentage value we can use
	// for calculations (like 1.5)
	var pct = (percentChange) ? percentChange / 100 : 1;
	
	// if we've already resized this image, it will have a "cacheTag" attribute
	// that should uniquely identify it. If the attribute is missing, create a
	// cacheTag and add the attribute
	var cacheTag = imgElement.getAttribute("cacheTag");
	if (!cacheTag) {
		cacheTag = getCacheTag(imgElement);
		imgElement.setAttribute("cacheTag", cacheTag);
	}
	
	// look for this image in our image cache. If it's not there, create it.
	// If it is there, update the percentage value.
	var cacheVal = imgCache[cacheTag];
	if (!cacheVal) {
		imgCache[cacheTag] = new Array(new cachedImg(imgElement), pct);
	} else {
		cacheVal[1] = pct;
	}
	
	// if we're supposed to be using a rollover image, use it
	if (newImageURL)
		imgElement.src = newImageURL;
	
	// start the resizing loop. It will continue to call itself over and over
	// until the image has been resized to the proper value.
	resizeImgLoop(cacheTag);
	return true;
}


/**
This is the function that actually does all the resizing. It calls itself
repeatedly with setTimeout until the image is the right size.
*/
function resizeImgLoop (cacheTag) {
	// get information about the image element from the image cache
	var cacheVal = imgCache[cacheTag];
	if (!cacheVal)
		return false;
	
	var cachedImageObj = cacheVal[0];
	var imgElement = cachedImageObj.img;
	var pct = cacheVal[1];
	var plusMinus = (pct > 1) ? 1 : -1;
	var hinc = plusMinus * cachedImageObj.heightIncrement;
	var vinc = plusMinus * cachedImageObj.widthIncrement;
	var startHeight = cachedImageObj.originalHeight;
	var startWidth = cachedImageObj.originalWidth;
	
	var currentHeight = imgElement.height;
	var currentWidth = imgElement.width;
	var endHeight = Math.round(startHeight * pct);
	var endWidth = Math.round(startWidth * pct);
	
	// if the image is already the right size, we can exit
	if ( (currentHeight == endHeight) || (currentWidth == endWidth) )
		return true;
	
	// increase or decrease the height and width, making sure we don't get
	// larger or smaller than the final size we're supposed to be
	var newHeight = currentHeight + hinc;
	var newWidth = currentWidth + vinc;
	if (pct > 1) {
		if ((newHeight >= endHeight) || (newWidth >= endWidth)) {
			newHeight = endHeight;
			newWidth = endWidth;
		}
	} else {
		if ((newHeight <= endHeight) || (newWidth <= endWidth)) {
			newHeight = endHeight;
			newWidth = endWidth;
		}
	}
	
	// set the image element to the new height and width
	imgElement.height = newHeight;
	imgElement.width = newWidth;
	
	// if we've returned to the original image size, we can restore the
	// original image as well (because we may have been using a rollover
	// image in the original call to resizeImg)
	if ((newHeight == cachedImageObj.originalHeight) || (newWidth == cachedImageObj.originalwidth)) {
		imgElement.src = cachedImageObj.originalSrc;
	}
	
	// shrink or grow again in a few milliseconds
	setTimeout("resizeImgLoop('" + cacheTag + "')", resizeDelay);
}



/* ------------------------ END Increase size on Hover Functions ---------------------- */


//TRIM FUNCTION
//
function trim(inputString) {
	   // Removes leading and trailing spaces from the passed string. Also removes
	   // consecutive spaces and replaces it with one space. If something besides
	   // a string is passed in (null, custom object, etc.) then return the input.
	   if (typeof inputString != "string") { return inputString; }
	   var retValue = inputString;
	   var ch = retValue.substring(0, 1);
	   while (ch == " ") { // Check for spaces at the beginning of the string
	      retValue = retValue.substring(1, retValue.length);
	      ch = retValue.substring(0, 1);
	   }
	   ch = retValue.substring(retValue.length-1, retValue.length);
	   while (ch == " ") { // Check for spaces at the end of the string
	      retValue = retValue.substring(0, retValue.length-1);
	      ch = retValue.substring(retValue.length-1, retValue.length);
	   }
	   while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
	      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
	   }
	   return retValue; // Return the trimmed string back to the user
} // Ends the "trim" function


/*****************************************************************/
function ValidateNo(NumStr, String){    
	for(var Idx=0; Idx<NumStr.length; Idx++)    
	{        
		var Char = NumStr.charAt(Idx);        
		var Match = false;        
		
		for(var Idx1=0; Idx1<String.length; Idx1++)        
		{            
			if(Char == String.charAt (Idx1))                
			Match = true;        
		}        
		if (!Match)            
			return false;    
		}    
	return true;
} 

function validateEmail(elementValue){      
   var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
   return emailPattern.test(elementValue); 
 }

 function ValidateNo(NumStr, String){    
	for(var Idx=0; Idx<NumStr.length; Idx++)    
	{        
		var Char = NumStr.charAt(Idx);        
		var Match = false;        
		
		for(var Idx1=0; Idx1<String.length; Idx1++)        
		{            
			if(Char == String.charAt (Idx1))                
			Match = true;        
		}        
		if (!Match)            
			return false;    
		}    
	return true;
} 


function validateRegistration(theForm) {

	if (trim(theForm.fname.value)==""){ 
		alert("Please enter your FIRST NAME!");
		return;
	}

	if (trim(theForm.lname.value)==""){ 
		alert("Please enter your LAST NAME!");
		return;
	}

	if(!ValidateNo(trim(theForm.phone.value),"1234567890-") || (trim(theForm.phone.value)==""))    
	{   
		alert("Please Enter your PHONE NUMBER in the format: nnn-nnn-nnnn!");        
		return;
	}
	
	if (!validateEmail(trim(theForm.email.value))){
		alert("Please enter a VALID EMAIL ADDRESS!");
		return;
	}
	
	pwd = trim(theForm.sm_password.value);
	if (pwd.length < 6) {
		alert("Your PASSWORD must be at least 6 chars!");
		return;
	}
	
	if (trim(theForm.sm_password_reenter.value) != trim(theForm.sm_password.value)) {
		alert("PASWORDS must match!");
		return;
	}
	
	theForm.submit()
}


function validateOrder(theForm) {
	
	if (trim(theForm.bill_address.value)==""){ 
		alert("Please enter your BILLING ADDRESS!");
		return;
	}

	if (trim(theForm.bill_city.value)==""){ 
		alert("Please enter your BILLING CITY!");
		return;
	}
	
	if ((trim(theForm.bill_state.value)=="") && (trim(theForm.bill_prov.value)=="")){ 
		alert("Please enter your BILLING STATE or PROVINCE!");
		return;
	}

	if (trim(theForm.bill_ZIP.value)==""){ 
		alert("Please enter your BILLING ZIP/POSTAL CODE!");
		return;
	}
	
	if (trim(theForm.bill_country.value)==""){ 
		alert("Please enter your BILLING COUNTRY!");
		return;
	}

	if (theForm.chkPhysicalMaster.checked) {
	
		if (trim(theForm.ship_address.value)==""){ 
			alert("Please enter your SHIPPING ADDRESS!");
			return;
		}
	
		if (trim(theForm.ship_city.value)==""){ 
			alert("Please enter your SHIPPING CITY!");
			return;
		}
		
		if ((trim(theForm.ship_state.value)=="") && (trim(theForm.ship_prov.value)=="")){ 
			alert("Please enter your SHIPPING STATE or PROVINCE!");
			return;
		}
	
		if (trim(theForm.ship_ZIP.value)==""){ 
			alert("Please enter your SHIPPING ZIP/POSTAL CODE!");
			return;
		}
		
		if (trim(theForm.ship_country.value)==""){ 
			alert("Please enter your SHIPPING COUNTRY!");
			return;
		}

	}
	
	theForm.submit()
}


function addTrack(theForm) {
		
	/*
	sFile = theForm.NewFile.value;
	
	if (trim(sFile)==""){ 
		alert("Please select a TRACK FILE!");
		return;
	}
	
	if ( (sFile.lastIndexOf(".wav")==-1) && (sFile.lastIndexOf(".sdii")==-1) && (sFile.lastIndexOf(".sd2")==-1) && (sFile.lastIndexOf(".aiff")==-1) && (sFile.lastIndexOf(".aif")==-1)) {
   		alert("Please upload only .wav, .sdii, .sd2, or .aiff/.aif");
		return;
	}
	*/
		
	if (trim(theForm.track_title.value)==""){ 
		alert("Please enter the TRACK TITLE!");
		return;
	}

	if (trim(theForm.artist_title.value)==""){ 
		alert("Please enter the ARTIST TITLE!");
		return;
	}

	if ((theForm.lstminutes.value=="0") && (theForm.lstseconds.value=="0")) { 
		alert("Please enter the TRACK TIME!");
		return;
	}

	//theForm.encoding='multipart/form-data';
	theForm.action='add_track.asp?mode=add';
	theForm.submit();
}

function editTrack(theForm) {
		
	/*
	sFile = theForm.NewFile.value;
	
	if (trim(sFile)==""){ 
		alert("Please select a TRACK FILE!");
		return;
	}
	
	if ( (sFile.lastIndexOf(".wav")==-1) && (sFile.lastIndexOf(".sdii")==-1) && (sFile.lastIndexOf(".sd2")==-1) && (sFile.lastIndexOf(".aiff")==-1) && (sFile.lastIndexOf(".aif")==-1)) {
   		alert("Please upload only .wav, .sdii, .sd2, or .aiff/.aif");
		return;
	}
	*/
		
	if (trim(theForm.track_title.value)==""){ 
		alert("Please enter the TRACK TITLE!");
		return;
	}

	if (trim(theForm.artist_title.value)==""){ 
		alert("Please enter the ARTIST TITLE!");
		return;
	}

	if ((theForm.lstminutes.value=="0") && (theForm.lstseconds.value=="0")) { 
		alert("Please enter the TRACK TIME!");
		return;
	}

	theForm.submit();
}

function validateOrder2(theForm) {

	if (trim(theForm.album_title.value)==""){ 
		alert("Please enter the ALBUM TITLE!");
		return;
	}

	if (trim(theForm.album_artist.value)==""){ 
		alert("Please enter the ALBUM ARTIST!");
		return;
	}

	theForm.action='order3.asp?mode=start';
	theForm.submit();
}
 
function finalizeOrder(theForm) {

	if (trim(theForm.cctype.value)==""){ 
		alert("Please enter your CARD TYPE");
		return;
	}

	if (trim(theForm.x_card_num.value)==""){ 
		alert("Please enter your CARD NUMBER");
		return;
	}	
	
	if (trim(theForm.expmonth.value)==""){ 
		alert("Please enter your EXPIRATION MONTH");
		return;
	}
	
	if (trim(theForm.expyear.value)==""){ 
		alert("Please enter your EXPIRATION YEAR");
		return;
	}
	
	if (trim(theForm.x_card_code.value)==""){ 
		alert("Please enter your CARD VERIFICATION NUMBER");
		return;
	}
	
	if ((trim(theForm.cctype.value)=="A") && (trim(theForm.x_card_code.value).length!==4) && (!ValidateNo(trim(theForm.x_card_code.value),"1234567890"))){
		alert("AMERICAN EXPRESS CVN numbers are 4 digits!");
		return;
	}

	if ((trim(theForm.cctype.value)!=="A") && (trim(theForm.x_card_code.value).length!==3) && (!ValidateNo(trim(theForm.x_card_code.value),"1234567890"))){
		alert("VISA, MASTERCARD, and DISCOVER CVN numbers are 3 digits!");
		return;
	}
	

	/*
	if (!ValidateNo(trim(theForm.chargetotal.value),"1234567890.")){ 
		alert("Please enter a VALID DOLLAR AMOUNT!");
		return;
	}
	*/
	
	if (CheckCardNumber(theForm)) { 
		theForm.x_amount.disabled=false;	
		theForm.x_exp_date.value = theForm.expmonth.value + theForm.expyear.value			
		theForm.submit()
	}
	
}


var Cards = new makeArray(8);
Cards[0] = new CardType("MasterCard", "51,52,53,54,55", "16");
var MasterCard = Cards[0];
Cards[1] = new CardType("VisaCard", "4", "13,16");
var VisaCard = Cards[1];
Cards[2] = new CardType("AmExCard", "34,37", "15");
var AmExCard = Cards[2];
Cards[3] = new CardType("DinersClubCard", "30,36,38", "14");
var DinersClubCard = Cards[3];
Cards[4] = new CardType("DiscoverCard", "6011", "16");
var DiscoverCard = Cards[4];
Cards[5] = new CardType("enRouteCard", "2014,2149", "15");
var enRouteCard = Cards[5];
Cards[6] = new CardType("JCBCard", "3088,3096,3112,3158,3337,3528", "16");
var JCBCard = Cards[6];
var LuhnCheckSum = Cards[7] = new CardType();

/*************************************************************************\
CheckCardNumber(form)
function called when users click the "check" button.
\*************************************************************************/
function CheckCardNumber(form) {
var tmpyear;

if (form.expyear.value > 96)
tmpyear = "19" + form.expyear.value;
else if (form.expyear.value < 21)
tmpyear = "20" + form.expyear.value;
else {
alert("The Expiration Year is not valid.");
return;
}
tmpmonth = form.expmonth.options[form.expmonth.selectedIndex].value;
// The following line doesn't work in IE3, you need to change it
// to something like "(new CardType())...".
// if (!CardType().isExpiryDate(tmpyear, tmpmonth)) {
if (!(new CardType()).isExpiryDate(tmpyear, tmpmonth)) {
alert("This card has already expired.");
return;
}

if (form.cctype.options[form.cctype.selectedIndex].value=="A") {
	card = "AmExCard"
}
if (form.cctype.options[form.cctype.selectedIndex].value=="V") {
	card = "VisaCard"
}
if (form.cctype.options[form.cctype.selectedIndex].value=="M") {
	card = "MasterCard"
}
if (form.cctype.options[form.cctype.selectedIndex].value=="D") {
	card = "DiscoverCard"
}

var retval = eval(card + ".checkCardNumber(\"" + form.x_card_num.value +
"\", " + tmpyear + ", " + tmpmonth + ");");
cardname = "";
if (retval) {



// comment this out if used on an order form
//alert("This card number appears to be valid.");
return true;

}
else {
// The cardnumber has the valid luhn checksum, but we want to know which
// cardtype it belongs to.
for (var n = 0; n < Cards.size; n++) {
if (Cards[n].checkCardNumber(form.x_card_num.value, tmpyear, tmpmonth)) {
cardname = Cards[n].getCardType();
break;
   }
}
if (cardname.length > 0) {
alert("This looks like a " + cardname + " number, not a " + card + " number.");
}
else {
alert("This card number is not valid.");
return false;
      }
   }
}
/*************************************************************************\
Object CardType([String cardtype, String rules, String len, int year, 
                                        int month])
cardtype    : type of card, eg: MasterCard, Visa, etc.
rules       : rules of the cardnumber, eg: "4", "6011", "34,37".
len         : valid length of cardnumber, eg: "16,19", "13,16".
year        : year of expiry date.
month       : month of expiry date.
eg:
var VisaCard = new CardType("Visa", "4", "16");
var AmExCard = new CardType("AmEx", "34,37", "15");
\*************************************************************************/
function CardType() {
var n;
var argv = CardType.arguments;
var argc = CardType.arguments.length;

this.objname = "object CardType";

var tmpcardtype = (argc > 0) ? argv[0] : "CardObject";
var tmprules = (argc > 1) ? argv[1] : "0,1,2,3,4,5,6,7,8,9";
var tmplen = (argc > 2) ? argv[2] : "13,14,15,16,19";

this.setCardNumber = setCardNumber;  // set CardNumber method.
this.setCardType = setCardType;  // setCardType method.
this.setLen = setLen;  // setLen method.
this.setRules = setRules;  // setRules method.
this.setExpiryDate = setExpiryDate;  // setExpiryDate method.

this.setCardType(tmpcardtype);
this.setLen(tmplen);
this.setRules(tmprules);
if (argc > 4)
this.setExpiryDate(argv[3], argv[4]);

this.checkCardNumber = checkCardNumber;  // checkCardNumber method.
this.getExpiryDate = getExpiryDate;  // getExpiryDate method.
this.getCardType = getCardType;  // getCardType method.
this.isCardNumber = isCardNumber;  // isCardNumber method.
this.isExpiryDate = isExpiryDate;  // isExpiryDate method.
this.luhnCheck = luhnCheck;// luhnCheck method.
return this;
}

/*************************************************************************\
boolean checkCardNumber([String cardnumber, int year, int month])
return true if cardnumber pass the luhncheck and the expiry date is
valid, else return false.
\*************************************************************************/
function checkCardNumber() {
var argv = checkCardNumber.arguments;
var argc = checkCardNumber.arguments.length;
var cardnumber = (argc > 0) ? argv[0] : this.cardnumber;
var year = (argc > 1) ? argv[1] : this.year;
var month = (argc > 2) ? argv[2] : this.month;

this.setCardNumber(cardnumber);
this.setExpiryDate(year, month);

if (!this.isCardNumber())
return false;
if (!this.isExpiryDate())
return false;

return true;
}
/*************************************************************************\
String getCardType()
return the cardtype.
\*************************************************************************/
function getCardType() {
return this.cardtype;
}
/*************************************************************************\
String getExpiryDate()
return the expiry date.
\*************************************************************************/
function getExpiryDate() {
return this.month + "/" + this.year;
}
/*************************************************************************\
boolean isCardNumber([String cardnumber])
return true if cardnumber pass the luhncheck and the rules, else return
false.
\*************************************************************************/
function isCardNumber() {
var argv = isCardNumber.arguments;
var argc = isCardNumber.arguments.length;
var cardnumber = (argc > 0) ? argv[0] : this.cardnumber;
if (!this.luhnCheck())
return false;

for (var n = 0; n < this.len.size; n++)
if (cardnumber.toString().length == this.len[n]) {
for (var m = 0; m < this.rules.size; m++) {
var headdigit = cardnumber.substring(0, this.rules[m].toString().length);
if (headdigit == this.rules[m])
return true;
}
return false;
}
return false;
}

/*************************************************************************\
boolean isExpiryDate([int year, int month])
return true if the date is a valid expiry date,
else return false.
\*************************************************************************/
function isExpiryDate() {
var argv = isExpiryDate.arguments;
var argc = isExpiryDate.arguments.length;

year = argc > 0 ? argv[0] : this.year;
month = argc > 1 ? argv[1] : this.month;

if (!isNum(year+""))
return false;
if (!isNum(month+""))
return false;
today = new Date();
expiry = new Date(year, month);
if (today.getTime() > expiry.getTime())
return false;
else
return true;
}

/*************************************************************************\
boolean isNum(String argvalue)
return true if argvalue contains only numeric characters,
else return false.
\*************************************************************************/
function isNum(argvalue) {
argvalue = argvalue.toString();

if (argvalue.length == 0)
return false;

for (var n = 0; n < argvalue.length; n++)
if (argvalue.substring(n, n+1) < "0" || argvalue.substring(n, n+1) > "9")
return false;

return true;
}

/*************************************************************************\
boolean luhnCheck([String CardNumber])
return true if CardNumber pass the luhn check else return false.
\*************************************************************************/
function luhnCheck() {
var argv = luhnCheck.arguments;
var argc = luhnCheck.arguments.length;

var CardNumber = argc > 0 ? argv[0] : this.cardnumber;

if (! isNum(CardNumber)) {
return false;
  }

var no_digit = CardNumber.length;
var oddoeven = no_digit & 1;
var sum = 0;

for (var count = 0; count < no_digit; count++) {
var digit = parseInt(CardNumber.charAt(count));
if (!((count & 1) ^ oddoeven)) {
digit *= 2;
if (digit > 9)
digit -= 9;
}
sum += digit;
}
if (sum % 10 == 0)
return true;
else
return false;
}

/*************************************************************************\
ArrayObject makeArray(int size)
return the array object in the size specified.
\*************************************************************************/
function makeArray(size) {
this.size = size;
return this;
}

/*************************************************************************\
CardType setCardNumber(cardnumber)
return the CardType object.
\*************************************************************************/
function setCardNumber(cardnumber) {
this.cardnumber = cardnumber;
return this;
}

/*************************************************************************\
CardType setCardType(cardtype)
return the CardType object.
\*************************************************************************/
function setCardType(cardtype) {
this.cardtype = cardtype;
return this;
}

/*************************************************************************\
CardType setExpiryDate(year, month)
return the CardType object.
\*************************************************************************/
function setExpiryDate(year, month) {
this.year = year;
this.month = month;
return this;
}

/*************************************************************************\
CardType setLen(len)
return the CardType object.
\*************************************************************************/
function setLen(len) {
// Create the len array.
if (len.length == 0 || len == null)
len = "13,14,15,16,19";

var tmplen = len;
n = 1;
while (tmplen.indexOf(",") != -1) {
tmplen = tmplen.substring(tmplen.indexOf(",") + 1, tmplen.length);
n++;
}
this.len = new makeArray(n);
n = 0;
while (len.indexOf(",") != -1) {
var tmpstr = len.substring(0, len.indexOf(","));
this.len[n] = tmpstr;
len = len.substring(len.indexOf(",") + 1, len.length);
n++;
}
this.len[n] = len;
return this;
}

/*************************************************************************\
CardType setRules()
return the CardType object.
\*************************************************************************/
function setRules(rules) {
// Create the rules array.
if (rules.length == 0 || rules == null)
rules = "0,1,2,3,4,5,6,7,8,9";
  
var tmprules = rules;
n = 1;
while (tmprules.indexOf(",") != -1) {
tmprules = tmprules.substring(tmprules.indexOf(",") + 1, tmprules.length);
n++;
}
this.rules = new makeArray(n);
n = 0;
while (rules.indexOf(",") != -1) {
var tmpstr = rules.substring(0, rules.indexOf(","));
this.rules[n] = tmpstr;
rules = rules.substring(rules.indexOf(",") + 1, rules.length);
n++;
}
this.rules[n] = rules;
return this;
}

function filterName(str) {
     re = /\$|,|@|#|~|`|\%|\*|\^|\&|\(|\)|\+|\=|\[|\-|\_|\]|\[|\}|\{|\;|\:|\'|\"|\<|\>|\?|\||\\|\!|\$|\./g;
     // remove special characters like "$" and "," etc...
     return str.replace(re, "");
}	
	 
function checkfileType(theForm) {  

   for(i=0; i<document.forms[0].elements.length; i++){
	   //alert(document.forms[0].elements[i].type)	   
	   if (document.forms[0].elements[i].type == "file") {
	   		sFile = document.forms[0].elements[i].value
			//sFile=filterName(sFile)		
			
			if ( (sFile.lastIndexOf(".wav")==-1) && (sFile.lastIndexOf(".aif")==-1) && (sFile.lastIndexOf(".aiff")==-1) && (sFile.lastIndexOf(".sd2")==-1) && (sFile.lastIndexOf(".bwf")==-1) ) {
		   		alert("Please upload only .wav, .aif, .aiff, .sd2, or .bwf");
				document.forms[0].elements[i].value = '';
				return;
			}
	   }
   
   }
	//theForm.encoding='multipart/form-data';
	//theForm.action='upload.asp';
	
	document.forms[0].submit();
	ShowProgress();
}

function validateMessage(theForm) {

	if (trim(theForm.txtname.value)==""){ 
		alert("Please enter a first name!");
		return;
	}

	if (trim(theForm.txtphone.value)==""){ 
		alert("Please enter phone number!");
		return;
	}

	if (trim(theForm.txtemail.value)==""){ 
		alert("Please enter an Email address");
		return;
	}
		if (trim(theForm.txtsubject.value)==""){ 
		alert("Please enter a Subject!");
		return;
	}

	if (trim(theForm.txtmessage.value)==""){ 
		alert("Please enter a message!");
		return;
	}

	theForm.submit()
}

