function AddFavorite(url,title){
if(document.all)
window.external.AddFavorite(url,title)
}

function copyit(theField) {
var tempval=eval("document."+theField)
tempval.focus()
tempval.select()
therange=tempval.createTextRange()
therange.execCommand("Copy")
}

function roll(img_name, img_src)
   {
   document[img_name].src = img_src;
   }

function pop(url,name,w,h)
{
	newwindow=window.open(url,name,'width=' + w + ',height=' + h + ',left=100,top=100,scrollbars=no');
	if (window.focus) {newwindow.focus()}
}

function popScroll(url,name,w,h)
{
	newwindow=window.open(url,name,'width=' + w + ',height=' + h + ',left=100,top=100,scrollbars=yes,resizable=yes');
	if (window.focus) {newwindow.focus()}
}

function popTool(url,name,w,h)
{
	newwindow=window.open(url,name,'width=' + w + ',height=' + h + ',left=100,top=100,toolbar=yes,scrollbars=no,resizable=no');
	if (window.focus) {newwindow.focus()}
}

function popMenu(url,name,w,h)
{
	newwindow=window.open(url,name,'width=' + w + ',height=' + h + ',left=100,top=100,scrollbars=yes,resizable=no,menubar=yes');
	if (window.focus) {newwindow.focus()}
}

function popToolScroll(url,name,w,h)
{
	newwindow=window.open(url,name,'width=' + w + ',height=' + h + ',left=100,top=100,toolbar=yes,scrollbars=yes,resizable=no');
	if (window.focus) {newwindow.focus()}
}

function popPrint(url)
{
	newwindow=window.open(url,'print','width=700,height=500,left=100,top=100,scrollbars=yes');
	if (window.focus) {newwindow.focus()}
}

function popForm(url,name,w,h)
{
	leftPos = 0
	topPos = 0
	if (screen) {
	leftPos = (screen.width / 2) - 251
	topPos = (screen.height / 2) - 162
    }
	newwindow=window.open(url,name,'width=' + w + ',height=' + h + ',left='+leftPos+',top='+topPos+',scrollbars=yes,resizable=yes');
	if (window.focus) {newwindow.focus()}
}


function warning(url,name,w,h)
{
  l = (screen.availWidth - 10 - w) / 2;
  t = (screen.availHeight - 30 - h) / 2;
	newwindow=window.open(url,name,'width=' + w + ',height=' + h + ',screenX=' + l + ',screenY=' + t + ',scrollbars=no');
	if (window.focus) {newwindow.focus()}
}


function showregion()
{
if (!document.images)
return
document.images.bvregionimg.src=
"maps/search/" + document.search.bvregion.options[document.search.bvregion.selectedIndex].value + ".gif"
}

function showfregion()
{
if (!document.images)
return
document.images.bvregionimg.src=
"maps/search/" + document.search.frregion.options[document.search.frregion.selectedIndex].value + ".gif"
}

function showdept()
{
if (!document.images)
return
document.images.bvregionimg.src=
"maps/search/" + document.search.dept.options[document.search.dept.selectedIndex].value + ".gif"
}



function show(ico)
{
if (document.search[ico].checked == true){
    document.images[ico].src = "icons/search/" + ico + "_on.gif"
    }
else{
    document.images[ico].src = "icons/search/" + ico + "_off.gif";
}
}



function ImageLoadFailed() {
    window.event.srcElement.style.display = "none";
}



function Submit(formname,page)
{
	document[formname].action = page
	document[formname].submit();	
	return true;
}


function AlertDate()
{
    alert("Please use calendar icon to insert date...");
}



function AlertMap()
{
    alert("Please use map icon to insert map reference...");
}

function showPic (whichpic) { 
	if (document.getElementById) { 
		document.getElementById('placeholder').src = whichpic.href; 
		if (whichpic.title) { 
			document.getElementById('desc').childNodes[0].nodeValue = whichpic.title; 
		} else { 
			document.getElementById('desc').childNodes[0].nodeValue = whichpic.childNodes[0].nodeValue; 
		} 
		return false; 
	} else { 
		return true; 
	} 
}



