/*
----------------------------------------------------------
	Scion Solutions Ltd main JavaScript file.
	This file is included in all pages
	FileName:    generic.js
	Version:     1.00				07/10/2005
	Copyright Scion Solutions Ltd 1998 - 2005
	www.scion.co.uk
	Author: Ian Winstanley
----------------------------------------------------------
*/

/* Browser detection */
var NS = (document.layers) ? 1 : 0;
var IE = (document.all) ? 1 : 0;
var NEW = (document.getElementById) ? 1 : 0;
var IE4 = (IE && !NEW) ? 1 : 0;
var IE5 = (IE && NEW) ? 1 : 0;
var MAC = (navigator.appVersion.indexOf("Mac") != -1) ? 1 : 0;
var Opera = (navigator.userAgent.indexOf("Opera") != -1) ? 1 : 0;
var Firefox = (navigator.userAgent.indexOf("Firefox") != -1) ? 1 : 0;
var NS6 = (NEW && !IE && !Opera & !Firefox) ? 1 : 0;
//alert('NS:' + NS + '\nIE:' + IE + '\nNEW:' + NEW + '\nIE4:' + IE4 + '\nIE5:' + IE5 + '\nNS6:' + NS6 + '\nNS60:' + NS60 + '\nMAC:' + MAC + '\nOpera: ' + Opera + 'navigator.userAgent:' + navigator.userAgent);

window.name = 'scionMain'; // Generic window name

/* Element identification. Makes allowances for earlier browser that do not support getElementById */
function getElementById(id, windowName) {
	if (NEW) {
		return windowName ? windowName.document.getElementById(id) : document.getElementById(id);
	} else {
		return windowName ? windowName.document.all[id] : document.all[id];
	}
}

// Preload images
var myImages = new Array();
function preloadImages(imageName, imagePath) {
	for (var i in imageName) {
		myImages[imageName[i] + '_on'] = new Image();
		myImages[imageName[i] + '_on'].src  = imagePath + imageName[i] + '_on.gif';
		myImages[imageName[i] + '_off'] = new Image();
		myImages[imageName[i] + '_off'].src = imagePath + imageName[i] + '_off.gif';
	}
}

// Generic /images replace function
function imageChange(imgOb, imgReplace) {
	imgOb.src = myImages[imgReplace].src;
}

// opens a popup window based on either default or supplied arguments
var myWin, focusWin, genericWin;
function openWindow(url, winWidth, winHeight, windowName) {
var winWidth = winWidth ? winWidth : Opera ? 666 : 650;
var winHeight = winHeight ? winHeight : Opera ? 570 : 570;
var parms = 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, height=' + winHeight + ',width=' + winWidth + ', left=0, top=0';
    if (windowName) {
    	genericWin = window.open(url, 'myWin', parms);
    } else {
    	focusWin = window.open(url, 'myWin', parms);
    }
    if (focusWin) {
        focusWin.focus();
    }
}

var agreementRead = false;
function popupLicence() {
  agreementRead = true;
  openWindow('/docs/title_role_agreement.pdf', 800, 600)
}

function checkLicence(frm) {
  var licenceAgreementChecked = false;
  for (i = 0; i < frm.licence.length; i++) {
    if (frm.licence[i].checked == true && frm.licence[i].value == 'accept') {
      licenceAgreementChecked = true;
    }
  }

  if (agreementRead == false) {
    alert('Please read the licence agreement before continuing.')
    return false;
  }
  if (licenceAgreementChecked == false) {
    alert('Please check to confirm that you accept the licence agreement before continuing.')
    return false;
  }

}

function check_clip_use(frm) {
  vatChargeChecked = false;
  if (frm.clip_use.value.length < 5) {
    alert('Please enter the use to which you will be putting your clip.')
    return false;
  }
  for (i = 0; i < frm.charge_vat.length; i++) {
    if (frm.charge_vat[i].checked == true) {
      vatChargeChecked = true;
    }
  }
  if (vatChargeChecked == false) {
    alert('Please select your VAT status.')
    return false;
  }
}