﻿// JScript File

function find_by_id(id) {

	var identity=document.getElementById(id);

	if (!identity) {
		alert(">" + id + "<")
	} else {
	    return identity;
    }

}

function rolloverServerControl_display(imgName, imgImage) {
   document.getElementById(imgName).src = imgImage.src;
}

function CheckButton(id,type,value1,value2) {
//alert("test" + id + " " + type + " " + value1 + " " + value2);
    switch(type.toLowerCase()) {
		case 'equal':
		    if (value1 == value2) {
		        EnableButton(id);
		    } else {
		        DisableButton(id);
		    }
	        break;	
		case 'notequal':
		    if (value1 != value2) {
		        EnableButton(id);
		    } else {
		        DisableButton(id);
		    }
	        break;	
	};

}

function DisableButton(id) {
alert('test2');
    document.getElementById(id).style.display="none"
    document.getElementById(id & "D").style.display="block"
    //document.getElementById(id).enabled=true;
}

function EnableButton(id) {
alert('test3');
    document.getElementById(id).style.display="block"
    document.getElementById(id & "D").style.display="none"
    //document.getElementById(id).enabled=false;
}

function ChangeStyle(id, newClass) {

	var identity=find_by_id(id);

	identity.className=newClass;
}

function ChangeInner(id, NewValue) {

var identity=find_by_id(id);

identity.innerHTML = NewValue;

}

function imageswap(t_strID,t_strURL) {

var identity=find_by_id(t_strID);

identity.src = t_strURL;

}

function ShowDiv(t_strOuterID,t_strInnerID,t_strShowID,t_strHideID,t_lngTargetHeight) {
    
    document.getElementById(t_strShowID).style.display="none"
    document.getElementById(t_strInnerID).style.display="none"
    document.getElementById(t_strOuterID).style.height="10px"
    document.getElementById(t_strOuterID).style.display="block"
    setTimeout('ChangeSize("' + t_strOuterID + '",10,' + t_lngTargetHeight + ',10,"' + t_strInnerID + '","' + t_strHideID + '");',1)     
}

function HideDiv(t_strOuterID,t_strInnerID,t_strShowID,t_strHideID,t_lngTargetHeight) {

    document.getElementById(t_strHideID).style.display="none"
    document.getElementById(t_strInnerID).style.display="none"
    setTimeout('ChangeSize("' + t_strOuterID + '",' + t_lngTargetHeight + ',10,-10,"' + t_strInnerID + '","' + t_strShowID + '");',1)     

}

function ChangeSize(t_strTargetID,t_lngStartHeight,t_lngEndHeight,t_lngIncrement,t_strInnerID,t_strShowID) {

    t_lngStartHeight +=t_lngIncrement;
    if ((t_lngStartHeight >= t_lngEndHeight) && (t_lngIncrement>0)) {
        document.getElementById(t_strInnerID).style.display="block"
        document.getElementById(t_strShowID).style.display="block"
    } else if ((t_lngStartHeight <= t_lngEndHeight) && (t_lngIncrement<0)) {
        document.getElementById(t_strTargetID).style.display="none"
        document.getElementById(t_strShowID).style.display="block"
    } else {
        document.getElementById(t_strTargetID).style.height="" + t_lngStartHeight + "px"
        setTimeout('ChangeSize("' + t_strTargetID + '",' + t_lngStartHeight + ',' + t_lngEndHeight + ',' + t_lngIncrement + ',"' + t_strInnerID + '","' + t_strShowID + '");',1)     
    }
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function ADCvalidateForm() { 
 
var ADCvalidateFormE0 = 'The following error(s) occurred'
var ADCvalidateFormE1 = 'You must select an option'
var ADCvalidateFormE2 = 'must contain an e-mail address'
var ADCvalidateFormE3 = 'must contain a number between'
var ADCvalidateFormE4 = 'and'
var ADCvalidateFormE5 = 'is required'
var ADCvalidateFormE6 = 'must contain a number'
 
  var i,p,q,val,nm,test,display,num,min,max,errors='',args=ADCvalidateForm.arguments;
  var pparts = new Array;
  for (i=0; i<(args.length-2); i+=4) { 
    display=args[i+3]; test=args[i+2]; val=MM_findObj(args[i]);
    if (display=='') display=nm;
    if (test.charAt(0) == 'B') { 
    	if (!radio_button_checker(args[i]))errors+='- '+display+' ' + ADCvalidateFormE1 +'.\n'; 
    } else {
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isDropDown')!=-1) {
	if (val=='Unselected') errors+='- '+display+' - '+ ADCvalidateFormE1 + '.\n';
      } else 
      if (test.indexOf('isEmail')!=-1) { 
        pparts = val.split('@'); 
        p=val.indexOf(' '); 
        if (p>=0 || pparts.length!=2 || pparts[0]=='' || pparts[1]=='') 
          {
	    errors+='- '+display+' '+ADCvalidateFormE2+'.\n'; 
	  } else {
	    pparts = pparts[1].split('.');
	    if(pparts.length<2 || pparts[0]==''|| pparts[pparts.length-1]=='')  
	      {
	      	 errors+='- '+display+' '+ADCvalidateFormE2+'.\n'; 
	      }
	  }
	} else if (test!='R') { num = parseFloat(val);
	if (isNaN(val)) errors+='- '+nm+' '+ADCvalidateFormE6+'.\n';
	if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
	  min=test.substring(8,p); max=test.substring(p+1);
	  if (num<min || max<num) errors+='- '+display+' '+ADCvalidateFormE3+' '+min+' '+ADCvalidateFormE4+' '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors +='- '+display+' '+ADCvalidateFormE5+'.\n';} }
  } if (errors) alert(ADCvalidateFormE0+':\n'+errors);
  return (!errors);
}