NS4 = (document.layers) ? true : false;

function checkenter(event)
{
   var code = 0;

   if (NS4)
      code = event.which;
   else
      code = event.keyCode;
   if (code==13)
      document.editform.submit();
}

function addbookmark(){
if (document.all)
window.external.AddFavorite(location.href, document.title)
}


function open_window(url, w, h) {
email = window.open(url,"Preview",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=YES,width='+w+',height='+h);
}
 

function land(ref, target)
{
if (target=="_self") {window.location=loc;
}
else {if (target=="_top") {top.location=loc;
}

else {if (target=="_blank") {window.open(loc);
}
else {if (target=="_parent") {parent.location=loc;
}
else {parent.frames[target].location=loc;
};
}}}
}

function jump(menu)
{
ref=menu.choice.options[menu.choice.selectedIndex].value;
splitc=ref.lastIndexOf("&");
target="";
if (splitc!=-1)
{loc=ref.substring(0,splitc);
target=ref.substring(splitc+1,1000).toLowerCase();}
else {loc=ref; target="_self";};
if (ref != "") {land(loc,target);}
}


function jump2(menu)
{
ref=menu.choice2.options[menu.choice2.selectedIndex].value;
splitc=ref.lastIndexOf("&");
target="";
if (splitc!=-1)
{loc=ref.substring(0,splitc);
target=ref.substring(splitc+1,1000).toLowerCase();}
else {loc=ref; target="_self";};
if (ref != "") {land(loc,target);}
}


function jump3(menu)
{
ref=menu.choice3.options[menu.choice3.selectedIndex].value;
splitc=ref.lastIndexOf("&");
target="";
if (splitc!=-1)
{loc=ref.substring(0,splitc);
target=ref.substring(splitc+1,1000).toLowerCase();}
else {loc=ref; target="_self";};
if (ref != "") {land(loc,target);}
}


function jump4(menu)
{
ref=menu.choice4.options[menu.choice4.selectedIndex].value;
splitc=ref.lastIndexOf("&");
target="";
if (splitc!=-1)
{loc=ref.substring(0,splitc);
target=ref.substring(splitc+1,1000).toLowerCase();}
else {loc=ref; target="_self";};
if (ref != "") {land(loc,target);}
}


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_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_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_swapimage() { //v3.0
//alert(mm_swapimage.arguments[2]);
  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];}
}


	var bWrittenFunctions;

	function IEFlashTest()
	{
		var objFlash;
		var bHasFlash;

		if (navigator.appVersion.indexOf('MSIE 5')!=-1)
			bHasFlash=eval('try { var objFlash; objFlash=new ActiveXObject(\'ShockwaveFlash.ShockwaveFlash\'); delete objFlash; bHasFlash=true; } catch(e) { bHasFlash=false; }');
		else
		{
			{
				bWrittenFunctions=true;
				document.writeln('<SCR'+'IPT LANGUAGE="vbscript">');
				document.writeln('Function VBIETest');
				document.writeln('Dim objFlash');
				document.writeln('VBIETest=false');
				document.writeln('On Error Resume Next');
				document.writeln('Set objFlash=CreateObject("ShockwaveFlash.ShockwaveFlash")');
				document.writeln('If Err.Number=0 Then VBIETest=True');
				document.writeln('Set blnFlash=Nothing');
				document.writeln('End Function');
				document.writeln('</SCR'+'IPT>');
			}
			bHasFlash=VBIETest();
		}

		return(bHasFlash);
	}

	function HasFlash()
	{
		var bHasFlash=false;

		if ( (navigator.userAgent.indexOf("MSIE") == -1) || ( navigator.userAgent.indexOf("Mac")!=-1 ) )
		{
			// Netscape
			if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"])
			{
				bHasFlash=true;
			}
			else
			{
				bHasFlash=false;
			}
		}
		else
		{
			bHasFlash=IEFlashTest();
		}

		return(bHasFlash);
	}

	function InsertFlash( sFilename, iWidth, iHeight, sBackground )
	{
		var sOut;

		sOut='';
		sOut+='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
		sOut+='  width='+iWidth+' height='+iHeight+'>';
		sOut+='              <param name=movie value="'+sFilename+'">';
		sOut+='              <param name=quality value=high>';
		sOut+='              <param name=scale value=exactfit>';
		sOut+='              <param name=bgcolor value='+sBackground+'>';
		sOut+='<embed src="' + sFilename +'" quality=high bgcolor=' + sBackground;
		sOut+=' swLiveConnect=FALSE WIDTH=' + iWidth +' HEIGHT=' + iHeight + ' scale=exactfit';
		sOut+=' TYPE="application/x-shockwave-flash">';
		sOut+='</object>';
		
		document.write(sOut);
	}

	function InsertTag( sTag )
	{
		document.write(sTag);
	}


