
function updateBannerHits(BannerId, Page)
{
	
	var ajax = new sack();
	var form = document.getElementById('form');
	ajax.setVar("BannerId", BannerId); 
	ajax.setVar("RefURL", Page); 
	// recomended method of setting data to be parsed.
	ajax.requestFile = "/myasg/countbanner.asp";	
	//alert(ajax.requestFile)
	ajax.method = "POST";	
	ajax.runAJAX();
}

<!-- ================================= -->
			<!-- Trim Function -->
<!-- ================================= -->			
function Trim(TRIM_VALUE)
{
	if(TRIM_VALUE.length < 1)
	{
	return"";
	}
	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);
	if(TRIM_VALUE=="")
	{
		return "";
	}
	else
	{
	return TRIM_VALUE;
	}
} //End Function

<!-- ================================= -->
		<!-- RTrim Function -->
<!-- ================================= -->
function RTrim(VALUE)
{
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";
	if(v_length < 0)
	{
		return"";
	}
	var iTemp = v_length -1;
	while(iTemp > -1)
	{
		if(VALUE.charAt(iTemp) == w_space)
		{}
		else
		{
			strTemp = VALUE.substring(0,iTemp +1);
			break;
		}
		iTemp = iTemp-1;
	} //End While
	return strTemp;
} //End Function

<!-- ================================= -->
		<!-- LTrim Function -->
<!-- ================================= -->
function LTrim(VALUE)
{
	var w_space = String.fromCharCode(32);
	if(v_length < 1)
	{
		return"";
	}
	var v_length = VALUE.length;
	var strTemp = "";
	var iTemp = 0;
	while(iTemp < v_length)
	{
		if(VALUE.charAt(iTemp) == w_space)
		{}
		else
		{
			strTemp = VALUE.substring(iTemp,v_length);
			break;
		}
		iTemp = iTemp + 1;
	} //End While
return strTemp;
} //End Function

<!-- ================================= -->
		<!-- Left Function -->
<!-- ================================= -->

function Left(str, n)
   
    {
            if (n <= 0)     // Invalid bound, return blank string
                    return "";
            else if (n > String(str).length)   // Invalid bound, return
                    return str;                // entire string
            else // Valid bound, return appropriate substring
                    return String(str).substring(0,n);
    }

<!-- ================================= -->
		<!-- End Left Function -->
<!-- ================================= -->

<!-- ================================= -->
		<!-- Right  Function -->
<!-- ================================= -->

 function Right(str, n)
   
    {
            if (n <= 0)     // Invalid bound, return blank string
               return "";
            else if (n > String(str).length)   // Invalid bound, return
               return str;                     // entire string
            else { // Valid bound, return appropriate substring
               var iLen = String(str).length;
               return String(str).substring(iLen, iLen - n);
            }
    }
<!-- ================================= -->
		<!-- End Right Function -->
<!-- ================================= -->

<!-- ================================= -->
		<!-- Mid Function -->
<!-- ================================= -->

 function Mid(str, start, len)
    
    {
            
            if (start < 0 || len < 0) return "";

            var iEnd, iLen = String(str).length;
            if (start + len > iLen)
                    iEnd = iLen;
            else
                    iEnd = start + len;

            return String(str).substring(start,iEnd);
    }
<!-- ================================= -->
		<!-- End Mid Function -->
<!-- ================================= -->

<!-- ================================= -->
		<!-- Instr  Function -->
<!-- ================================= -->


function InStr(strSearch, charSearchFor)

{
	for (i=0; i < String(strSearch).length; i++)
	{
	    if (charSearchFor == Mid(strSearch, i, 1))
	    {
			return i;
	    }
	}
	return -1;
}
<!-- ================================= -->
		<!-- End inStr Function -->
<!-- ================================= -->

//Function To Check Valid String Only Consists Of a-z 0-9
function isValidStr(checkStr)
{
var checksOK = "abcdefghijklmnopqrstuvwxyz1234567890";

var allValid = true;
 
for (i = 0;  i < checkStr.length;  i++)
{
ch = checkStr.charAt(i);
for (j = 0;  j < checksOK.length;  j++)
if (ch == checksOK.charAt(j))
break;
if (j == checksOK.length)
{
allValid = false;
break;
}
}
 
if (!allValid)
{
	return false;
}
else
{
	return true;
}

}


