/***********************************************
* IE AC ACTIVE X
***********************************************/
function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}

var browserType;

if (document.layers) {browserType = "nn4"}
if (document.all) {browserType = "ie"}
if (window.navigator.userAgent.toLowerCase().match("gecko")) {browserType= "gecko"}
function hide_prices() 
{
  	if (browserType == "gecko")
  	{
     		document.poppedLayer = eval('document.getElementById(\'artwork_prices\')');
     	}
  	else if (browserType == "ie")
     	{
     		document.poppedLayer = eval('document.all[\'artwork_prices\']');
     	}
  	else
	{
     		document.poppedLayer = eval('document.layers[\'`artwork_prices\']');
     	}
     	document.poppedLayer.style.display = "none";
}

function show_prices() 
{
  	if (browserType == "gecko")
  	{
     		document.poppedLayer = eval('document.getElementById(\'artwork_prices\')');
     	}
  	else if (browserType == "ie")
  	{
     		document.poppedLayer = eval('document.all[\'artwork_prices\']');
     	}
  	else
  	{
     		document.poppedLayer = eval('document.layers[\'`artwork_prices\']');
     	}
  	document.poppedLayer.style.display = "block";
}

function show_new_customer() 
{
  	/*document.getElementById('frm_checkout_new').style.display = "block";*/
	$("#frm_checkout_new").slideDown(1000);
	$("#frm_checkout_new_heading").slideUp(1000);
	$("#frm_existing_customer").slideUp(1000);
	/*document.getElementById('right_checkout_image').src="/media/images/checkout_epdq.jpg";*/
}


function show_cont() 
{
  	if (browserType == "gecko")
  	{
     		document.poppedLayerBut = eval('document.getElementById(\'continue_button\')');
     	}
  	else if (browserType == "ie")
  	{
     		document.poppedLayerBut = eval('document.all[\'continue_button\']');
     	}
  	else
  	{
     		document.poppedLayerBut = eval('document.layers[\'`continue_button\']');
     	}
  	document.poppedLayerBut.style.display = "block";
}

function hide_cont() 
{
  	if (browserType == "gecko")
  	{
     		document.poppedLayerBut = eval('document.getElementById(\'continue_button\')');
     	}
  	else if (browserType == "ie")
     	{
     		document.poppedLayerBut = eval('document.all[\'continue_button\']');
     	}
  	else
	{
     		document.poppedLayerBut = eval('document.layers[\'`continue_button\']');
     	}
     	document.poppedLayerBut.style.display = "none";
}

function show_upload() 
{
  	if (browserType == "gecko")
  	{
     		document.poppedLayerBut = eval('document.getElementById(\'upload_ftp\')');
     	}
  	else if (browserType == "ie")
  	{
     		document.poppedLayerBut = eval('document.all[\'upload_ftp\']');
     	}
  	else
  	{
     		document.poppedLayerBut = eval('document.layers[\'`upload_ftp\']');
     	}
  	document.poppedLayerBut.style.display = "block";
}

function getposOffset(overlay, offsettype)
{
	var totaloffset=(offsettype=="left")? overlay.offsetLeft : overlay.offsetTop;
	var parentEl=overlay.offsetParent;
	while (parentEl!=null)
	{
		totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
		parentEl=parentEl.offsetParent;
	}
	return totaloffset;
}

function show_paper_info(curobj, subobj)
{
	if (document.getElementById)
	{
		var subobj=document.getElementById(subobj);
		subobj.style.left=getposOffset(curobj, "left")+"px";
		subobj.style.top=getposOffset(curobj, "top")+"px";
		subobj.style.display="block";
		return false;
	}
	else
	{
		return true;
	}
}

function close_paper_info()
{
	document.getElementById('paper_info').style.display="none";
}

function show_artwork_info(curobj, subobj)
{
	if (document.getElementById)
	{
		var subobj=document.getElementById(subobj);
		var left_offset = getposOffset(curobj, "left")-200;
		var top_offset = getposOffset(curobj, "top")-200;
		subobj.style.left=left_offset+"px";
		subobj.style.top=top_offset+"px";
		subobj.style.display="block";
		return false;	
	}
	else
	{
		return true;
	}
}

