// Popup Window audio
function details(pag) {
    this.name = "caption"
    pag = pag+".asp"
    myRemote = open(pag, "program", "width=475, height=400,alwaysLowered=0,alwaysRaised=1,channelmode=0,dependent=0,directories=0,fullscreen=0,hotkeys=1,location=0,menubar=0,resizable=0,scrollbars=0,status=0,titlebar=1,toolbar=0,z-lock=0")
}

// Regular expressions for form validations
var rgBlank = /^\s*$/;
var rgNumber = /^[0-9]+$/;
var rgWords = /^[a-zA-Z\s-]+$/;
var rgPhone = /^[0-9-)(+\s]+$/;
var rgEmail = /^[\w\.-]+@[\w-]+\.[\w\.-]+$/;

// Date format is MM/DD/YYYY
var rgDate = /^(0?[1-9]|1[0-2])\/(0?[1-9]|1[0-9]|2[0-9]|3[0-1])\/[0-9]{2}$/;

function AddCharacter(input,type) {
// Adds anb HTML paragraph 
// to text
	var output = input;
	if (type=='p') {
	output = output + "<p>"; }
	if (type=='br') {
	output = output + "<br>"; }
	if (type=='bon') {
	output = output + "<b>"; }
	if (type=='boff') {
	output = output + "</b>"; }
	if (type=='ion') {
	output = output + "<i>"; }
	if (type=='ioff') {
	output = output + "</i>"; }
	if (type=='uon') {
	output = output + "<u>"; }
	if (type=='uoff') {
	output = output + "</u>"; }
	if (type=='url') {
	output = '<a href="http://' + output + '" target="_blank">type link text</a>'; }
	if (type=='url2') {
	output = '<a href="' + output + '.asp">type link text</a>'; }
	return output;
}

function popupwin(winurl,winname,winfeatures)
{
   winhandle=window.open([winurl],[winname],[winfeatures]);
   winhandle.focus();
}

function bookmark(urlname,favouritename)
{
if (document.all)
window.external.AddFavorite(urlname,favouritename);
else
alert("Sorry. Netscape users must bookmark the pages manually by hitting <Ctrl-D>");
}

function printwin(winurl,winname,winfeatures)
{
  winhandle=window.open([winurl],[winname],[winfeatures])
  winhandle.focus();
  winhandle.print();
  winhandle.blur();
  winhandle.setTimeout('window.close()', 5000) 
  return true;
} 

function redirect(webpage)
{
    window.location=webpage; return true;
} 

function valCheckboxSelected(el, msg)
{
	var counter=0;
	for (i = 0; i<el.length; ++ i)
	{
		if (el[i].checked)
		{
		counter=counter+1
		}
	}
	if(counter==0)
	{
	    alert(msg);
		el.focus;
		return true;
	}
	return false;
}   

function valRadioSelected(el, msg)
{
	var counter=0;
	for (i = 0; i<el.length; ++ i)
	{
		if (el[i].checked)
		{
		counter=counter+1
		}
	}
	if(counter==0)
	{
		alert(msg);
		el.focus;
		return true;
	}
	return false;
}  

function valLength(el, minlen, msg)
{
 	if(el.value.length <= minlen)
	{
	    alert(msg);
		el.focus;
		return true;
	}
	return false;		 
}
function valLength2(el, maxlen, msg)
{
 	if(el.value.length >= maxlen)
	{
	    alert(msg);
		el.focus;
		return true;
	}
	return false;		 
}

function valNotBlank(el) {
	if(!rgBlank.test(el.value))
		return true;
	return false;
}

function valBlank(el, msg) {
	if(rgBlank.test(el.value)) {
		alert(msg);
		el.focus();
		return true;
	}
	return false;
}

function valNumber(el, msg) {
	if(isNaN(el.value)) {
		alert(msg);
		el.focus();
		return true;
	}
	return false;
}

function valSelected(el, msg) {
	if(el.selectedIndex==0) {
		alert(msg);
		el.focus();
		return true;
	}
	return false;
}

function valBlankandSelected(el, el2, msg) {
	if(el2.selectedIndex==0 && rgBlank.test(el.value)) {
		alert(msg);
		el.focus();
		return true;
	}
	return false;
}

function valPhone(el, msg) {
	if(!rgPhone.test(el.value)) {
		alert(msg);
		el.focus();
		return true;
	}
	return false;
}

function valDate(el, msg) {
	if(!rgDate.test(el.value)) {
		alert(msg);
		el.focus();
		return false;
	}
	return true;
}

function valPasswordConfirm(el, elp, msg) {
	if(el.value!=elp.value) {
		alert(msg);
		el.focus();
		return true;
	}
	return false;
}

function valEmail(el, msg) {
	if(!rgEmail.test(el.value)) {
		alert(msg);
		el.focus();
		return true;
	}
	return false;
}

function selectid(element, parameter, extra) {
 if(selectid.arguments.length<2)
	parameter = "id";
 if(selectid.arguments.length<3)
	extra = "";
	
 if(element.selectedIndex>0) {
	var url = extra;
	
	if(extra!="")
		url += "&";
	else
		url += "?";
		
	url += parameter + "=" + element.options(element.selectedIndex).value;
	
	window.location.href = window.location.pathname + url;
 }

 if(element.selectedIndex==0) {
  var url = "";

  if(extra!="")
	url += "?" + extra;

  window.location.href = window.location.pathname + url;
 }
}

function confirm_delete() {
 return confirm("Are you sure?");
}
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 MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_jumpMenuGo(selName,targ,restore){ //v3.0
  var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu(targ,selObj,restore);
}