//Function To Check Email
function emailCheck (emailStr) 
{
var checkTLD=1;
var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
var emailPat=/^(.+)@(.+)$/;
var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
var validChars="\[^\\s" + specialChars + "\]";
var quotedUser="(\"[^\"]*\")";
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
//var ipDomainPat=/^((0|1[0-9]{0,2}|2[0-9]{0,1}|2[0-4][0-9]|25[0-5]|[3-9][0-9]{0,1})\.){3}(0|1[0-9]{0,2}|2[0-9]{0,1}|2[0-4][0-9]|25[0-5]|[3-9][0-9]{0,1})$/;
//var ipDomainPat=/^((0|1[0-9]{0,2}|2[0-9]{0,1}|2[0-4][0-9]|25[0-5]|[3-9][0-9]{0,1})\\.){3}(0|1[0-9]{0,2}|2[0-9]{0,1}|2[0-4][0-9]|25[0-5]|[3-9][0-9]{0,1})$/;
var atom=validChars + '+';
//alert("\[^\\s");
var word="(" + atom + "|" + quotedUser + ")";
var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
var matchArray=emailStr.match(emailPat);
//alert(emailStr.match(emailPat));

if (matchArray==null) 
{
//alert("Email address seems incorrect (check @ and .'s)");
return false;
}
var user=matchArray[1];
var domain=matchArray[2];
//alert(matchArray[2])
for (i=0; i<user.length; i++) 
{
//alert(user.charCodeAt(i));
if (user.charCodeAt(i)>127) 
{
//alert("Ths username contains invalid characters.");
return false;
}
}
for (i=0; i<domain.length; i++) 
{
if (domain.charCodeAt(i)>127) 
{
//alert("Ths domain name contains invalid characters.");
return false;
}
}


if (user.match(userPat)==null) 
{
//alert("The username doesn't seem to be valid.");
return false;
}
alert(domain.match(ipDomainPat));
var IPArray=domain.match(ipDomainPat);
alert(IPArray);
if (IPArray!=null) 
{
	for (var i=1;i<=4;i++) 
	{
		if (IPArray[i]>255) 
		{
		//alert("Destination IP address is invalid!");
			return false;
		}
	}
	return true;
}

var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) 
{
//alert(atomPat);
if (domArr[i].search(atomPat)==-1) 
{
//alert("The domain name does not seem to be valid.");
return false;
}
}

if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1) 
{
//alert("The address must end in a well-known domain or two letter " + "country.");
return false;
}
if (len<2) 
{
//alert("This address is missing a hostname!");
return false;
}
return true;
}



//Function To Check Date
function isDate(DateToCheck){
if(DateToCheck==""){return false;}
var m_strDate = FormatDate(DateToCheck,"dd/mm/yyyy");
if(m_strDate==""){
return false;
}
var m_arrDate = m_strDate.split("/");
var m_DAY = m_arrDate[0];
var m_MONTH = m_arrDate[1];
var m_YEAR = m_arrDate[2];
if(m_YEAR.length > 4){return false;}
m_strDate = m_MONTH + "/" + m_DAY + "/" + m_YEAR;
var testDate=new Date(m_strDate);
if(testDate.getMonth()+1==m_MONTH){
return true;
} 
else{
return false;
}
}//end function


function FormatDate(DateToFormat,FormatAs){
if(DateToFormat==""){return"";}
if(!FormatAs){FormatAs="dd/mm/yyyy";}

var strReturnDate;
FormatAs = FormatAs.toLowerCase();
DateToFormat = DateToFormat.toLowerCase();
var arrDate
var arrMonths = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
var strMONTH;
var Separator;

while(DateToFormat.indexOf("st")>-1){
DateToFormat = DateToFormat.replace("st","");
}

while(DateToFormat.indexOf("nd")>-1){
DateToFormat = DateToFormat.replace("nd","");
}

while(DateToFormat.indexOf("rd")>-1){
DateToFormat = DateToFormat.replace("rd","");
}

while(DateToFormat.indexOf("th")>-1){
DateToFormat = DateToFormat.replace("th","");
}

if(DateToFormat.indexOf(".")>-1){
Separator = ".";
}

if(DateToFormat.indexOf("-")>-1){
Separator = "-";
}


if(DateToFormat.indexOf("/")>-1){
Separator = "/";
}

if(DateToFormat.indexOf(" ")>-1){
Separator = " ";
}

arrDate = DateToFormat.split(Separator);
DateToFormat = "";
	for(var iSD = 0;iSD < arrDate.length;iSD++){
		if(arrDate[iSD]!=""){
		DateToFormat += arrDate[iSD] + Separator;
		}
	}
DateToFormat = DateToFormat.substring(0,DateToFormat.length-1);
arrDate = DateToFormat.split(Separator);

if(arrDate.length < 3){
return "";
}

var DAY = arrDate[0];
var MONTH = arrDate[1];
var YEAR = arrDate[2];




if(parseFloat(arrDate[1]) > 12){
DAY = arrDate[1];
MONTH = arrDate[0];
}

if(parseFloat(DAY) && DAY.toString().length==4){
YEAR = arrDate[0];
DAY = arrDate[2];
MONTH = arrDate[1];
}


for(var iSD = 0;iSD < arrMonths.length;iSD++){
var ShortMonth = arrMonths[iSD].substring(0,3).toLowerCase();
var MonthPosition = DateToFormat.indexOf(ShortMonth);
	if(MonthPosition > -1){
	MONTH = iSD + 1;
		if(MonthPosition == 0){
		DAY = arrDate[1];
		YEAR = arrDate[2];
		}
	break;
	}
}

var strTemp = YEAR.toString();
if(strTemp.length==2){

	if(parseFloat(YEAR)>40){
	YEAR = "19" + YEAR;
	}
	else{
	YEAR = "20" + YEAR;
	}

}


	if(parseInt(MONTH)< 10 && MONTH.toString().length < 2){
	MONTH = "0" + MONTH;
	}
	if(parseInt(DAY)< 10 && DAY.toString().length < 2){
	DAY = "0" + DAY;
	}
	switch (FormatAs){
	case "dd/mm/yyyy":
	return DAY + "/" + MONTH + "/" + YEAR;
	case "mm/dd/yyyy":
	return MONTH + "/" + DAY + "/" + YEAR;
	case "dd/mmm/yyyy":
	return DAY + " " + arrMonths[MONTH -1].substring(0,3) + " " + YEAR;
	case "mmm/dd/yyyy":
	return arrMonths[MONTH -1].substring(0,3) + " " + DAY + " " + YEAR;
	case "dd/mmmm/yyyy":
	return DAY + " " + arrMonths[MONTH -1] + " " + YEAR;	
	case "mmmm/dd/yyyy":
	return arrMonths[MONTH -1] + " " + DAY + " " + YEAR;
	}

return DAY + "/" + strMONTH + "/" + YEAR;;

} //End Function


