String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}

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_validateForm() { //v4.0
	document.MM_returnValue = false;
	var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
	for (i=0; i<(args.length-2); i+=3) { 
		test=args[i+2]; 
		val=MM_findObj(args[i]);
		if (val) {
			nm=val.name; 
			if (args[i+1] != "")
				nm = args[i+1];
			if ((val=val.value)!="") {
				if (test.indexOf('isEmail')!=-1) { 
					p=val.indexOf('@');
					if (p<1 || p==(val.length-1)) 
						errors+='- '+nm+' must contain an e-mail address.\n';
				} 
				else if (test!='R') { 
					num = parseFloat(val);
					if (isNaN(val)) 
						errors+='- '+nm+' must contain a number.\n';
					if (test.indexOf('inRange') != -1) { 
						p=test.indexOf(':');
						min=test.substring(8,p); 
						max=test.substring(p+1);
						if (num<min || max<num) 
							errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
					} 
				} 
			}
			else if (test.charAt(0) == 'R') 
				errors += '- '+nm+' is required.\n'; 
		}
	} 
	if (errors) 
		alert('The following error(s) occurred:\n'+errors);
	document.MM_returnValue = (errors == '');
}

function Help(W,H,url) {
    helpwin = window.open('','help',
        'width='+W+',height='+H+',toolbars=0,scrollbars=1,location=0,statusbars=0,menubar=0,resizable=1');
    helpwin.focus();
    helpwin.location = url;

}

function TestWindow(W,H,url) {
    helpwin = window.open('','help',
        'width='+W+',height='+H+',toolbars=1,scrollbars=1,location=0,statusbars=0,menubar=0,resizable=1');
    helpwin.focus();
    helpwin.location = url;
	 return false;
}

lightbox = null;
darkbox = null;
lightboxclose = null;
loadingbox = null;

function myGetWindowHeight() {
	if( typeof( window.innerWidth ) == 'number' ) {
		return myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		return document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		return document.body.clientHeight;
	}
}

function myGetWindowWidth() {
	if( typeof( window.innerWidth ) == 'number' ) {
		return window.innerWidth;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		return document.documentElement.clientWidth;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		return document.body.clientWidth;
	}
}

function myGetScrollX() {
  var scrOfX = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    scrOfX = document.documentElement.scrollLeft;
  }
  return scrOfX;
}

function myGetScrollY() {
  var scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    scrOfY = window.pageYOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    scrOfY = document.body.scrollTop;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    scrOfY = document.documentElement.scrollTop;
  }
  return scrOfY;
}

function loadSuccess() {
	lb = lightbox;
	lb.style.display = "block";
	lb.style.zIndex = "99999";
	pad = 10;
	lb.style.left = ((myGetWindowWidth() / 2 ) - (this.width + pad) / 2  + myGetScrollX()) + "px";
	lby = ((myGetWindowHeight() / 2 ) - (this.height + pad) / 2  + myGetScrollY());
	lb.style.top =  lby + "px";
	if(lby < myGetScrollY()) lb.style.top = (myGetScrollY()+25)+ "px";
	lb.style.width = this.width + pad + "px";
	lb.style.height = this.height + pad + "px";
	lb.style.padding = pad + "px";
	lb.appendChild(this);
	body = document.body;
	darkbox.innerHTML = "";
	body.appendChild(lightbox);
}

function loadFailure() {
	alert(this.name + " failed to load");
}

function openLightBox(img) {
	body = document.body;
	darkbox = document.createElement('div');
	darkbox.setAttribute("id","darkbox");
	darkbox.style.width = myGetWindowWidth() + "px";
	darkbox.style.height = myGetWindowHeight() + "px";
	lightbox = document.createElement('div');
	lightbox.setAttribute("id","lightbox");
	lightboxclose = document.createElement('div');
	lightboxclose.setAttribute('id','close');
	lightboxclose.innerHTML = 
'<a style="cursor:pointer;" onclick="closeLightbox();"><img src="/images/closegif.gif"></a>';
	lightbox.appendChild(lightboxclose);
	var image = new Image();
	image.name = "lightbox: "+img;
	image.onload = loadSuccess;
	image.onerror = loadFailure;
	image.src = img;
	
	db = darkbox;
	db.style.display = "block";
	db.style.zIndex = "99998";
	
	body.appendChild(darkbox);
	
	darkbox.innerHTML = '<div style="margin-top: 300px; color:white; font-size: 12px;">'+
	'<img style="display: inline;" src="/images/loading.gif" alt="" style="vertical-align: bottom;"> Loading...'+
		'</div>';
}

function closeLightbox() {
	body.removeChild(lightbox);
	body.removeChild(darkbox);
}


function screen() {
	javascript:alert('Your resolution is '+screen.width+'x'+screen.height);	
}

//javascript:alert('Your resolution is '+screen.width+'x'+screen.height);






