<!--
// Javascript functions for CVA Media website written by Telaworks.com

function openCVAMediaPlayer(mediaURL) { // Opens a new window for the Flash media player - Jake Collins, Telaworks.com
	winX=690;
	winY=535;
	Yoffset=30;
	XRes=screen.width;
	YRes=screen.height;
	winPosX=Math.round((XRes-winX)/2);
	winPosY=Math.round((YRes-winY)/2)-Yoffset;
	winPosX=navigator.appVersion.indexOf("MSIE")>-1 ? (',left='+winPosX) : (',screenX='+winPosX);
	winPosY=navigator.appVersion.indexOf("MSIE")>-1 ? (',top='+winPosY) : (',screenY='+winPosY);	
	window.open(mediaURL,'CVAPlayer','scrollbars=no,resizable=no,width='+winX+',height='+winY+winPosX+winPosY);
}

// Begin cross platform/browser stylesheet selection - styles for dymnamic layers and text formatting
function xBrowserPlatform() { //v4.1 by Jake Collins, Tom Nelson
	// Inline frame or table for 'latest news ticker'
	ticker = "<IFRAME SRC='../news/ticker.html' WIDTH=176 HEIGHT=150 SCROLLING='no' FRAMEBORDER=0 MARGINHEIGHT=0 MARGINWIDTH=0></IFRAME>";
	noticker = "<table border=0 cellpadding=20 cellspacing=0 width='176' height='150' background='../gif/ticker.gif'><tr><td height='25' valign='top' class='whatsnew'><br><br><br>what's new at CVA<p><a class='tickertext' href='../news/index.shtml' target=_top>Click here for the latest news about CVA Media...</a></p></td></tr></table>";

	bid=new whichBrowser();
	if (bid.antiqueCssWin) {
		styleToLink = '/clientside/cva_legacy.css'; // Pre Netscape 6 on Windows
		news = noticker;
	} else if (bid.antiqueCssMac) {
		styleToLink = '/clientside/cva_legacy.css'; // Pre Netscape 6 or IE 5 on Mac
		news = noticker;
	} else {
		styleToLink = '/clientside/cva.css' // Everything else
		news = ticker;
	}
}
// End xBrowserPlatform()

function whichBrowser(){ //v3.0 by Jake Collins, Telaworks.com
	this.ver=navigator.appVersion;
	this.name=navigator.appName;
	this.nav=eval(this.name == "Netscape");
	this.ie=eval(this.ver.indexOf("MSIE")>-1);
	this.ie4=eval(this.ver.indexOf("MSIE 4")>-1);
	this.ie5=eval(this.ver.indexOf("MSIE 5")>-1);
	this.ie6=eval(this.ver.indexOf("MSIE 6")>-1);
	this.ie7=eval(this.ver.indexOf("MSIE 7")>-1);
//	this.dom=eval(document.getElementById); //Might Break Old Browsers
	this.mac=eval(this.ver.indexOf("Mac")>-1);
	this.win=eval(this.ver.indexOf("Win")>-1);
	this.antiqueCssWin=eval(this.win&&(this.nav&&!(eval(parseInt(this.ver,10)>=5))));
	this.antiqueCssMac=eval(this.mac&& ( (this.nav&&!(eval(parseInt(this.ver,10)>=5))) || (this.ie&&!(this.ie5 || this.ie6)) ) );
	return this
}

function chooseCSS() { //v3.0 by Jake Collins, Telaworks.com
	xBrowserPlatform();
	document.write("<LINK REL='Stylesheet' REV='Stylesheet' HREF='" + styleToLink + "' TYPE='text/css' MEDIA='Screen'>");
}

function systemRequirements(requirement) {//Checks for requirement and writes a tick or a cross graphic to the browser, Jake Collins
	if (checkRequirement(requirement)) {
		document.write('<img src="gif/tick_yes.gif" width="34" height="34" />');
	} else {
		document.write('<img src="gif/tick_no.gif" width="34" height="34" />');
	}
}

function checkRequirement(requirement) {
	if (requirement=='Javascript') {
		return true;
	}
	if (requirement=='Browser') {
		var bid=whichBrowser();
		if ((bid.nav&&parseInt(bid.ver,10)>=5)||bid.ie4||bid.ie5||bid.ie6||bid.ie7) {
			return true;
		} else {
			return false;
		}
	}
	if (requirement=='Flash') {
		return MM_FlashCanPlay;
	}
}

function goThere(url){	
	var cmdStr=String.fromCharCode(108,111,99,97,116,105,111,110,46,104,114,101,102,61,39)+url+'\';';
	eval(cmdStr);
}

