// JavaScript Document



function send(btn)
{
	document.frmDetails.txtAction.value=btn;
	document.frmDetails.submit();
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

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_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function select_directoryartist(idx){
	var artidx = ""
	with (document.frmSearch) {
		if (idx=="")
		{
			artidx = lstartist[lstartist.selectedIndex].value;
		}
		else
		{
			artidx = idx;
		}

		if (artidx!="")
		{
			document.frmSearch.txtAristID.value=artidx;
			document.frmSearch.submit();
		}
	}
}
function dirsearch(){
	document.frmSearch.txtImagePath.value="";
	document.frmSearch.txtAristID.value="";
	document.frmSearch.txtAction.value="SEARCH";
	document.frmSearch.submit();
}

function select_activity(){
	var ref_url = ""
	with (document.frmdemo) {
		ref_url = lstdemonstrator[lstdemonstrator.selectedIndex].value;
		if (ref_url!=""){
			document.location = ref_url;
		}
	}
}
function select_teacher(){
	var ref_url = ""
	with (document.frmdemo) {
		ref_url = lstartist[lstartist.selectedIndex].value;
		if (ref_url!=""){
			document.location = "event_activity-Teachers.asp?teacherref=" + ref_url;
		}
	}
}

function select_organisation(){
	var ref_url = ""
	with (document.frmdemo) {
		ref_url = lstorganisation[lstorganisation.selectedIndex].value;
		if (ref_url!=""){
			document.location = "Community_events_&_orgainizations-details.asp?ref=" + ref_url;
		}
	}
}
function select_organisation_detail(){
	var ref_url = ""
	with (document.frmdemo) {
		ref_url = lst[lst.selectedIndex].value;
		if (ref_url!=""){
			document.location = "Community_events_&_orgainizations-details.asp?ref=" + txtdemo.value + "&sref=" + ref_url;
		}
	}
}

function select_demonstrator(){
	var ref_url = ""
	with (document.frmdemo) {
		ref_url = lstdemonstrator[lstdemonstrator.selectedIndex].value;
		if (ref_url!=""){
			document.location = "event_demo_area.asp?ref=" + ref_url;
		}
	}
}

function select_areademonstrator(){
	var ref_url = ""
	with (document.frmdemo) {
		ref_url = lstdemonstrator[lstdemonstrator.selectedIndex].value;
		if (ref_url!=""){
			document.location = "event_demo_area.asp?ref=" + ref_url;
		}
	}
}
function select_marketarea(){
	var ref_url = ""
	with (document.frmdemo) {
		ref_url = lstmarketarea[lstmarketarea.selectedIndex].value;
		if (ref_url!=""){
			document.location = "event_activity-TheMarketDetail.asp?AreaID=" + ref_url;
		}
	}
}
function select_market(){
	var ref_url = ""
	with (document.frmdemo) {
		ref_url = lstmarket[lstmarket.selectedIndex].value;
		if (ref_url!=""){
			document.location = "event_activity-TheMarketDetail.asp?AreaID=" + txtArea.value + "&ref=" + ref_url;
		}
	}
}
function select_jump(URL){
	var ref_url = ""
	with (document.frmdemo) {
		ref_url = lst[lst.selectedIndex].value;
		if (ref_url!=""){
			document.location = URL + "?ref=" + ref_url;
		}
	}
}

function change_preview(src_img){
	document.artimage.src=src_img + "jpg";
}

function chk(frmElement,errMsg) {
	if (trim(frmElement.value)=="") {
	 alert (errMsg);
	 frmElement.focus;
	 return false;
	}
	else return true;
}

function trim(str) {
	if (str=="") return ""
	var str0=new Array(' ','\t','\n').toString()
	if (str0.indexOf(str.charAt(0))!=-1) return trim(str.slice(1))
	if (str0.indexOf(str.charAt(str.length-1))==-1) return str
	return trim(str.slice(0,str.length-1))
}

function isemail(str) {
	var pt1,pt2,address,re
	address=str.split("@");
	if (address.length==2) {
		pt1 = address[0];
		pt2 = address[1];
  		if (pt2.split(".").length>0) {
			if (pt1.split(" ").length==1 && pt2.split(" ").length==1) {
				return true;
			}
			return false;
		}
		return false;
	}
	return false;
}

function checkparameters(str,matchstr) {
	var cnt;
	for (cnt = 1; cnt <= str.length; cnt++){
		if (matchstr.split(str.charAt(cnt-1)).length==1){
			return false;
		}
	}
	return true;
}

function bookingnumber(classref,lessonref)
{
	var sLst = "lst" + lessonref;
	var lst = document.frmdemo[sLst];

	var number = lst[lst.selectedIndex].value;
	if (number==0)
	{
		alert("You must first select how many places on the course you wish to reserve.");
	}
	else
	{
		document.frmdemo["lessonref"].value = lessonref;
		document.frmdemo["numberref"].value = number;
		document.frmdemo.submit();
	}
}
function promo_validate()
{
		var reg,t;
	with (document.frmTickets) {
		//txtname
		if (trim(txtPromo.value) == "") {
			t = alert("Please enter your Promotional Code.");
			txtPromo.focus();
		    return false;
		}
	}
	return true;
}

function validate_calendar()
{
	var reg,t;
	with (document.frmTickets) {
		//txtname
		if (trim(txtfname.value) == "") {
			t = alert("Please enter your first name.");
			txtfname.focus();
		    return false;
		}
		if (trim(txtlname.value) == "") {
			t = alert("Please enter your last name.");
			txtlname.focus();
		    return false;
		}		
		//txtAddress
		if (trim(txtAddress1.value) == "") {
			t = alert("Please enter the address you wish the calendar sent to.");
			txtAddress1.focus();
		    return false;
		}
		if (trim(txtCity.value) == "") {
			t = alert("Please enter the city you wish the tickets sent to.");
			txtCity.focus();
		    return false;
		}		
		//txtPostCode
		if (trim(txtPostCode.value) == "") {
			t = alert("Please enter the post code of the address you wish the calendar sent to.");
			txtPostCode.focus();
		    return false;
		}	
		if (trim(txtCountry.value) == "") {
			t = alert("Please enter the country you wish the calendar sent to.");
			txtCountry.focus();
		    return false;
		}			
		//txtTel
		if (trim(txtTel.value) == "") {
			t = alert("Please enter a contact telephone number.");
			txtTel.focus();
		    return false;
		}		
		//txtEmail
		if (trim(txtEmail.value) == "") {
			t = alert("Please enter your contact email address.");
			txtEmail.focus();
		    return false;
		}
		if (isemail(txtEmail.value) == false) {
			t = alert("Email address entered incorrectly.");
			txtEmail.focus();
			return false;
		}
		first_name.value = txtfname.value;
		last_name.value = txtlname.value;
		address1.value = txtAddress1.value;
		address2.value = txtAddress2.value;
		city.value = txtCity.value;
		country.value = txtCountry.value;
		email.value = txtEmail.value;
		
		
		return true;
		// skip card check for pay pal!
		
	}
}


function validate_bookingdetails()
{
	var reg,t;
	with (document.frmTickets) {
		//txtname
		if (trim(txtfname.value) == "") {
			t = alert("Please enter your first name.");
			txtfname.focus();
		    return false;
		}
		if (trim(txtlname.value) == "") {
			t = alert("Please enter your last name.");
			txtlname.focus();
		    return false;
		}		
		//txtAddress
		if (trim(txtAddress1.value) == "") {
			t = alert("Please enter the address you wish the tickets sent to.");
			txtAddress1.focus();
		    return false;
		}
		if (trim(txtCity.value) == "") {
			t = alert("Please enter the city you wish the tickets sent to.");
			txtCity.focus();
		    return false;
		}		
		//txtPostCode
		if (trim(txtPostCode.value) == "") {
			t = alert("Please enter the post code of the address you wish the tickets sent to.");
			txtPostCode.focus();
		    return false;
		}	
		if (trim(txtCountry.value) == "") {
			t = alert("Please enter the country you wish the tickets sent to.");
			txtCountry.focus();
		    return false;
		}			
		//txtTel
		if (trim(txtTel.value) == "") {
			t = alert("Please enter a contact telephone number.");
			txtTel.focus();
		    return false;
		}		
		//txtEmail
		if (trim(txtEmail.value) == "") {
			t = alert("Please enter your contact email address.");
			txtEmail.focus();
		    return false;
		}
		if (isemail(txtEmail.value) == false) {
			t = alert("Email address entered incorrectly.");
			txtEmail.focus();
			return false;
		}
		first_name.value = txtfname.value;
		last_name.value = txtlname.value;
		address1.value = txtAddress1.value;
		address2.value = txtAddress2.value;
		city.value = txtCity.value;
		country.value = txtCountry.value;
		email.value = txtEmail.value;
		
		
		return true;
		// skip card check for pay pal!
		
	}
}

function validate_emailfriend()
{
	var reg,t;
	with (document.frmEmail) {
		if (trim(txtname.value) == "") {
			t = alert("Please enter your name.");
			txtname.focus();
		    return false;
		}
		if (trim(txtemail.value) == "") {
			t = alert("Please enter your email address.");
			txtemail.focus();
		    return false;
		}
		if (isemail(txtemail.value) == false) {
			t = alert("Email address entered incorrectly.");
			txtemail.focus();
			return false;
		}
		if (trim(txtToName.value) == "") {
			t = alert("Please enter the name of the person you wish to send the link to.");
			txtToName.focus();
		    return false;
		}
		if (trim(txtToEmail.value) == "") {
			t = alert("Please enter your email address of the person you wish to send the link to.");
			txtToEmail.focus();
		    return false;
		}
		if (isemail(txtToEmail.value) == false) {
			t = alert("Email address entered incorrectly.");
			txtToEmail.focus();
			return false;
		}
		return true;
	}
}
function validate_logon()
{
	var reg,t;
	with (document.frmLogon) {
		if (trim(txtUserName.value) == "") {
			t = alert("Please enter your user name.");
			txtUserName.focus();
		    return false;
		}
		if (trim(txtPassword.value) == "") {
			t = alert("Please enter your password.");
			txtPassword.focus();
		    return false;
		}
		return true;
	}
}
function select_artist(){
	var ref_url = ""
	with (document.frmdemo) {
		ref_url = lstartist[lstartist.selectedIndex].value;
		if (ref_url!=""){
			document.location = "event_demonstrator-details.asp?ref=" + txtdemo.value + "&artref=" + ref_url;
		}
	}
}
function select_areaartist(){
	var ref_url = ""
	with (document.frmareaartist) {
		ref_url = lstareaartist[lstareaartist.selectedIndex].value;
		if (ref_url!=""){
			document.location = "event_demonstrator-details.asp?ref=" + txtdemo.value + "&artref=" + ref_url;
		}
	}
}

function select_areaartistlink(ref_url){
	with (document.frmareaartist) {
		if (ref_url!=""){
			document.location = "event_demonstrator-details.asp?ref=" + txtdemo.value + "&artref=" + ref_url;
		}
	}
}
 function bookmarkme()
 {
  if (window.external)
  {
   var urlAddress = document.location;
   var pageName = document.title;
   window.external.AddFavorite(urlAddress,pageName);
  }
  else
  { 
   alert("Sorry! Your browser doesn't support this function.");
  }
 }
 function emailfriend()
 {
   var urlAddress = document.location;
   var pageName = document.title;
   document.location = "emailfriend.asp?ref=" + urlAddress + "&name=" + pageName;
 }

window.status = "Copyright 2009 Art in Action"
 