
function cEnterKey(evt,f)
{ 	
	if (!e) var e = window.event;

	if (e==undefined){
		var element;
		element = evt.target || evt.srcElement 
		if(element.name=="txtSearch" && evt.which == 13){eval (f)}
		if(element.name=="pswPass" && evt.which == 13){eval (f)}
		if(element.name=="btnLoginAcct" && evt.which == 13){eval (f)}
		if(element.name=="btnAdminLogin" && evt.which == 13){eval (f)}
		if(element.name=="txtAdminPass" && evt.which == 13){eval (f)}	
		if(element.name=="txtPass2" && evt.which == 13){eval (f)}		
		
	}
	else{
		var element;
		element = evt.target || evt.srcElement 
		if(element.name=="txtSearch" && evt.keyCode == 13){eval (f)}
		if(element.name=="pswPass" && evt.keyCode == 13){eval (f)}
		if(element.name=="btnLoginAcct" && evt.keyCode == 13){eval (f)}
		if(element.name=="btnAdminLogin" && evt.keyCode == 13){eval (f)}
		if(element.name=="txtAdminPass" && evt.keyCode == 13){eval (f)}
		if(element.name=="txtPass2" && evt.keyCode == 13){eval (f)}
	}
	
return
}

function cHelp(i){
	var url = "phelp.asp?i=" + i

	var width = 350
	var height = 250
	var left= 400
	var top = 300

	var handle =   window.open(url, 'Help',"scrollbars=yes,left=" + left  + ",top="  + top + ",height=" + height + ",width=" + width + ",location=no,menubar=no,resizable=yes,status=no,toolbar=no"); 
   // Children.push(handle);
//		handle.focus();
//		return handle;

}

function cChat(){

	var url = "chat.asp"
	var name = "Chat"
	var width = 600
	var height = 440
	var x = 200
	var y = 200
	var handle =  window.open(url, name,"scrollbars=yes,top=" + x + ",screenY=" + y + ",directories=0,height=" + height + ",width=" + width + ",location=no,menubar=no,resizable=yes,status=no,toolbar=no"); +
		handle.focus();
		return handle;

}

function cFow(f){

	var url = "default.asp"
	var name = "test"
	var width = 100
	var height = 100

	var handle =   window.open(url, name,"scrollbars=yes,screenX=25,screenY=25,directories=0,height=" + height + ",width=" + width + ",location=no,menubar=no,resizable=yes,status=no,toolbar=no"); +
	   Children.push(handle);
		handle.focus();
		return handle;
}

function cTextCounter(field,cntfield,maxlimit) {
	if (field.value.length > maxlimit) // if too long...trim it!
		field.value = field.value.substring(0, maxlimit);
	// otherwise, update 'characters left' counter
	else
		cntfield.value = maxlimit - field.value.length;
}
	
function cOnLoad(){
	try{
		//getElementById_s('txtSearch').focus()
		if (window.pOnLoad){
			pOnLoad()
		}
	}
	catch(e){}
}

function GetNavState(){
	//alert(cRCookie('catExpand'))
}


function cShowWait(){
	//getElementById_s('headerwait').style.display=""
}

function cPopH(ai_index)
{
	var nLeft;
	var nTop;
	var	nHeight;
	var nWidth;
	
	nHeight=400;
	nWidth=400;

	nLeft = window.screen.availWidth ;
	nTop = window.screen.availHeight ;
	nLeft=(nLeft-nWidth)/2;
	nTop=(nTop-nHeight)/2;

	wChildWindow = window.open("pop_help.asp?i=" + ai_index,"","top=" + nTop + ",left=" + nLeft + ",height=" + nHeight + ",width=" + nWidth + ",status=no,resizable=yes,toolbar=no,menubar=no,scrollbars=no,location=no,titlebar=no");
	//wChildWindow = window.open("help_pop.asp","","top=1,left=1,height=200,width=200,status=no,resizable=yes,toolbar=no,menubar=no,scrollbars=no,location=no,titlebar=no");

	wChildWindow.focus();
	return true;

}