function cookieVal(cookieName) { // Reads the cookie
	thisCookie = document.cookie.split("; ");
		for (i=0; i<thisCookie.length; i++) {
			if (cookieName == thisCookie[i].split("=")[0]) {
				return thisCookie[i].split("=")[1]
			}
		}
	return 0
}

function cookiesEnabledCheck() { // See if the browser will accept cookies, Jake Collins 23.7.2001
	document.cookie = "cCookiesEnabled=yes;expires=" + expireDate.toGMTString() + ";path=/;domain=" + cookieDomain + ";";
	if (cookieVal('cCookiesEnabled') == 'yes') {
		document.cookie = "cCookiesEnabled=;expires=" + killCookieDate.toGMTString() + ";path=/;domain=" + cookieDomain + ";";
		return true;
	}
	else {
		document.cookie = "cCookiesEnabled=;expires=" + killCookieDate.toGMTString() + ";path=/;domain=" + cookieDomain + ";";
		return false;
	}
}

function initCookieCode() { // Defines variables to be used by other cookie related functions - Jake Collins, Telaworks 23.7.2001
	cookieDomain = location.hostname;
//	cookieDomain = "www.cvamedia.co.uk";
	expireDate = new Date;
	expireDate.setYear(expireDate.getYear()+3);
	killCookieDate = new Date;
	killCookieDate.setDate(killCookieDate.getDate()-1);
}

function checkCookiesForIndexPage() { // Checks if cookies are enabled and writes an error message if not, Jake Collins
	initCookieCode();
	if (eval(cookiesEnabledCheck()) == false) {
		document.writeln("<b>You don't appear to have cookies enabled on your web browser.</b> Please enable them or we won't be able to process the form below. Alternatively click on the email link instead.<BR><BR>");
	}
}


function checkCookiesForMoreInfoPage() { // Checks if cookies are enabled and redirects the browser if not, Jake Collins
	initCookieCode();
	if (eval(cookiesEnabledCheck()) == false) {
		redirectBrowser();
	}
}

function validEmail(email) { // Checks for valid email address, Tom Negrino, Dori Smith
	invalidChars = " /:,:";
	if (email == "") { // They don't have to enter an email
		return true;
	}
	for (i=0;i<invalidChars.length;i++) {
		badChar = invalidChars.charAt(i);
		if (email.indexOf(badChar,0)>-1) {
			return false;
		}
	}
	atPos = email.indexOf("@",1)
	if (atPos == -1) {
		return false;
	}
	if (email.indexOf("@",atPos+1)>-1) {
		return false;
	}
	periodPos = email.indexOf(".",atPos);
	if (periodPos == -1) {
		return false;
	}
	if (periodPos+3>email.length) {
		return false;
	}
	return true;
}
	

function validateContactDetails() { // Checks cookies are enabled and validates users details, Jake Collins
	vName = document.contactDetails.Name.value;
	vPosition = document.contactDetails.Position.value;
	vEmail = document.contactDetails.Email.value;
	vTel = document.contactDetails.Tel.value;	
	if ( vName == "") {
		alert("Please enter your name");
		document.contactDetails.Name.focus();
		return false;
	}
	if ((vEmail == "") && (vTel == "")) {
		alert("Please enter a method of contacting you");
		document.contactDetails.Tel.focus();
		return false;
	}
	if (eval(validEmail(vEmail)) == false) {
		alert("Your email address seems to be invalid, please check and try again");
		document.contactDetails.Email.focus();
		return false;
	}
	return true;
}


function newsLink(newsURL,linkText,newsDate) { // Suppresses link if url matches current page - Jake Collins 24.08.2001
	document.write('<p>');
	if (location.href.slice(-(newsURL.length))==newsURL) {
		document.write(linkText);
	}
	else {
		document.write('<a href=\"'+newsURL+'\" class=\"sidebar\">'+linkText+'</a>');
	}
	document.write('<br><span class=\"sidebardate\">'+newsDate+'</span></p>');
}

function updateParent(newURL) { // Tom Nelson, Telaworks.com
   opener.document.location = newURL
}

function lastUpdated() { //Writes HTML date into page, Telaworks
	var mydate=new Date();
	var year=mydate.getYear();
	year = (year < 1000) ? year+1900 : year ;
	var month=mydate.getMonth()+1;
	var day=mydate.getDate();
	day =(day<10) ? "0"+day : day ;
	month = (month<10) ? "0"+month : month ;
	document.write("Last Updated "+day+":"+month+":"+year+"&nbsp;&nbsp;&nbsp;");
}
	
// Standard Macromedia Dreamweaver generated functions

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.0
  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 && document.getElementById) x=document.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 MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}

//-->