// JavaScript Document
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_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_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 validateUser() {

	var d = document.paymentdetail;
	var len = d.schemeid.length;
	var	myOption = -1;
	var myCheckBox = 0;

	for(var i=0; i<len; i++)
	{
		if(document.paymentdetail.schemeid[i].checked == true)
		{
			myOption = i;
			var val = document.paymentdetail.schemeid[i].value
			if( (val == 13) || (val == 14) || (val == 15) )
			{
				if(document.paymentdetail.music.checked) myCheckBox +=1;
				if(document.paymentdetail.acting.checked) myCheckBox +=1;
				if(document.paymentdetail.cw.checked) myCheckBox +=1;
				if(myCheckBox != 2) {
					alert("Please Choose any two categories");
					document.paymentdetail.music.focus();
					return false;
				}
			}
		}
	}
	if(myOption == -1) {
		alert("Please Choose a Membership");
		document.paymentdetail.schemeid[0].focus();
		return false;
	}
	return true;
}

function showterms()
{
window.open("legel.php","_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=500, height=400, addressbar=no" )
}

function getuserscheme(price) {
		
	var d = document.paymentdetail;
	var e = document.getElementById("schemeid");
//	d.userscheme.value = e.value;
    document.paymentdetail.amount.value = price;
}

function checkscheme() {
	//alert("hi");
//	var d = document.paymentdetail;
	var e = document.getElementById('schemeids');
//var e = d.schemeid.name;
//	alert(e.getAttribute("size"));
	var j = 0;
	for(j = 0; j<e.size; j++) {
		alert(j);	
	}


//	var size = e.length;
//	alert(e);
	return false;
}

function validatepayscheme() {
	
	myOption = -1;
	alert(myOption);
	var d = document.paymentdetails;
	var key;
	for(var key=1; key <= 15; key++) {
//		alert(key);
		if (d.schemeid[key].checked) {
			myOption = 1;		
		}
	}

	if (myOption == -1) {
		alert("Please Choose User Type!");
		return false;
	}
	alert(myOption);
	return true;
}

function validateloguser() {
	
	if(document.login.uname.value == "") {
		alert("Required: Username");
		document.login.uname.focus();
		return false;
	}
	if(document.login.pwd.value == "") {
		alert("Required: Password");
		document.login.pwd.focus();
		return false;
	}
	return true;
}

function validateFloat(obj, nLength, nPrecision)
	{
		var strVal = new String(obj.value);
		var nIndexOfDot = strVal.indexOf('.');
		var nValidLength = nIndexOfDot==-1?strVal.length:strVal.length+1
		
		if(nValidLength<strVal.length)
		{
			alert('Maximum length can be '+nLength);
			strVal = strVal.substring(0,nValidLength);
		}
		if(strVal.charAt(strVal.length-1)!='.' || nIndexOfDot!=(strVal.length-1))
		{
			if(isNaN(parseFloat(strVal)))
			{
				strVal='0';
			}
			obj.value=parseFloat(strVal);
		}
		if(-1!=nIndexOfDot && strVal.substring(nIndexOfDot+1).length>nPrecision)
		{
			strVal=strVal.substring(0, strVal.length-1);
			obj.value=strVal;
		}
	}

function changemodule() {
	var d = document;
	var e = d.basesearch.category.value;
	
//	alert(e);
	window.location.href = "search.php?category="+e;	
//	return false;
	
}
function changemodule1() {
	var d = document;
	var e = d.basesearch.category.value;
	
	//alert(e);
	window.location.href = "votemembers.php?category="+e;	
	//	return false;
	
}
function changemodule2() {
	var d = document;
	var e = d.basesearch.category.value;
	
	//alert(e);
	window.location.href = "voteschool.php?category="+e;	
	//	return false;
	
}
function validatesearch() {
	
	var d = document;
	var e = d.basesearch.category.value;
	
	var chk = 1;
	if(d.getElementById ('sname').value != '') { chk=0; }
	
	if(d.getElementById ('aname').value != '') { chk=0;	}
	
	if(e != 3) { if(d.getElementById ('genre').value != -9){ chk=0; } }

	if(d.getElementById ('country').value != '') { chk=0; }

	if(chk == 1) {
		alert("Please Enter a Valid Search Criteria");
		return false;
	}
	
	return true;
}

function confirmuser() {
	var d = document.applyaudition;
	if(d.audapply.checked == false) {

		var agree=confirm("Are you sure you wish to continue?");
		if (agree)
			return true ;
		else
			return false ;
	}
	return true;
}

function downloadcart(basketid)
{
	alert(basketid);
	window.open("downloads.php");
	window.location.href="viewcartdetails.php?tid=329";
}

function competitionalert()
{
	alert("Coming Soon");
	return false;
}
