/*Browsercheck object*/
function cm_bwcheck(){
	//In theory we should use object detection, but this script needs work-arounds for almost every browser...
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent.toLowerCase()
	this.dom=document.getElementById?1:0
	this.ns4=(!this.dom && document.layers)?1:0;
	this.op=window.opera 
	this.moz=(this.agent.indexOf("gecko")>-1 || window.sidebar)
	this.ie=this.agent.indexOf("msie")>-1 && !this.op
	if(this.op){
		this.op5=(this.agent.indexOf("opera 5")>-1 || this.agent.indexOf("opera/5")>-1)
		this.op6=(this.agent.indexOf("opera 6")>-1 || this.agent.indexOf("opera/6")>-1)
		this.op7=this.dom&&!this.op5&&!this.op6 //So all higher opera versions will use it
	}else if(this.moz) this.ns6 = 1
	else if(this.ie){
		this.ie4 = !this.dom && document.all
  	this.ie5 = (this.agent.indexOf("msie 5")>-1)
  	this.ie55 = (this.ie5 && this.agent.indexOf("msie 5.5")>-1)
  	this.ie6 = this.dom && !this.ie4 && !this.ie5 && ! this.ie55
	}
	this.mac=(this.agent.indexOf("mac")>-1)
	this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.op5 || this.op6 || this.op7)
  this.usedom= this.ns6||this.op7//Use dom creation
  this.reuse = this.ie||this.op7||this.usedom //Reuse layers
  this.px=this.dom&&!this.op5?"px":""
	return this
}
	
function Replace(sString, sWhat, sBy){
	return sString.replace(sWhat, sBy);
}

function ShowProperties(obj){
	if (obj){
		alert("please wait, loading items")
		var buff;
		for (p in obj) {
			buff += p+' : '+obj[p]+'\n';
		}
		alert("done loading items")
		var width 	= 400;
		var height 	= 400;
		var winl	= ( screen.width  - width  ) / 2;
		var wint	= ( screen.height - height ) / 2;


		var specs = 'toolbar=0,location=0,directories=0,resizable=yes,menubar=0,status=0,scrollbars=yes,width='+ width +',height='+ height +',top='+ wint +',left=' + winl;

		wShowProperties = window.open("","ShowProperties",specs);
		wShowProperties.document.open();
		wShowProperties.document.write("<html><head><title>Properties</title></head><body><pre>" + buff + "</pre></body></html>");
		wShowProperties.document.close();
		wShowProperties.focus();
	}
}

function ValidateZip(f,zip){
		f.elements[zip].value = f.elements[zip].value.toUpperCase();
		var cp = f.elements[zip].value;  
		cp = cp.replace(' ','')
		if(!(cp.length == 6) || 
			!(cp.charAt(0) >= 'A' && cp.charAt(0) <= 'Z') ||
			!(cp.charAt(1) >= '0' && cp.charAt(1) <= '9') ||
			!(cp.charAt(2) >= 'A' && cp.charAt(2) <= 'Z') ||
			!(cp.charAt(3) >= '0' && cp.charAt(3) <= '9') ||
			!(cp.charAt(4) >= 'A' && cp.charAt(4) <= 'Z') ||
			!(cp.charAt(5) >= '0' && cp.charAt(5) <= '9'))  {
			return false;
		}else{
			return true;
		}
	}

var pPW = "";
function popupWindow( height, width, OpenPage, title, resize, scrollbar) 
{ 
	winl            = ( screen.width  - width  ) / 2;
	wint            = ( screen.height - height ) / 2;
	    
	if ( pPW.focus)
	{
		pPW.close();
	}
	    
	pPW = window.open(OpenPage,title,'toolbar=0,location=0,directories=0,resizable=' + resize + ',menubar=0,status=0,scrollbars=' + scrollbar + ',width='+ width +',height='+ height +',top='+ wint +',left=' + winl);
	    
	if ( self.focus ) pPW.focus();    
}

function ShowHideLayer(theObj, vis){
	document.getElementById(theObj).style.display=vis;
}

function ShowLayer(ele){
	ShowHideLayer(ele, 'block');
}

function HideLayer(ele){
	ShowHideLayer(ele, 'none');
}

function enlargePhoto(photo){
	showtrail(photo,'','','1',5,433);
}

function reducePhoto(){
	hidetrail();
}

function Trim(t){
	return t.replace(/(^\s*)|(\s*$)/g, "");
}

function IsValidEmail(sEmail){
	return (sEmail.search("^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+([\.][a-zA-Z0-9-]+)+$") != -1);
}