
var passport = new bulldogPassport();
bulldogPassport.prototype.contentdiv;

function bulldogPassport () {
	//create content div
};

function openReg()
{
passport.showRegistration();
}

function closeReg()
{
passport.close();
return true;
}
	//contentDiv handlers ---------------------------------------------------------------
	bulldogPassport.prototype._createContentDiv = function() {
		try {
			if (this.contentDiv) {
			}else{
				var bulldogDiv =  document.createElement("div");
				bulldogDiv.setAttribute("id","bulldogReg");
				document.body.appendChild(bulldogDiv);
				this.contentDiv = bulldogDiv;
				grow(this.contentDiv);	
								
			};
			
			return true;
		
		}catch(err){
			this._processJSError(err.message);
			return false;
		};
	};
	
	bulldogPassport.prototype._destroyContentDiv = function() {
		try {
		
			document.body.removeChild(this.contentDiv);
			this.contentDiv = null;
		
		}catch(err){
			this._processJSError(err.message);
			return false;
		};
	};


	bulldogPassport.prototype.close = function() {
		try {
			this._destroyContentDiv();
		}catch(err){
		
		};
	};




	bulldogPassport.prototype.showRegistration = function() {
		try {
			this._getRegistrationForm();
    		center(this.contentDiv.firstChild);
		    return true;
		}catch(err){
			this._processJSError(err.message);
			return false;
		};	
	};





bulldogPassport.prototype._getRegistrationForm = function() {
	/* In the non-demo version, these will be pulled from the server via AJAX */
	
		try{
			//Create Content Div if missing and Assign
			this._createContentDiv();
			
			var FormData =	"<div id=\"RegistrationForm\"> " +
					"<iframe src=\"frmRegistration.aspx\" width=\"361\" height=\"500\" frameborder=\"0\" allowtransparency=\"false\"></ />" +
					"</div>" ;
		
			this.contentDiv.innerHTML = FormData;
            //this._processFormError("All Fields Required");
			//document.getElementById("bulldogIDusername").focus;
			return true;
			
		}catch(err){
			this._processJSError(err.message);
			return false;
		}	
	};
	
	

	bulldogPassport.prototype._processJSError = function(errmsg){
		try{
			alert(errmsg);
			return true;
		}catch(err){
		    alert(err.message);
		    
		};
	};
	
	/*FORMATTING FUNCTIONALITY */
	function grow(element){
	    var my_width = 0;
	    var my_height = 0;
	
		if (window.innerHeight && window.scrollMaxY) {// Firefox
			my_height = window.innerHeight + window.scrollMaxY;
			my_width = window.innerWidth + window.scrollMaxX;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			my_height = document.body.scrollHeight;
			my_width = document.body.scrollWidth;
		} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
			my_height = document.body.offsetHeight;
			my_width = document.body.offsetWidth;
	  	}
	    
	    element.style.position = 'absolute';
	
	    element.style.width = my_width + "px";
	    element.style.height  =  my_height + "px";    
	    
	}
	
	function center(element){
	//    try{
	//        element = $(element);
	//    }catch(e){
	//        return;
	 //   }
	
	    var my_width  = 0;
	    var my_height = 0;
	
	    if ( typeof( window.innerWidth ) == 'number' ){
	        my_width  = window.innerWidth;
	        my_height = window.innerHeight;
	    }else if ( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ){
	        my_width  = document.documentElement.clientWidth;
	        my_height = document.documentElement.clientHeight;
	    }
	    else if ( document.body && ( document.body.clientWidth || document.body.clientHeight ) ){
	        my_width  = document.body.clientWidth;
	        my_height = document.body.clientHeight;
	    }
	
	    element.style.position = 'absolute';
	
	    var scrollY = 0;
	
	    if ( document.documentElement && document.documentElement.scrollTop ){
	        scrollY = document.documentElement.scrollTop;
	    }else if ( document.body && document.body.scrollTop ){
	        scrollY = document.body.scrollTop;
	    }else if ( window.pageYOffset ){
	        scrollY = window.pageYOffset;
	    }else if ( window.scrollY ){
	        scrollY = window.scrollY;
	    }
	    
	    
	    var setX = ( my_width  - element.offsetWidth  ) / 2;
	    var setY = ( my_height - element.offsetHeight ) / 2 + scrollY;
	    
	    element.style.left = setX + "px";
	    element.style.top  = setY + "px";
	
	    element.style.display  = 'block';
}