function checkBox(m) {
for (var j = 1; j <= 31; j++) {
box = eval("document.checkboxform." + j + m + "2005");
if (box.checked == false) box.checked = true;
   }
}

function uncheckBox(m) {
for (var j = 1; j <= 31; j++) {
box = eval("document.checkboxform." + j + m + "2005");
if (box.checked == true) box.checked = false;
   }
}



function CountWords(w,x){
var y=w.value;
var r = 0;
a=y.replace('\n',' ');
a=a.split(' ');
for (z=0; z<a.length; z++) {if (a[z].length > 0) r++;}
x.value=r;
}



function intOnly(i) {
	if(i.value.length>0) {
		i.value = i.value.replace(/[^\d]+/g, ''); 
	}
}


function distOnly(i) {
	if(i.value.length>0) {
		i.value = i.value.replace(/[^\d.]+/g, ''); 

	}
}


 function goPage(url){
	 if (url) {
		 location.href=url;
	 } else {
		 alert('That is not a valid url!');
	 } //else
 }


function populateDept(pop) {
    search.dept.value = pop;
    showdept(pop);
}

function populateBVR(pop) {
    search.bvregion.value = pop;
    showregion(pop);
}

function populateBVRClear(pop) {
    search.bvregion.value = pop;
    search.frregion.value = 'noregion';
    search.dept.value = 'noregion';
    showregion(pop);
}

function clearRD() {
    search.frregion.value = 'noregion';
    search.dept.value = 'noregion';
}

function clearBD() {
    search.bvregion.value = 'noregion';
    search.dept.value = 'noregion';
}

function clearBR() {
    search.bvregion.value = 'noregion';
    search.frregion.value = 'noregion';
}


function checkTerms(f){
if (f.checked == false )
{
alert('Please tick \'Accept Terms & Conditions\' to continue.');
return false;
}else
return true;
}

function SubmitForm(form,aim)
{
    form.target = "_self";
    form.action = aim
	form.submit();
	return false;
}

function Preview(form)
{
    newwindow = window.open('','preview','width=700,height=500,left=100,top=100,scrollbars=yes');
    form.target = "preview";
    form.action = "preview.asp"
	form.submit();
	return false;
}

function OwnerPreview(form)
{
    newwindow = window.open('','preview','width=700,height=500,left=100,top=100,scrollbars=yes');
    form.target = "preview";
    form.action = "../preview.asp"
	form.submit();
	return false;
}


function ChangeTab(id,newClass,oldClass) 
{
	identity1=document.getElementById("1");
	identity1.className=oldClass;
	identity2=document.getElementById("2");
	identity2.className=oldClass;
	identity3=document.getElementById("3");
	identity3.className=oldClass;
	identity4=document.getElementById("4");
	identity4.className=oldClass;

	identity=document.getElementById(id);
	identity.className=newClass;

}


function statusDate(){
tDate = new Date;
	var today = new Date()
	var month = tDate.getMonth() + 1
	var day = tDate.getDate()
	var year = tDate.getFullYear()
	var nextyear = tDate.getFullYear() + 1
	var s = "/"
	var hour = tDate.getHours()
        if(hour < 10){
		  hour = "0" + hour;
        }
	var minute = tDate.getMinutes()
        if(minute < 10){
		  minute = "0" + minute;
        }
	var second = tDate.getSeconds()
        if(second < 10){
		  second = "0" + second;
        }
	var t = ":"
	var sp = " "
document.status.StartDate.value = day + s + month + s + year + sp + hour + t + minute + t + second
document.status.FinishDate.value = day + s + month + s + nextyear + sp + hour + t + minute + t + second
}



function populateClass(name) { 
	select	= window.document.search.SubCategory; 
	string	= ""; 
	count	= 0; 
	select.options.length = count; 
	for( i = 0; i < arrayData.length; i++ ) { 
		string = arrayData[i].split( "|" ); 
		if( string[0] == name ) { 
			select.options[count++] = new Option( string[1] ); 
		} 
	}  
} 

function showVoucher(name,date,adid) {
    voucher.name.value = name;
    voucher.date.value = date;
    voucher.adid.value = adid;
}

