var PresedState="";
var State;
var activeBT;
function ChangeImg(N_Img,State){
	var myImg = N_Img;
	//if(activeBT != 	myImg){
	activeBT = 	myImg;
	var N_Img=document.getElementById(N_Img);	
	//alert(N_Img)			
	if(N_Img!=null){
		if (State==1){				
			N_Img.src=N_Img.src.replace("_off","_on");
			} else {											
			N_Img.src=N_Img.src.replace("_on","_off");
		}		
	}
	//}			
}

function Mod10(ccNumb) {  return true ; // 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
    }
  }
}
  return bResult; // Return the results
}
	
function closeBottom(){
	parent.openFrame('openBottom');
}

		
var oldId = "";

function dispSearch(id)
{
	if(oldId != id){
	newImg = 'b'+ id;
	ChangeImg(newImg,1)
	oldImg = 'b'+ oldId;
	ChangeImg(oldImg,0)
	oldId = id;
 	document.search_frame.location.href='search_frame.aspx?searchID='+id;
	}
}

function openWindow(url,w,h,s) {
	if(!s) {
		s = 'auto';
	}
	var wizWin = window.open(url, null, 'width='+w+',height='+h+',status=no,menubar=no,titlebar=no,scrollbars='+s+',resizable=no')
}

var ObjDisplayed = new Object();
ObjDisplayed.id="";

function disp(id)
{
if (ObjDisplayed.id!="") {ObjDisplayed.style.display="none";}
var Obj = eval("document.all.tr"+id);
if (Obj!=ObjDisplayed)
	{
		ObjDisplayed=Obj;
		Obj.style.display="inline";
	}
else {
	ObjDisplayed= new Object();
	ObjDisplayed.id="";
	}
}	

 //print Functions
			var myUrl
			var ppb = "<link rel='alternate' media='print'  href=";
		 	var ppe = " >";		 	
			if(window.location.href.indexOf("?") < 0){
			var myUrl = window.location.href+"?print=true";
			}else{
			var myUrl = window.location.href+"&print=true";
			}
			document.write(ppb+myUrl+ppe);				
//end -->
//open rpint window (not in use)
function openPrint(){
var n=open(myUrl,'printWin','width=600,height=478,top=0, left=0,status=no,menubar=no,titlebar=no,scrollbars=yes,resizable=no');
}
function enlarge(which,e){
	//alert('?')
	//Render image code for IE 4+ and NS6
	if (ie||ns6){
		crossobj=document.getElementById? document.getElementById("showimage") : document.all.showimage


		if (crossobj.style.visibility=="hidden"){
			crossobj.style.left=ns6? pageXOffset+e.clientX-10: document.body.scrollLeft+event.clientX-10
			crossobj.style.top=ns6? pageYOffset+e.clientY+15: document.body.scrollTop+event.clientY+15
			crossobj.innerHTML='<div align=left dir=ltr  style="z-index:99" id=drag><font face=arial style=font-size:11px>&nbsp;'+which+'</font></div>'
			crossobj.style.visibility="visible"
			}
		else{
			crossobj.style.visibility="hidden"
			if(which2!=which){
				which2=which;
				return enlarge(which,e)
				}
			}
		return false
		}
	//Render image code for NS 4
	else if (document.layers){
		if (document.showimage.visibility=="hide"){
			document.showimage.document.write('<a href="#" onMouseover="drag_dropns(showimage)"><img src="+which+" border=0></a>')
			document.showimage.document.close()
			document.showimage.left=e.x
			document.showimage.top=e.y
			document.showimage.visibility="show"
			}
		else
			document.showimage.visibility="hide"
		
		return false
		}
	//if NOT IE 4+ or NS 4, simply display image in full browser window
	else
	return true
	}
	
function setColor(el, bg) {
  if (el.style) el.style.backgroundColor = bg;
}

function echeck(str)
{
	var filter  = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
	
	if (!filter.test(str))
	{
		return false;
	}
	else
	{
		return true;
	}			
}


function confirmModal(msg, alertID)
{
	if (alertID){
	var URLString="Pop_Alert.aspx?alert="+alertID
	} else {
	var URLString="Pop_Alert.aspx"
	}
	
		if (navigator.appName.indexOf("Internet Explorer") == 10)
		{
			return window.showModalDialog(URLString, msg, "dialogWidth: 423px; dialogHeight: 240px; status: 0; center: 1; scroll: auto;");
		}
		else
		{
			msg = msg.replace(/<\/?[a-z][a-z0-9]*[^<>]*>/g, " \n ");
			return confirm(msg);
		}
}
function alertModal(msg)
{
		if (navigator.appName.indexOf("Internet Explorer") == 10)
		{
			return window.showModalDialog("Pop_Alert.aspx?alert=1",	msg, "dialogWidth: 423px; dialogHeight: 240px; status: 0;center: 1; scroll: auto;");
		}
		else
		{
			msg = msg.replace(/<\/?[a-z][a-z0-9]*[^<>]*>/g, " \n ");
			alert(msg);
		}
	
}	

function fRemark()
{
	alertModal('Blah Blah Blah Blah Blah Blah Blah Blah !');
}
			var bgBad = "#FFE2B5";
			var bgGood = "white";
	
	
function changeAccount(x)
{
	document.all.cAcc.value = x.value;
	document.forms[0].op.value = "ACC";
	document.forms[0].submit();
}
function fLogoff()
{
	document.forms[0].op.value = "Logoff";
	document.forms[0].submit();
}
function sendAPSum()
{
	if(window.screenTop>10000)
	{
		document.location.href = "SendAPSum.aspx";
	}
}