function getScreenX(formWidth)
{
	return (parseFloat(screen.width) - parseFloat(formWidth)) / 2;
}

function getScreenY(formHeight)
{
	return (parseFloat(screen.height) - parseFloat(formHeight)) / 2;
}

function CheckImage(ImageField)
{
	var BigImageFile="";
	var SmallImageFile="";
	ImagePath1=ImageField;
	if (ImagePath1.length>0)
	{
		SmallImageArray=ImagePath1.split("\\");
		SmallImageFile=SmallImageArray[SmallImageArray.length-1];
	}
	if(SmallImageFile.length>0)	
	{
		if (SmallImageFile.toUpperCase().lastIndexOf(".JPG")==-1 && SmallImageFile.toUpperCase().lastIndexOf(".JPEG")==-1 && SmallImageFile.toUpperCase().lastIndexOf(".GIF")==-1 && SmallImageFile.toUpperCase().lastIndexOf(".PNG")==-1)
		{
			alert("Please Select Image With jpg|jpeg|gif\png extensions");
			return false;		
		}
	}
return true;
}



function CheckUKPostalCode(PCODE){ //check postcode format is valid
 test = PCODE; 
 size = test.length;
 test = test.toUpperCase(); //Change to uppercase
 while (test.slice(0,1) == " ") //Strip leading spaces
  {test = test.substr(1,size-1);size = test.length
  }
 while(test.slice(size-1,size)== " ") //Strip trailing spaces
  {test = test.substr(0,size-1);size = test.length
  }
 if (size < 6 || size > 8){ //Code length rule
  return false;
  }
 if (!(isNaN(test.charAt(0)))){ //leftmost character must be alpha character rule
   return false;
  }
 if (isNaN(test.charAt(size-3))){ //first character of inward code must be numeric rule
   return false;
  }
 if (!(isNaN(test.charAt(size-2)))){ //second character of inward code must be alpha rule
   return false;
  }
 if (!(isNaN(test.charAt(size-1)))){ //third character of inward code must be alpha rule
   return false;
  }
 if (!(test.charAt(size-4) == " ")){//space in position length-3 rule
   return false;
   }
 count1 = test.indexOf(" ");count2 = test.lastIndexOf(" ");
 if (count1 != count2){//only one space rule
   return false;
  }
return true;
}


function checkMinSelection(frmName,ctrName,minSelection)
{
	var i;
	var cnt;
	cnt=0;
	if(eval("document."+frmName+"."+ctrName).checked==true)
	{
			return true;
	}
	else
	{
	for(i=0;i<eval("document."+frmName+"."+ctrName).length;i++)
	{
		if(eval("document."+frmName+"."+ctrName)[i].checked==true)
		{
			cnt=parseInt(cnt)+1;
		}
	}
	if(parseInt(cnt)>=parseInt(minSelection))
	{
		return true;
	}
	else
	{
		return false;
	}
	}
}

function Ckeckall(frmName,ctrName,MyVal )
{
	if(MyVal==true)
	{
		for(i=0;i<eval("document."+frmName+"."+ctrName).length;i++)
		{
			eval("document."+frmName+"."+ctrName)[i].checked=true;
		}
	}
	else
	{
		for(i=0;i<eval("document."+frmName+"."+ctrName).length;i++)
		{
		eval("document."+frmName+"."+ctrName)[i].checked=false;
		}
	}
}

function CheckAll(frmName,ctrName,MyVal )
{
	if(MyVal==true)
	{
		for(i=0;i<eval("document."+frmName+"."+ctrName).length;i++)
		{
			eval("document."+frmName+"."+ctrName)[i].checked=true;
		}
	}
	else
	{
		for(i=0;i<eval("document."+frmName+"."+ctrName).length;i++)
		{
		eval("document."+frmName+"."+ctrName)[i].checked=false;
		}
	}
}

function OnlyNumbers(Choice)
{
		if (event.keyCode<48 || event.keyCode>57)
		{
			if(Choice==1)
			{
				event.keyCode=0;
			}
			else if(Choice==2)
			{
				if(event.keCode!=46)
				{
					event.keyCode=0;
				}
			}
		}
}