function vaultyGetObject(name) {
  if (document.getElementById) {
  	this.obj = document.getElementById(name);
	if ( this.obj == null ) return this;
	this.style = document.getElementById(name).style;
  } else if (document.all) {
	this.obj = document.all[name];
	if ( this.obj == null ) return this;
	this.style = document.all[name].style;
  } else if (document.layers) {
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
  }
}

///////////////////////////////////////////	
	var VAULTY_SIGN = 'vaultyCert';
	var VAULTY_CERT = 'vaultyCertData'; 		
	function vaultyGetX(e) { 
		var docW = vaultyGetDocProps( true );
		var x = (document.all) ? (window.event.clientX+document.body.scrollLeft) : e.pageX; 
		if ( (docW-x) < VAULTY_WIDTH ) x -= VAULTY_WIDTH;
		return x;
	}
	function vaultyGetY(e) { 
		var docH = vaultyGetDocProps( false );
		var y = (document.all) ? (window.event.clientY+document.body.scrollTop) : e.pageY; 
		if ( (docH-y) < VAULTY_HEIGHT ) y -= VAULTY_HEIGHT;
		if ( y < VAULTY_HEIGHT ) y = VAULTY_HEIGHT;
		return y; 
	}	

	var _vaultyRegistered = false;	
	var _vaultyHtml = "";
	var _vaultyUrl = "";
	var _vaultyVisible = false;
	var _vaultyCert = new Object();	
	
	function vaultyRegister( cid, wsid, pid, piid ) {			
		_vaultyUrl =  VAULTY_URL + "?v_type=0&cid=" + cid + "&wsid=" + wsid + "&pid=" + pid;
		var x = new vaultyGetObject( VAULTY_SIGN + pid + piid );		 

		if ( null == x.obj ) return;
		x.obj.onmouseover = vaultyOnOver;
		x.obj.onmouseout = vaultyOnOut;
		x.obj.onmouseup = vaultyOnMouse;
		x.obj.onmousedown = vaultyOnMouse;		
		if (x.obj.captureEvents) {
			x.obj.captureEvents(Event.MOUSEOVER);
			x.obj.captureEvents(Event.MOUSEOUT);
			x.obj.captureEvents(Event.MOUSEUP);			
			x.obj.captureEvents(Event.MOUSEDOWN);						
		}	
		_vaultyRegistered = true;		
	}			
	function vaultyOnMouse(e) {
		if (!e) e = window.event; 
		if (e.which && e.which > 1){
			alert(VAULTY_IMG_MSG);
		  	return false;
	   } else if (e.button && (e.button >1)) {
	   		alert(VAULTY_IMG_MSG);
			return false;
	   }	
	}
	function vaultyOnOver(e) {			
		_vaultyCert = new vaultyGetObject( VAULTY_CERT );		
		
		_vaultyCert.obj.innerHTML = '<iframe scrolling="no" marginheight="0" marginwidth="0" style="background-color: transparent;" src="' +_vaultyUrl+ '" frameborder="0" id="buffer" name="buffer" width="' +VAULTY_WIDTH+ '" height="'+VAULTY_HEIGHT+'" style="width: '+VAULTY_WIDTH+'px; height: '+VAULTY_HEIGHT+'px; visibility: visible;"></iframe>';
		_vaultyCert.style.zIndex = 1000;
		_vaultyCert.style.position = "absolute";
		_vaultyCert.style.top = vaultyGetY(e) + "px";
		_vaultyCert.style.left = vaultyGetX(e) + "px";
		_vaultyCert.style.display = 'block';		
	}	
	function vaultyOnOut(e)	 {
		vaultyHideCert(e);
	}	
	function vaultyLoadCert() {
		_vaultyCert.obj.innerHTML = _vaultyHtml;		
	}
	function vaultyShowCert(e) {	
		if ( _vaultyVisible ) return;		
		_vaultyCert.style.zIndex = 1000;
		_vaultyCert.style.position = "absolute";
		_vaultyCert.style.top = vaultyGetY(e);
		_vaultyCert.style.left = vaultyGetX(e);
		_vaultyCert.style.display = 'block';		
		_vaultyVisible = true;
	}
	function vaultyHideCert() {
		_vaultyCert.style.display = 'none';
		_vaultyVisible = false;
	}	
	function vaultyClick( cid, wsid, pid ) {
		var url =  VAULTY_URL + "?v_type=1&cid=" + cid + "&wsid=" + wsid + "&pid=" + pid;
		var wnd = window.open( url, 'wndVaultyCertificate', 'width=460,height=400,scrollbars=1' );
		wnd.focus();
	}
	function vaultyGetDocProps( bWidth ) {
		if (self.innerWidth) {
			return bWidth ? self.innerWidth : self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientWidth) {
			return bWidth ? document.documentElement.clientWidth : document.documentElement.clientHeight;
		} else if (document.body) {
			return bWidth ? document.body.clientWidth: document.body.clientHeight;
		}
	}
			
	var VAULTY_URL = "http://www.vaulty.com/vault/verify.php"; 
	var VAULTY_VAULT_IMAGES_URL = "http://www.vaulty.com/vault/images/";
	var VAULTY_HEIGHT = 181;
	var VAULTY_WIDTH = 240;
	var VAULTY_IMG_MSG = "*** VAULTY.COM VERIFICATION PROTECTION! *** "
	function VaultySign( cid, wsid, pid, piid ) {		
		document.write( '<img src="' +VAULTY_VAULT_IMAGES_URL+'st' + piid + '.gif" id="vaultyCert'+pid+piid+'" onmouseover="vaultyRegister( '+ cid +',' + wsid +',' + pid + ',' + piid + ')" onmousedown="return false;" onmouseup="return false;" onClick="vaultyClick( '+ cid +',' + wsid +',' + pid + ')">' );
		document.write( '<div id="vaultyCertData" style="z-index: 100;"></div>' );
		vaultyRegister( cid, wsid, pid, piid );			
	}
