function LTrim(str) { 
 for (var k=0; k<str.length && str.charAt(k)<=" " ; k++) ;
 return str.substring(k,str.length);
}
function RTrim(str) {
 for (var j=str.length-1; j>=0 && str.charAt(j)<=" " ; j--) ;
 return str.substring(0,j+1);
}
function Trim(str) {
 return LTrim(RTrim(str));
}


//verisign popup
dn="WWW.MACHINEMART.CO.UK";
lang="en";
aff="VeriSignUK";
tpt="opaque";
vrsn_style="WW";
splash_url="https://seal.verisign.com";
seal_url="https://seal.verisign.com";
u1=splash_url+"/splash?form_file=fdf/splash.fdf&dn="+dn+"&lang="+lang;
u2=seal_url+"/getseal?at=0&&sealid=2&dn="+dn+"&aff="+aff+"&lang="+lang;
function vrsn_splash() {
tbar = "location=yes,status=yes,resizable=yes,scrollbars=yes,width=560,height=500";
sw = window.open(u1,'VRSN_Splash',tbar);
sw.focus();
}

var ver=-1;
var v_ua=navigator.userAgent.toLowerCase();
var re=new RegExp("msie ([0-9]{1,}[\.0-9]{0,})");
if (re.exec(v_ua) != null)
 ver = parseFloat( RegExp.$1 );
var v_old_ie=(v_ua.indexOf("msie")!=-1);
if (v_old_ie) {
 v_old_ie = ver < 5;
}

function v_mact(e){
 if (document.addEventListener) {
  var s=(e.target.name=="seal");
   if (s) { vrsn_splash(); return false; }
 }else if(document.captureEvents) {
  var tgt=e.target.toString(); var s=(tgt.indexOf("splash")!=-1);
  if (s){ vrsn_splash(); return false; }
 }
 return true;
}
function v_mDown() {
if (event.button==1){
  if (v_old_ie) { return true; } else { vrsn_splash(); return false; }
} else if (event.button==2) { vrsn_splash(); return false; }
}


if (document.addEventListener){ document.addEventListener('mouseup', v_mact, true); } 
else {
  if (document.layers){
    document.captureEvents(Event.MOUSEDOWN); document.onmousedown=v_mact;
  }
}
function v_resized(){
  if(pageWidth!=innerWidth || pageHeight!=innerHeight){
    self.history.go(0);
  }
}
if(document.layers){
  pageWidth=innerWidth; pageHeight=innerHeight; window.onresize=v_resized;
}



function fnShowOverlay() {
	var dblOpacity = 0.5;
	var arrayPageSize = getPageSize();	
	var objOverlay = document.getElementById("overlay");
	objOverlay.style.width = arrayPageSize[0] + "px";
	objOverlay.style.height = arrayPageSize[1] + "px";
	objOverlay.style.display = "block";
	objOverlay.style.opacity = dblOpacity;
	objOverlay.style.filter = 'alpha(opacity=' + dblOpacity*100 + ')';	
}

function fnCloseOverlay() {
	document.getElementById("overlay").style.display = 'none';
}

//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.com
// Edit for Firefox by pHaez
//
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	
	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}