function cURLencode(sStr) {
   return escape(sStr)
      .replace(/\+/g, '%2B')
         .replace(/\"/g,'%22')
            .replace(/\'/g, '%27');
}


function cCCookie(name,value,days) {

	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function cRCookie(name) {

	var nameEQ = name + "=";
	var ca = document.cookie.split(';');


	for(var i=0;i < ca.length;i++) {
 		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0){
			 return c.substring(nameEQ.length,c.length);
		}
	}

	return null;
}

function cValidCC(ccNumb) {  // v2.0
	var valid = "0123456789"  // Valid digits in a credit card number
	var len = ccNumb.length;  // The length of the submitted cc number
	var iCCN = parseInt(ccNumb);  // integer of ccNumb
	var sCCN = ccNumb.toString();  // string of ccNumb
	sCCN = sCCN.replace (/^\s+|\s+$/g,'');  // strip spaces
	var iTotal = 0;  // integer total set at zero
	var bNum = true;  // by default assume it is a number
	var bResult = false;  // by default assume it is NOT a valid cc
	var temp;  // temp variable for parsing string
	var calc;  // used for calculation of each digit

	// Determine if the ccNumb is in fact all numbers
	for (var j=0; j<len; j++) {
	  temp = "" + sCCN.substring(j, j+1);
	  if (valid.indexOf(temp) == "-1"){bNum = false;}
	}

	// if it is NOT a number, you can either alert to the fact, or just pass a failure
	if(!bNum){
	  /*alert("Not a Number");*/bResult = false;
	}

	// Determine if it is the proper length 
	if((len == 0)&&(bResult)){  // nothing, field is blank AND passed above # check
	  bResult = false;
	} else{  // ccNumb is a number and the proper length - let's see if it is a valid card number
	  if(len >= 15){  // 15 or 16 for Amex or V/MC
	    for(var i=len;i>0;i--){  // LOOP throught the digits of the card
	      calc = parseInt(iCCN) % 10;  // right most digit
	      calc = parseInt(calc);  // assure it is an integer
	      iTotal += calc;  // running total of the card number as we loop - Do Nothing to first digit
	      i--;  // decrement the count - move to the next digit in the card
	      iCCN = iCCN / 10;                               // subtracts right most digit from ccNumb
	      calc = parseInt(iCCN) % 10 ;    // NEXT right most digit
	      calc = calc *2;                                 // multiply the digit by two
	      // Instead of some screwy method of converting 16 to a string and then parsing 1 and 6 and then adding them to make 7,
	      // I use a simple switch statement to change the value of calc2 to 7 if 16 is the multiple.
	      switch(calc){
		case 10: calc = 1; break;       //5*2=10 & 1+0 = 1
		case 12: calc = 3; break;       //6*2=12 & 1+2 = 3
		case 14: calc = 5; break;       //7*2=14 & 1+4 = 5
		case 16: calc = 7; break;       //8*2=16 & 1+6 = 7
		case 18: calc = 9; break;       //9*2=18 & 1+8 = 9
		default: calc = calc;           //4*2= 8 &   8 = 8  -same for all lower numbers
	      }                                               
	    iCCN = iCCN / 10;  // subtracts right most digit from ccNum
	    iTotal += calc;  // running total of the card number as we loop
	  }  // END OF LOOP
	  if ((iTotal%10)==0){  // check to see if the sum Mod 10 is zero
	    bResult = true;  // This IS (or could be) a valid credit card number.
	  } else {
	    bResult = false;  // This could NOT be a valid credit card number
	    }
	  }
	}
	// change alert to on-page display or other indication as needed.
	if(bResult) {
	 // alert("This IS a valid Credit Card Number!");
	}
	if(!bResult){
	  //alert("This is NOT a valid Credit Card Number!");
	}
  return bResult; // Return the results
}

function cECookie(name) {
	cCCookie(name,"",-1);
}

function cSearchOnFocus(e){
    if (e.value=='Quick Search'){
        e.value=''
    }
}
