var path = '/';

function showWin(which,parm,parm1)
{
	var newwinname = '_' + which;
	switch (which) {
		case 'upLoad': 	
			opts = 'menubar=0,location=0,status=0,scrollbars=1,toolbar=0,width=450,height=340';
			LinkURL = 'UpLoadFile.asp?up='+parm + '&val='+parm1;
			break;
	}

	thiswin = window.open(LinkURL, newwinname, opts );
	thiswin.focus();
	
}

function inValidCharacters(str,charset)
{
	var result = false;
	for (var i=0;i<str.length;i++)
		if (charset.indexOf(str.substr(i,1))>-1)
		{	result = true;
			break;
		}
	return result;
}

function ValidateEmail(em,emtype) {
		if (em == "") 
			return "\n     - " + emtype + " Email Address" ;
		else {
			if (em.length < 6 || em.indexOf('@')==-1 || em.indexOf('@')==0 || em.indexOf('.')==-1 || em.indexOf('http') > 0) 
				return "\n     -  Invalid " + emtype + " Email Address";
			else
				return '';
		}	
}		

function checkContact( path )	{

	var msg='';
	if ( path.YourName.value == "" )
		msg += '\n     -  Your Name' ;

	msg += ValidateEmail(path.Email.value,'');

	if ( path.Message.value == "" )
		msg += '\n     -  Message text' ;

	if (msg != "") {
		msg ="\n" +
			 "The following fields must be filled in or corrected\n" +
			 msg + "\n" +
			 "\nPlease re-enter ";
		alert(msg);
		return false;
	}
	else return true;
}

function checkAddress(path) {
	var msg = "";
	if (path.FirstName.value == "")
		 msg += '\n     -  First Name' ;
	if ( path.LastName.value == "" )
		 msg += '\n     -  Last Name' ;
	if ( path.Address.value == "" )
		 msg += '\n     -  Address' ;
	if ( path.City.value == "" )
		 msg += '\n     -  City' ;
	if (trim(path.State.value) == "" && (path.Country.value == "USA" || path.Country.value == "Canada" )) 
			msg += "\n     -  State";
	if ( path.ZipCode.value == "" )
		 msg += '\n     -  Zip Code' ;
	if ( path.Country.value == "" )
		 msg += '\n     -  Country' ;
	if ( path.Phone.value == "" )
		 msg += '\n     -  Phone' ;

	msg += ValidateEmail(path.Email.value,'') ;
	
	if ( path.sut.value > 1){
		if (path.FirstNameG.value == "")
			 msg += '\n     -  Gift to First Name' ;
		if ( path.LastNameG.value == "" )
		 	msg += '\n     -  Gift to Last Name' ;
		msg += ValidateEmail(path.EmailG.value,' Gift to') ;	
		if ( path.FromFirstName.value == "" )
		 	msg += '\n     -  Gift From First Name' ;
		if ( path.FromLastName.value == "" )
		 	msg += '\n     -  Gift From Last Name' ;
		if ( path.GiftNote.value == "" )
		 	msg += '\n     -  Gift Note' ;
	}
	
	if ( msg != "" )	   	
		{	msg = 'Please fill in the following field(s)\n' + msg;
			alert(msg);
			return false
		}
	else {
		return true; 
	}
}

function checkAffiliateType(form) {
	var msg = "";
	if (path.PayTo.value == "")
		 msg += '\n     -  Pay To Name' ;
	if ( path.TaxId.value == "" )
		 msg += '\n     -  Taxpayer Id' ;
	if ( path.TaxType.value == "" )
		 msg += '\n     -  Taxpayer Id Type' ;
	if ( path.BusinessType.value == "" )
		 msg += '\n     -  Business Type' ;
	if ( msg != "" )	   	
		{	msg = 'Please fill in the following field(s)\n' + msg;
			alert(msg);
			return false
		}
	else return true; 
}


function stripscript(theField)	{

	var astr = theField.value;
	astr = astr.replace(/script/gi, '');
	astr = astr.replace(/.js/gi, '');
	astr = astr.replace(/http/gi, '');
	astr = astr.replace(/</g, '');
	astr = astr.replace(/>/g, '');
	theField.value = astr;
}
