var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
	if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
	if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
	else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=yes,menubar=no,toolbar=no,resizable=yes,status=no';
	win=window.open(mypage,myname,settings);
}

xcCSSArrowMonthPrev=["","",""];
xcCSSArrowMonthNext=["","",""];

xcCSSArrowYearPrev=["","",""];
xcCSSArrowYearNext=["","",""];

xcArrowMonth=["<img src='/js/xc2/images/month_prev.gif' width='15' height='15' border='0' hspace='2'>",
              "<img src='/js/xc2/images/month_next.gif' width='15' height='15' border='0' hspace='2'>"];
xcArrowYear=["<img src='/js/xc2/images/year_prev.gif' width='15' height='15' border='0'>",
             "<img src='/js/xc2/images/year_next.gif' width='15' height='15' border='0'>"];

xcFootTagSwitch=[0, 0, 0, 0, 0, 0, 0, 0];



/* Functions for old style rollovers */
function rollover(imgID) {
		
  // get the image object we're referring to
  var thisimg = document.getElementById(imgID);
  // and add "_on" to its src
  thisimg.src = thisimg.src.replace(/(\.[a-z0-9]+)$/i,'_on$1');
}
function rollout(imgID) {
  // get the image object we're referring to
  var thisimg = document.getElementById(imgID);
  // and remove "_on" from its src
  thisimg.src = thisimg.src.replace(/_on(\.[a-z0-9]+)$/i,'$1');
}

/* Functions for new style rollovers; these are actual event handlers,
   not just called from an event handler. */
function rollover_handler(e) {
	
  // get the source element in a cross-browser way
  if (window.event) { thisimg = window.event.srcElement;
  } else if (e.target) { thisimg = e.target;
  } else { return;
  }
  thisimg.src = thisimg.src.replace(/(\.[a-z0-9]+)$/i,'_on$1');
}
function rollout_handler(e) {
  // get the source element in a cross-browser way
  if (window.event) { thisimg = window.event.srcElement;
  } else if (e.target) { thisimg = e.target;
  } else { return;
  }
  thisimg.src = thisimg.src.replace(/_on(\.[a-z0-9]+)$/i,'$1');
}

// set the hidden action element in a form
function KILLsetProductOrderForm(f, a, i) {
	//alert (document.forms[f].name);
	f= document.forms[f];
	f.elements['action'].value= a;
	f.elements['data'].value= i;
	if (a=='removeItem') {
		if (!confirm('Remove this item?')) {
			return;
		}
	}
	f.submit();
	//alert(document.forms[f].elements['action'].value);
	//alert(document.forms[f].elements['product_id'].value);
}

// set the hidden action element in a form
function setProductOrderForm(f, e, i) {
	//alert (document.forms[f].name);
	//f= document.forms[f];
	f.elements['action'].value= e.name;
	f.elements['data'].value= i;
	if (e.name=='removeItem') {
		if (!confirm('Remove this item?')) {
			return;
		}else{
			f.submit();
		}
	}else{
		f.submit();
	}
	//alert(document.forms[f].elements['action'].value);
	//alert(document.forms[f].elements['product_id'].value);
}


// set the hidden action element in a form
function setAction(f, e) {
	f.elements['action'].value= e.name;
}


// Anti spam bot for email
//var lhs = "help";
//var rhs = "mspan.co.uk";
function email_me(lhs, rhs, aClass) {
	// class=\""+aClass+"\"
	document.write("<a href=\"mailto");
	document.write(":" + lhs + "@");
	document.write(rhs + "\" title=\"email: "+lhs+"@"+rhs+"\">" + lhs + "@" + rhs + "<\/a>");
}

function confirmPurchase() {
	if (!document.forms["myForm"].agreement.checked) {
		alert ("Please check the terms and conditions box, in order to proceed.");
		return;
	}
	document.forms["myForm"].submit();
}

/*
function confirmRemoveItem(f, e, id1, msg) {
	if (confirm(msg))
	{
		f.elements['id'].value= id1;
		setAction(f, e);
		f.submit();
	}
	return false;
}
*/

function deliveryFormCheck(f, id) {
	var e = document.getElementById(id);
	e.style.display = 'block';
	
	e= f.First_Names;
	if (e.value=='') {
		e.value= 'Enter delivery details';
		setFocus(e);
		e.select()
	}
}

function deliveryFormCheckHide(f, id) {
	var things= new Array('First_Names', 'Last_Name', 'Street_Address_1', 'Street_Address_2', 'City', 'Postcode');
	for (var i=0; i< things.length; i++) {
		f.elements[things[i]].value='';
	} 
	var e = document.getElementById(id);
	e.style.display = 'none';
}

function toggle_visibility(id) {
var e = document.getElementById(id);
if(e.style.display == 'none')
e.style.display = 'block';
else
e.style.display = 'none';
}

// -----------------------------------------
//                  setfocus
// Delayed focus setting to get around IE bug
// Author: Stephen Poley
// wbsite: http://www.xs4all.nl/~sbpoley/webmatters/
// Update Jun 2005: discovered that reason IE wasn't setting focus was
// due to an IE timing bug. Added 0.1 sec delay to fix.
// -----------------------------------------
var glb_vfld;      // retain vfld for timer thread
function setFocusDelayed(vfld)
{
  glb_vfld.focus()
}
function setFocus(vfld)
{
	//alert(vfld.name);
  glb_vfld = vfld;
  setTimeout( 'setFocusDelayed()', 100 );
}