function show_upload_info(curobj, subobj)
{
	if (document.getElementById)
	{
		var subobj=document.getElementById(subobj);
		var left_offset = getposOffset(curobj, "left")-200;
		var top_offset = getposOffset(curobj, "top");
		subobj.style.left=left_offset+"px";
		subobj.style.top=top_offset+"px";
		subobj.style.display="block";
		return false;	
	}
	else
	{
		return true;
	}
}


function show_callback_info(curobj, subobj)
{
	if (document.getElementById)
	{
		var subobj=document.getElementById(subobj);
		subobj.style.display="block";
		return false;	
	}
	else
	{
		return true;
	}
}

function close_artwork_info(curobj)
{
	document.getElementById(curobj).style.display="none";
}

function test(src) 
{
		var regex = /^[a-zA-Z0-9.'_-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
		return regex.test(src);
}	

function validate(f)
{
	var regex = /\W+/;
	var str = "";
	
	if(!test(f.tbxCusEmail.value))
	{
		str += "\nInvalid email address.";
	}
	if (f.tbxCusFirstName.value == "") 
	{
		str += "\nThe firstname field is blank.";
	}
	if (f.tbxCusSurname.value == "") 
	{
		str += "\nThe surname field is blank.";
	}
	if (f.tbxCusCompany.value == "") 
	{
		str += "\nThe company field is blank.";
	}
	if (f.tbxCusPhone.value == "") 
	{
		str += "\nThe phone field is blank.";
	}
	if (f.tbxCusEmail.value == "") 
	{
		str += "\nThe email field is blank.";
	}
	if (f.tbxBillAddress.value == "") 
	{
		str += "\nThe address field is blank.";
	}
	if (f.tbxBillTown.value == "") 
	{
		str += "\nThe town field is blank.";
	}
	if (f.tbxBillCounty.value == "") 
	{
		str += "\nThe county field is blank.";
	}
	if (f.tbxBillPostcode.value == "")
	{
		str += "\nThe postcode field is blank.";
	}
	if (!f.tbxTerms.checked)
	{
		str += "\nYou must agree to our Terms and Conditions.";
	}
	if (str == "")
	{
		f.submit();
	}
	else
	{
		alert(str);
		return false;
	}
}

function show_upload_details(curobj, subobj)
{
		var subobj=document.getElementById(subobj);
		var left_offset = getposOffset(curobj, "left")-400;
		var top_offset = getposOffset(curobj, "top")-300;
		subobj.style.left=left_offset+"px";
		subobj.style.top=top_offset+"px";
		subobj.style.display="block";
		return false;	
}

function close_upload_details()
{
	document.getElementById('upload_details').style.display="none";
}

function duplicate_delivery()
{
	document.getElementById('frm_del_name').value = document.getElementById('frm_bill_name').value;
	document.getElementById('frm_del_address').value = document.getElementById('frm_bill_address').value;
	document.getElementById('frm_del_address2').value = document.getElementById('frm_bill_address2').value;
	document.getElementById('frm_del_city').value = document.getElementById('frm_bill_city').value;
	document.getElementById('frm_del_county').value = document.getElementById('frm_bill_county').value;
	document.getElementById('frm_del_postcode').value = document.getElementById('frm_bill_postcode').value;
}

function get_size_price(id)
{
	size_price_tmp = document.getElementById('size_price_'+id).value;
	base_price = document.getElementById('base_price_'+id).value;
	size_price = size_price_tmp.split('_',2);
	new_price = parseFloat(base_price)+(parseFloat(size_price[1])*1);
	document.getElementById('accessory_price_'+id).value = new_price.toFixed(2);
	//document.getElementById('accessory_price_'+id).value = "£"+new_price.toFixed(2);
	//alert('ID: '+size_price[0]+' £'+size_price[1]);
}

function get_each_price(id)
{
	access_price_tmp = document.getElementById('accessory_price_'+id).value;
	each_qty_tmp = document.getElementById('each_qty_'+id).value;
	new_price = parseFloat(access_price_tmp)*parseFloat(each_qty_tmp);
	new_each = parseFloat(new_price)/parseFloat(each_qty_tmp);
	document.getElementById('accessory_each_'+id).value = new_each.toFixed(2);
	document.getElementById('accessory_price_'+id).value = new_price.toFixed(2);
	//alert('ID: '+access_price_tmp+' '+each_qty_tmp);
}

function show_product_nav()
{
	document.getElementById('product_nav_heading').style.background="#394ba9 url(/media/images/skin/nav_header_bg_sel.jpg)";
	document.getElementById('mugs_nav_heading').style.background="#394ba9 url(/media/images/skin/nav_header_bg.jpg)";
	document.getElementById('pos_nav_heading').style.background="#394ba9 url(/media/images/skin/nav_header_bg.jpg)";
	document.getElementById('pens_nav_heading').style.background="#394ba9 url(/media/images/skin/nav_header_bg.jpg)";
	document.getElementById('accessories_nav_heading').style.background="#394ba9 url(/media/images/skin/nav_header_bg.jpg)";
	document.getElementById('promo_nav_heading').style.background="#394ba9 url(/media/images/skin/nav_header_bg.jpg)";
	$("#nav_show_product").slideDown(1000);
	$("#nav_show_mugs").slideUp(1000);
	$("#nav_show_pos").slideUp(1000);
	$("#nav_show_pens").slideUp(1000);
	$("#nav_show_accessories").slideUp(1000);
	$("#nav_show_promo").slideUp(1000);
	document.getElementById('anc_product_nav_heading').style.color="#6367ae";
	document.getElementById('anc_mugs_nav_heading').style.color="#fff";
	document.getElementById('anc_pos_nav_heading').style.color="#fff";
	document.getElementById('anc_pens_nav_heading').style.color="#fff";
	document.getElementById('anc_accessories_nav_heading').style.color="#fff";
	document.getElementById('anc_promo_nav_heading').style.color="#fff";
}

function show_event_nav()
{
	document.getElementById('event_nav_heading').style.background="#394ba9 url(/media/images/skin/nav_header_bg_sel.jpg)";
	document.getElementById('product_nav_heading').style.background="#394ba9 url(/media/images/skin/nav_header_bg.jpg)";
	document.getElementById('accessories_nav_heading').style.background="#394ba9 url(/media/images/skin/nav_header_bg.jpg)";
	document.getElementById('promo_nav_heading').style.background="#394ba9 url(/media/images/skin/nav_header_bg.jpg)";
	$("#nav_show_event").slideDown(1000);
	$("#nav_show_product").slideUp(1000);
	$("#nav_show_accessories").slideUp(1000);
	$("#nav_show_promo").slideUp(1000);
	document.getElementById('anc_event_nav_heading').style.color="#6367ae";
	document.getElementById('anc_product_nav_heading').style.color="#fff";
	document.getElementById('anc_accessories_nav_heading').style.color="#fff";
	document.getElementById('anc_promo_nav_heading').style.color="#fff";
}

function show_accessories_nav()
{
	document.getElementById('accessories_nav_heading').style.background="#394ba9 url(/media/images/skin/nav_header_bg_sel.jpg)";
	document.getElementById('product_nav_heading').style.background="#394ba9 url(/media/images/skin/nav_header_bg.jpg)";
	document.getElementById('pens_nav_heading').style.background="#394ba9 url(/media/images/skin/nav_header_bg.jpg)";
	document.getElementById('mugs_nav_heading').style.background="#394ba9 url(/media/images/skin/nav_header_bg.jpg)";
	document.getElementById('pos_nav_heading').style.background="#394ba9 url(/media/images/skin/nav_header_bg.jpg)";
	document.getElementById('promo_nav_heading').style.background="#394ba9 url(/media/images/skin/nav_header_bg.jpg)";
	$("#nav_show_accessories").slideDown(1000);
	$("#nav_show_product").slideUp(1000);
	$("#nav_show_pens").slideUp(1000);
	$("#nav_show_mugs").slideUp(1000);
	$("#nav_show_pos").slideUp(1000);
	$("#nav_show_promo").slideUp(1000);
	document.getElementById('anc_accessories_nav_heading').style.color="#6367ae";
	document.getElementById('anc_product_nav_heading').style.color="#fff";
	document.getElementById('anc_pens_nav_heading').style.color="#fff";
	document.getElementById('anc_mugs_nav_heading').style.color="#fff";
	document.getElementById('anc_pos_nav_heading').style.color="#fff";
	document.getElementById('anc_promo_nav_heading').style.color="#fff";
}

function show_mugs_nav()
{
	document.getElementById('mugs_nav_heading').style.background="#394ba9 url(/media/images/skin/nav_header_bg_sel.jpg)";
	document.getElementById('product_nav_heading').style.background="#394ba9 url(/media/images/skin/nav_header_bg.jpg)";
	document.getElementById('pens_nav_heading').style.background="#394ba9 url(/media/images/skin/nav_header_bg.jpg)";
	document.getElementById('pos_nav_heading').style.background="#394ba9 url(/media/images/skin/nav_header_bg.jpg)";
	document.getElementById('accessories_nav_heading').style.background="#394ba9 url(/media/images/skin/nav_header_bg.jpg)";
	document.getElementById('promo_nav_heading').style.background="#394ba9 url(/media/images/skin/nav_header_bg.jpg)";
	$("#nav_show_mugs").slideDown(1000);
	$("#nav_show_product").slideUp(1000);
	$("#nav_show_pens").slideUp(1000);
	$("#nav_show_pos").slideUp(1000);
	$("#nav_show_accessories").slideUp(1000);
	$("#nav_show_promo").slideUp(1000);
	document.getElementById('anc_mugs_nav_heading').style.color="#6367ae";
	document.getElementById('anc_product_nav_heading').style.color="#fff";
	document.getElementById('anc_pens_nav_heading').style.color="#fff";
	document.getElementById('anc_pos_nav_heading').style.color="#fff";
	document.getElementById('anc_accessories_nav_heading').style.color="#fff";
	document.getElementById('anc_promo_nav_heading').style.color="#fff";
}

function show_pens_nav()
{
	document.getElementById('pens_nav_heading').style.background="#394ba9 url(/media/images/skin/nav_header_bg_sel.jpg)";
	document.getElementById('product_nav_heading').style.background="#394ba9 url(/media/images/skin/nav_header_bg.jpg)";
	document.getElementById('mugs_nav_heading').style.background="#394ba9 url(/media/images/skin/nav_header_bg.jpg)";
	document.getElementById('pos_nav_heading').style.background="#394ba9 url(/media/images/skin/nav_header_bg.jpg)";
	document.getElementById('promo_nav_heading').style.background="#394ba9 url(/media/images/skin/nav_header_bg.jpg)";
	document.getElementById('accessories_nav_heading').style.background="#394ba9 url(/media/images/skin/nav_header_bg.jpg)";
	$("#nav_show_pens").slideDown(1000);
	$("#nav_show_product").slideUp(1000);
	$("#nav_show_mugs").slideUp(1000);
	$("#nav_show_pos").slideUp(1000);
	$("#nav_show_promo").slideUp(1000);
	$("#nav_show_accessories").slideUp(1000);
	document.getElementById('anc_pens_nav_heading').style.color="#6367ae";
	document.getElementById('anc_product_nav_heading').style.color="#fff";
	document.getElementById('anc_mugs_nav_heading').style.color="#fff";
	document.getElementById('anc_pos_nav_heading').style.color="#fff";
	document.getElementById('anc_promo_nav_heading').style.color="#fff";
	document.getElementById('anc_accessories_nav_heading').style.color="#fff";
}

function show_promo_nav()
{
	document.getElementById('promo_nav_heading').style.background="#394ba9 url(/media/images/skin/nav_header_bg_sel.jpg)";
	document.getElementById('pens_nav_heading').style.background="#394ba9 url(/media/images/skin/nav_header_bg.jpg)";
	document.getElementById('pos_nav_heading').style.background="#394ba9 url(/media/images/skin/nav_header_bg.jpg)";
	document.getElementById('product_nav_heading').style.background="#394ba9 url(/media/images/skin/nav_header_bg.jpg)";
	document.getElementById('mugs_nav_heading').style.background="#394ba9 url(/media/images/skin/nav_header_bg.jpg)";
	document.getElementById('accessories_nav_heading').style.background="#394ba9 url(/media/images/skin/nav_header_bg.jpg)";
	$("#nav_show_promo").slideDown(1000);
	$("#nav_show_product").slideUp(1000);
	$("#nav_show_pos").slideUp(1000);
	$("#nav_show_pens").slideUp(1000);
	$("#nav_show_mugs").slideUp(1000);
	$("#nav_show_accessories").slideUp(1000);
	document.getElementById('anc_promo_nav_heading').style.color="#6367ae";
	document.getElementById('anc_pens_nav_heading').style.color="#fff";
	document.getElementById('anc_pos_nav_heading').style.color="#fff";
	document.getElementById('anc_product_nav_heading').style.color="#fff";
	document.getElementById('anc_mugs_nav_heading').style.color="#fff";
	document.getElementById('anc_accessories_nav_heading').style.color="#fff";
}

function show_pos_nav()
{
	document.getElementById('pos_nav_heading').style.background="#394ba9 url(/media/images/skin/nav_header_bg_sel.jpg)";
	document.getElementById('mugs_nav_heading').style.background="#394ba9 url(/media/images/skin/nav_header_bg.jpg)";
	document.getElementById('product_nav_heading').style.background="#394ba9 url(/media/images/skin/nav_header_bg.jpg)";
	document.getElementById('pens_nav_heading').style.background="#394ba9 url(/media/images/skin/nav_header_bg.jpg)";
	document.getElementById('accessories_nav_heading').style.background="#394ba9 url(/media/images/skin/nav_header_bg.jpg)";
	document.getElementById('promo_nav_heading').style.background="#394ba9 url(/media/images/skin/nav_header_bg.jpg)";
	$("#nav_show_pos").slideDown(1000);
	$("#nav_show_mugs").slideUp(1000);
	$("#nav_show_product").slideUp(1000);
	$("#nav_show_pens").slideUp(1000);
	$("#nav_show_accessories").slideUp(1000);
	$("#nav_show_promo").slideUp(1000);
	document.getElementById('anc_pos_nav_heading').style.color="#6367ae";
	document.getElementById('anc_mugs_nav_heading').style.color="#fff";
	document.getElementById('anc_product_nav_heading').style.color="#fff";
	document.getElementById('anc_pens_nav_heading').style.color="#fff";
	document.getElementById('anc_accessories_nav_heading').style.color="#fff";
	document.getElementById('anc_promo_nav_heading').style.color="#fff";
}

function show_offers_nav()
{
	/*document.getElementById('nav_show_offers').style.display="block";*/
	$("#nav_show_offers").slideDown(1000);
	document.getElementById('offers_nav_heading').style.background="#394ba9 url(/media/images/skin/nav_header_bg_sel.jpg)";
	document.getElementById('anc_offers_nav_heading').style.color="#6367ae";
}

function switch_tab(show,hide,hide2)
{
	if (document.getElementById)
	{
		document.getElementById('area_'+show).style.display="block";
		document.getElementById('tab_'+show).style.background="#ffffff";
		document.getElementById('tab_'+show).style.borderBottom="1px solid #ffffff";
		document.getElementById('anchor_'+show).style.color="#000000";
		document.getElementById('area_'+hide).style.display="none";
		document.getElementById('tab_'+hide).style.background="#867fbc";
		document.getElementById('tab_'+hide).style.borderBottom="1px solid #5958b3";
		document.getElementById('anchor_'+hide).style.color="#fff";
		document.getElementById('area_'+hide2).style.display="none";
		document.getElementById('tab_'+hide2).style.background="#867fbc";
		document.getElementById('tab_'+hide2).style.borderBottom="1px solid #5958b3";
		document.getElementById('anchor_'+hide2).style.color="#fff";
		return false;
	}
	else
	{
		return true;
	}
}

function show_nav_sub(nav_ul)
{
	$("#"+nav_ul).slideToggle(500);
	/*if(document.getElementById(nav_ul).style.display=="block")
	{
		document.getElementById(nav_ul).style.display="none"
	}
	else
	{
		document.getElementById(nav_ul).style.display="block"
	}*/
}