function open_window(url, w, h) {
email = window.open(url,"Preview",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=YES,width='+w+',height='+h);
}


function clearDefault(el) {
  if (el.defaultValue==el.value) el.value = ""
}


function StrIsEmail(value) {
	var ret = false;
	var emailRe=/\w+(.\w+)*@\w+(.\w+)*\.\w{2,3}/;
	var emailResult = emailRe.exec(value);
	if (emailResult) {
		if (emailResult[0].length ==  emailResult.input.length)
			ret = true;
	}
	return ret;
}


/*

function calgtot(lpcntr)
{
   var ticket1 = 'A' ;
   var ticket2 = 'S' ;
   var ticket3 = 'U' ;
   var ticket4 = 'J' ;
   var loopcount = lpcntr ;
   // loop to set form tttype1 to 4 	
   for(i = 1; i <= 4; i++)
   {
      var tselection = 'shopform.ticketprice' + i +'.selectedIndex' ;
      var ticketloop = eval(tselection) ;

      if ( !ticketloop == 0)
         {
         var ticketname = 'ticket' + ticketloop ;
         var tickettype = eval(ticketname) ;
	 // now set the form value - ttype1 to 4	
	 shopform.elements['ttype'+i].value = tickettype ;
         }
   }

   // debug lines
   
   // just add totals 
         
   var price1 = shopform.ticketprice1.options[shopform.ticketprice1.selectedIndex].value ;
   var price2 = shopform.ticketprice2.options[shopform.ticketprice2.selectedIndex].value ;
   var price3 = shopform.ticketprice3.options[shopform.ticketprice3.selectedIndex].value ;
   var price4 = shopform.ticketprice4.options[shopform.ticketprice4.selectedIndex].value ;
   var gtotal = eval(price1) + eval(price2) + eval(price3) + eval(price4) ;
   shopform.gtotal.value = gtotal ;


  if (parseInt(loopcount) != 1) 
  
  {
  	shopform.elements['address1-' + loopcount].value = shopform.elements['address1-1'].value ;
  	shopform.elements['address2-' + loopcount].value = shopform.elements['address2-1'].value ;
  	shopform.elements['town' + loopcount].value = shopform.town1.value ;
  	shopform.elements['county' + loopcount].value = shopform.county1.value ;
  	shopform.elements['postcode' + loopcount].value = shopform.postcode1.value ;
  	shopform.elements['daynumber' + loopcount].value = shopform.daynumber1.value ;
  	shopform.elements['nightnumber' + loopcount].value = shopform.nightnumber1.value ;
  	shopform.elements['email' + loopcount].value = shopform.email1.value ;
  	 	
  	
  }	

}


function copydetails()
{
	shopform.honorific1.value = shopform.honorific.options[shopform.honorific.selectedIndex].value ;
	shopform.firstname1.value = shopform.firstname.value ;
	shopform.lastname1.value = shopform.lastname.value ;
	shopform.address11.value = shopform.address.value ;
	shopform.address21.value = shopform.address2.value ;
	shopform.town1.value = shopform.town.value ;
	shopform.county1.value = shopform.county.value ;
	shopform.postcode1.value = shopform.postcode.value ;

}


*/


sfHover = function() {
	// this line was changed to remove the error
	// var sfEls = document.getElementById("nav").getElementsByTagName("LI") ;
	
	var sfEls = document.getElementsByTagName("li") ;
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover); 


function toggle(objBodyEle){
			if (document.getElementById(objBodyEle).className=='bodyClose'){
				document.getElementById(objBodyEle).className='bodyOpen';
			}else{
				document.getElementById(objBodyEle).className='bodyClose';
			}
		}


function addSinglePartTag(tagName, prompt, defaultText)
{
  // If something is selected then just encase it in the tags
  var selection = document.selection.createRange().text;
  if(selection != "")
  {
    self.editform.message.focus();
    var newSelection = document.selection.createRange();
	  newSelection.text 
= '<'+tagName+'>'+selection+'</'+tagName+'>';
	  return;
  }

  // Nothing's selected so prompt for something to put between the tags
  alert("Highlight the required text") ;
}

var d=document, imgs = new Array(), zInterval = null, current=0, pause=false;

function so_init() {
	if(!d.getElementById || !d.createElement)return;

	// DON'T FORGET TO GRAB THIS FILE AND PLACE IT ON YOUR SERVER IN THE SAME DIRECTORY AS THE JAVASCRIPT!
	// http://slayeroffice.com/code/imageCrossFade/xfade2.css
	css = d.createElement("link");
	css.setAttribute("href","/rugby/xfade2.css");
	css.setAttribute("rel","stylesheet");
	css.setAttribute("type","text/css");
	d.getElementsByTagName("head")[0].appendChild(css);

	imgs = d.getElementById("imageContainer").getElementsByTagName("img");
	for(i=1;i<imgs.length;i++) imgs[i].xOpacity = 0;
	imgs[0].style.display = "block";
	imgs[0].xOpacity = .99;
	
	setTimeout(so_xfade,1000);
}

function so_xfade() {
	cOpacity = imgs[current].xOpacity;
	nIndex = imgs[current+1]?current+1:0;

	nOpacity = imgs[nIndex].xOpacity;
	
	cOpacity-=.05; 
	nOpacity+=.05;
	
	imgs[nIndex].style.display = "block";
	imgs[current].xOpacity = cOpacity;
	imgs[nIndex].xOpacity = nOpacity;
	
	setOpacity(imgs[current]); 
	setOpacity(imgs[nIndex]);
	
	if(cOpacity<=0) {
		imgs[current].style.display = "none";
		current = nIndex;
		setTimeout(so_xfade,1000);
	} else {
		setTimeout(so_xfade,50);
	}
	
	function setOpacity(obj) {
		if(obj.xOpacity>.99) {
			obj.xOpacity = .99;
			return;
		}
		obj.style.opacity = obj.xOpacity;
		obj.style.MozOpacity = obj.xOpacity;
		obj.style.filter = "alpha(opacity=" + (obj.xOpacity*100) + ")";
	}
	
}

function deleteconf() {
	// alert("pmode is " + document.getElementById("pmode").value) ;
	var answer = confirm("Delete this file, are you absolutely sure?")
	if (answer){
		// change the form mode and submit the form
		document.getElementById("pmode").value = 'delete' ;
		document.imageupload.submit() ;
	}
	
}


var timer_id;

function scroll_iframe(frm,inc,dir) 
{

  if (timer_id) clearTimeout(timer_id);
  if (window.frames[frm]) 
  {
	 window.frames[frm].scrollBy(inc, 0);
	 timer_id = setTimeout("scroll_iframe('" + frm + "'," + inc + ",'" + dir + "')", 20) ;
  }
}

function stopScroll() { 
if (timer_id) clearTimeout(timer_id); 
}


function arrows(mode)
{
	// function to turn left and right arrows off called from clickedportfolio
	
	if (mode == 'on') 
	{
	parent.document.getElementById('LeftArrow2').style.display = 'Block' ;
	parent.document.getElementById('RightArrow2').style.display = 'Block' ;
	}
	else
	{
	parent.document.getElementById('LeftArrow2').style.display = 'none' ;
	parent.document.getElementById('RightArrow2').style.display = 'none' ;
	}
}


function displayHideRow(rowID)
{
	var row = document.getElementById(rowID);
	if (row.style.display == '')  
		row.style.display = 'none';
	else row.style.display = '';
}


/*
(C) www.dhtmlgoodies.com, November 2005

This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website.

*/

var dhtmlgoodies_slideSpeed = 10;	// Higher value = faster
var dhtmlgoodies_timer = 10;	// Lower value = faster

var objectIdToSlideDown = false;
var dhtmlgoodies_activeId = false;
var dhtmlgoodies_slideInProgress = false;
function showHideContent(e,inputId)
{
	if(dhtmlgoodies_slideInProgress)return;
	dhtmlgoodies_slideInProgress = true;
	if(!inputId)inputId = this.id;
	inputId = inputId + '';
	var numericId = inputId.replace(/[^0-9]/g,'');
	var answerDiv = document.getElementById('dhtmlgoodies_a' + numericId);

	objectIdToSlideDown = false;

	if(!answerDiv.style.display || answerDiv.style.display=='none'){
		if(dhtmlgoodies_activeId &&  dhtmlgoodies_activeId!=numericId){
			objectIdToSlideDown = numericId;
			slideContent(dhtmlgoodies_activeId,(dhtmlgoodies_slideSpeed*-1));
		}else{

			answerDiv.style.display='block';
			answerDiv.style.visibility = 'visible';

			slideContent(numericId,dhtmlgoodies_slideSpeed);
		}
	}else{
		slideContent(numericId,(dhtmlgoodies_slideSpeed*-1));
		dhtmlgoodies_activeId = false;
	}
}

function slideContent(inputId,direction)
{

	var obj =document.getElementById('dhtmlgoodies_a' + inputId);
	var contentObj = document.getElementById('dhtmlgoodies_ac' + inputId);
	height = obj.clientHeight;
	if(height==0)height = obj.offsetHeight;
	height = height + direction;
	rerunFunction = true;
	if(height>contentObj.offsetHeight){
		height = contentObj.offsetHeight;
		rerunFunction = false;
	}
	if(height<=1){
		height = 1;
		rerunFunction = false;
	}

	obj.style.height = height + 'px';
	var topPos = height - contentObj.offsetHeight;
	if(topPos>0)topPos=0;
	contentObj.style.top = topPos + 'px';
	if(rerunFunction){
		setTimeout('slideContent(' + inputId + ',' + direction + ')',dhtmlgoodies_timer);
	}else{
		if(height<=1){
			obj.style.display='none';
			if(objectIdToSlideDown && objectIdToSlideDown!=inputId){
				document.getElementById('dhtmlgoodies_a' + objectIdToSlideDown).style.display='block';
				document.getElementById('dhtmlgoodies_a' + objectIdToSlideDown).style.visibility='visible';
				slideContent(objectIdToSlideDown,dhtmlgoodies_slideSpeed);
			}else{
				dhtmlgoodies_slideInProgress = false;
			}
		}else{
			dhtmlgoodies_activeId = inputId;
			dhtmlgoodies_slideInProgress = false;
		}
	}
}



function initShowHideDivs()
{
	var divs = document.getElementsByTagName('DIV');
	var divCounter = 1;
	for(var no=0;no<divs.length;no++){
		if(divs[no].className=='dhtmlgoodies_question'){
			divs[no].onclick = showHideContent;
			divs[no].id = 'dhtmlgoodies_q'+divCounter;
			var answer = divs[no].nextSibling;
			while(answer && answer.tagName!='DIV'){
				answer = answer.nextSibling;
			}
			answer.id = 'dhtmlgoodies_a'+divCounter;
			contentDiv = answer.getElementsByTagName('DIV')[0];
			contentDiv.style.top = 0 - contentDiv.offsetHeight + 'px';
			contentDiv.className='dhtmlgoodies_answer_content';
			contentDiv.id = 'dhtmlgoodies_ac' + divCounter;
			answer.style.display='none';
			answer.style.height='1px';
			divCounter++;
		}
	}
}

function jumpmonth(menu)
{
ref=menu.month.options[menu.month.selectedIndex].value;
splitc=ref.lastIndexOf("&");
target="";
if (splitc!=-1)
{loc=ref.substring(0,splitc);
target=ref.substring(splitc+1,1000).toLowerCase();}
else {loc=ref; target="_self";};
if (ref != "") {land(loc,target);}
}

