var prid = 0;
var ajax = new sack();

function getTownList(f, sel)
{
	removeAllOptions(f);
	var countyCode = sel.options[sel.selectedIndex].value;
	if(countyCode.length>0){
		ajax.requestFile = '/getDropDown.php?countyCode='+countyCode;	// Specifying which file to get
		ajax.onCompletion = displayTowns;	// Specify function that will be executed after file has been found
		ajax.runAJAX();		// Execute AJAX function
	}
}

function xxxgetTownList(sel)
{
	removeAllOptions(sel);
	var townCode = sel.options[sel.selectedIndex].value;
	if(townCode.length>0){
		ajax.requestFile = '/getDropDown.php?townCode='+townCode;	// Specifying which file to get
		ajax.onCompletion = displayTowns;	// Specify function that will be executed after file has been found
		ajax.runAJAX();		// Execute AJAX function
	}
}

// dtw
function removeAllOptions(f) {
	// except the 1st
	var selectbox= f.elements['gigByTown'];
	var i;
	for(i=selectbox.options.length;i>=0;i--) {
		selectbox.remove(i);
	}
}

function xxxremoveAllOptions(f) {
	var selectbox= f.elements['gigByTown'];
	var i;
	for(i=selectbox.options.length-1;i>=0;i--) {
		selectbox.remove(i);
	}
}


function displayTowns()
{
	var obj = document.getElementById('gigByTown');
	eval(ajax.response);	// Executing the response from Ajax as Javascript code	
}

function setUrl(f){
	
	  //alert(f.name);
	  //return;
  	//dtw changed for a form
  	var theCounty = f.countyText.options[f.countyText.selectedIndex].value;
  	var thetown = f.gigByTown.options[f.gigByTown.selectedIndex].value;
  	//alert('/gig_guide/'+theCounty+'/'+thetown);
  	f.action= '/gig_guide/'+theCounty+'/'+thetown;
  	//f.submit();
  	
  	/*  	
  	var btn = document.getElementById('viewByTown');
  	var thetown = town.options[town.selectedIndex].value;
  	if(thetown.length > 0){
	    btn.setAttribute('href','/gig_guide/'+thetown);
	}
	*/
}

function getSizeList(sel)
{
	var productCode = sel.options[sel.selectedIndex].value;
	if(productCode.length>0){
	  	prid = productCode;
	}
}
/** separate function to reveal faqs **/
hideInfo = function() {
qs = document.getElementsByTagName("UL");
for(i=0; i<qs.length; i++){
  	if(qs[i].hasChildNodes){
		for(j=0; j<qs[i].childNodes.length; j++){
			node = qs[i].childNodes[j];
			if(node.nodeName=="LI"){
			  	for(k=0; k<node.childNodes.length; k++){
			  		ans = node.childNodes[k];
					if(ans.className=="qs"){
					  ans.title = 'Reveal Answer';
					}
				    if(ans.nodeName=="DIV"){
					  ans.style.display = 'none';
					  ans.style.marginLeft = '0px';
					  ans.style.paddingLeft = '0px';
					}
				}
			}
		}
	}
}
}
function showMoreDetails(id){
  ansdiv = document.getElementById('details'+id);
  qlink = document.getElementById('moredetails'+id);
  if(ansdiv.style.display == 'block'){
    ansdiv.style.display = 'none';
    qlink.innerHTML = 'More Details &gt;&gt;';
  } else {
    ansdiv.style.display = 'block';
    qlink.innerHTML = 'Less Details &lt;&lt;';
  }
}

function showMoreDetailsGigsBlock(id){
  ansdiv = document.getElementById('details'+id);
  //qlink = document.getElementById('moredetails'+id);
  if(ansdiv.style.display == 'block'){
    ansdiv.style.display = 'none';
    //qlink.innerHTML = 'More Details &gt;&gt;';
  } else {
    ansdiv.style.display = 'block';
    //qlink.innerHTML = 'Less Details &lt;&lt;';
  }
}

function openRadio(){
  	mywin = window.open("/mp3player.html","Radio_Player",'width=410,height=519,top=100,left=100,resizable=no,toolbar=no,status=no');
  	mywin.document.close();
}
function openCopy(){
  	mywin = window.open("/copyright.html","Copyright",'width=250,height=175,top=100,left=100,resizable=no,toolbar=no,status=no');
  	mywin.document.close();
}
function printThisPage(){
  	mywin = window.open("/print.php","Invoice");
  	mywin.document.close();
}
function getDAWindow(){
  	mywin = window.open("/downloadagreement.php","Download_Agreement",'toolbar=no,status=no,scrollbars=1');
  	mywin.document.close();
}
function getUAWindow(){
  	mywin = window.open("/uploadagreement.php","Upload_Agreement",'toolbar=no,status=no,scrollbars=1');
  	mywin.document.close();
}
function getTUWindow(){
  	mywin = window.open("/termsofuse.php","Terms_use",'toolbar=no,status=no,scrollbars=1');
  	mywin.document.close();
}
function confirmPurchase() {
	if (!document.forms["Payform"].agreement.checked) {
		alert ("Please check the Download Agreement box, in order to proceed.");
		return;
	}
	document.forms["Payform"].submit();
}
function confirmReadTerms(theform) {
	if (!document.forms[theform].agreement.checked) {
		alert ("Please confirm you have read the terms by check the box, in order to proceed.");
		return;
	}
	document.forms[theform].submit();
}

function confirmDelete(response,theForm) {
	if (confirm(response))
	{
		document.forms[theForm].submit();
	}
}




window.onload = function(){
	hideInfo();
}

function setAccountType(str) {
	
	var target1 = new getMainObj('accountUK');
	//alert (target1.style.display);
	var target2 = new getMainObj('accountINT');
	if (str=='accountUK') {
		//alert(1);
		target1.style.display = "";
		target2.style.display = "none";
  }else if (str=='accountINT') {
  	//alert(2);
  	target1.style.display = "none";
  	target2.style.display = "";
  }
}

function setPaymentType(f, el, str) {
	
	//alert(el.name);
	//var dp= location.pathname;
	//alert(str);
	//var where_is= dp.indexOf('bank');
//alert('The a is at position '+where_is+'.');
//	alert(location.pathname);
//	alert(el.value);
	//window.location.href="http://home.netscape.com/";
	//return;
	//alert(f.action.value);
	//if (dp.indexOf('bank')>0) {
	if (f.pType.value== 'bank') {
		if (str=='cheque') {
			//alert(1);
			//f.action='/profile/'+str;
			f.actionx.value='updatePaymentType';
			f.submit();
		}
  }else if (f.pType.value== 'cheque') {
  	if (str=='bank') {
  		//alert(2);
			//location.href= '/profile/bank';
			//f.action='/profile/'+str;
			f.actionx.value='updatePaymentType';
			f.submit();
		}
  }else{
  	alert('payment type error - '+f.pType.value);
  }
}

function getMainObj(name){
  if (document.getElementById) {
  	this.obj = document.getElementById(name);
		this.style = document.getElementById(name).style;
  } else if (document.all) {
		this.obj = document.all[name];
		this.style = document.all[name].style;
  } else if (document.layers) {
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
  }
}