PlayVideo = function(vname, newHref)
{
	if (flash_ver >= 8)
	{ var winSource = '/flash/videoPlayer8.asp?id='+vname; }
	else
	{ var winSource = '/flash/videoPlayer.asp?id='+vname; }
	//alert(vname);
	var myWin = window.open(winSource, 'Video_Player', 'height=340,width=384,toolbar=no,scrollbars=no');
	myWin.focus();

	if (newHref)
	{ document.location.href = newHref; }
}

function ImgSwitch(direc) {
	if (iImgCount > 1) {				
		if (direc == 'f') {
			if(ii < (iImgCount - 1)) {
				ii = ii + 1
			} else {
				ii = 1
			}
		}
		
		if (direc == 'b') {
			if (ii!=1) { 
				ii = ii - 1
			} else {
				ii = iImgCount - 1;
			}
		}
		sImg.src = '/pictures/' + aImages[ii];
		sCap.innerHTML = aCaptions[ii];
	}
}

function wordCount() {
	var sForm = document.forms['entryform'];
	var sDesc = sForm.elements['*description'].value;
	sDesc = sDesc.replace( "  ", " ");
	var aWords = sDesc.split(" ");
	
	document.getElementById('wordcount').innerHTML = aWords.length;
}

function checkSelected() {
	var sForm = document.forms['entryform'];	
	sForm.submit();	
}

function checkSelectedNew(a) {
    var sForm = document.forms['entryform'];	
	
	if (a!="")
	{
	    sForm.action = a;
	    sForm.submit();	
    }
}


function checkForm() {
	var sForm = document.forms['entryform'];
	var pass	= 1;
	
	if( sForm.termsandcond) {	
		if( sForm.termsandcond.checked) {
			sForm.action = "/processForm.asp";
		} else {
			pass = 0;
		} 
	} else {
		sForm.action = "/confirm.asp";
	}
	if( pass == 1) {
	    checkrequiredPOY('entryform');
	} else {
		alert("Please agree to our terms and conditions.");
	}
}


function checkFormNew(pr) {
	var sForm = document.forms['entryform'];
	
	if (pr == 1)
	{
	    sForm.action = "/register_step2b.asp";
	} else 
	{
	    sForm.action = "/register_step3.asp";
	}
	checkrequiredPOY('entryform');
	
}

function checkFormPrNew() {
	var sForm = document.forms['entryform'];
	
	sForm.action = "/register_step3.asp";
	
	checkrequiredPOY('entryform');
	
}

function checkForm1() {
	var sForm = document.forms['entryform'];
	var pass	= 1;
	
	if( sForm.termsandcond) {	
		if( sForm.termsandcond.checked) {
			sForm.action = "/confirm2.asp";
		} else {
			pass = 0;
		} 
	} else {
		sForm.action = "/confirm.asp";
	}
	if( pass == 1) {
		checkrequired('entryform');
	} else {
		alert("Please agree to our terms and conditions.");
	}
}

function checkForm2() {
    var sForm = document.forms['entryform'];

    sForm.action = "/processForm.asp";
    sForm.submit();
}

function showPrintPage()
{
	var popUp = window.open( '/tandc/rules.html', 'popup', 'toolbar=0,location=0,directories=0,status=0,menubar=yes,scrollbars=yes,resizable=yes,width=600,height=350');
}

function checkInviteForm() {
	var sForm = document.forms['entryform'];
	sForm.action = "processInvite.asp";
	checkrequired('entryform');
}

function showPR() {
  var sForm = document.forms['entryform'];
  if( sForm.pr.checked == 1) {
    document.getElementById('prcompany').style.display = "block"
  } else {
    document.getElementById('prcompany').style.display = "none";
  }
}

function checkSmlInviteForm()
{
	var sForm = document.forms['entryform'];
	sForm.action = "processSmlInvite.asp";
	checkrequired('entryform');
}

//added by adam because of extra functionality required.
function checkrequiredPOY(formname) {

    var pass = 0, box = 0, theForm;
    theForm = document.forms[formname];
    var msg = "";
    var pr = 0;
    
    if (document.images) {


        //check through form once to make check if PR values have been filled in, if they have then that means some of these fields need to be compulsory. 
        for (i = 0; i < theForm.length; i++) 
        {
            
            var tempobj = theForm.elements[i];
            
            if (tempobj.name.substring(0, 1) == "*") 
            {
                if (((tempobj.type == "text" || tempobj.type == "textarea")) || (tempobj.type.toString().charAt(0) == "s" && tempobj.selectedIndex == 0)) 
                {
                    var elPrName = tempobj.name.substring(1, 30);
                        
                    if (elPrName.lastIndexOf("pr ") >= 0 && tempobj.value!="")
                    {
                        //alert(elPrName);
                        pr = 1;
                    }
                }
            }
        }
        
        for (i = 0; i < theForm.length; i++) 
        {
            
            var tempobj = theForm.elements[i];
            
            if (tempobj.name.substring(0, 1) == "*") 
            {
                if (((tempobj.type == "text" || tempobj.type == "textarea") && tempobj.value == '') || (tempobj.type.toString().charAt(0) == "s" && tempobj.selectedIndex == 0) || (tempobj.type == "checkbox" && tempobj.checked == false)) 
                {
                    var elName = tempobj.name.substring(1, 30);

                    if ((elName.lastIndexOf("pr ") >= 0 && pr == 1) || (elName.lastIndexOf("pr ") < 0))
                    {
                        if (elName != "pr enterfor") {
                            msg += elName.replace("pr ", "public relations ") + "\n";
                        } else {
                            msg += "I have authorisation to enter on behalf of the client.\n";
                        }
                    }
                    
                }
            }
        }

        if (msg != "") {
            msg = "Please make sure the following fields are properly filled in.\n" + msg;

            alert(msg);
            
            tempobj.focus();
        } else {
            theForm.submit();
        }
    }
}


function showBrandEmail()
{
	var popUp = window.open( '/brand_email.asp?section=461&page=1697', 'popup', 'toolbar=0,location=0,directories=0,status=0,menubar=yes,scrollbars=yes,resizable=yes,width=600,height=600');
}