﻿var POP_UP_DIV_ID='proposalPopUp';
//Style Setup Sequence: display,width,height,top,left,padding-Left,padding-Right,padding-Top,padding-Bottom,background-Color
var POP_UP_STYLE= new popUpStyle("inline","629px",false,"85px",(screen.width-629)/2+"px","20px","20px","20px","20px","#FFFFFF");//SetUp Default Style;
var RECEIVE_FLAG=false;
function sendRequest(url,callback,postData) {
	var req = createXMLHTTPObject();
	if (!req) return;
	var method = (postData) ? "POST" : "GET";
	req.open(method,url,true);
	if (postData){req.setRequestHeader('Content-type','application/x-www-form-urlencoded');}
	req.onreadystatechange = function () {
		if (req.readyState != 4) return;
		if (req.status != 200 && req.status != 304) {
			return;
		}
		callback(req);
	}
	if (req.readyState == 4) return;
	req.send(postData);
}
function createXMLHTTPObject() {
	var xmlhttp = false;
	var XMLHttp = [
	function () {return new XMLHttpRequest()},					//Modern Browsers
	function () {return new ActiveXObject("Msxml2.XMLHTTP")},
	function () {return new ActiveXObject("Msxml3.XMLHTTP")},
	function () {return new ActiveXObject("Microsoft.XMLHTTP")}
	];
	for (var i=0;i<XMLHttp.length;i++) {
		try {xmlhttp = XMLHttp[i]();}
		catch (e) {	continue;}
		break;
	}
	return xmlhttp;
}
//Process Returned Result from request
function processRequest(req) {
	var d=document.getElementById(POP_UP_DIV_ID);	//Get Popup DIV
	if(!d){	//Create Popup DIV if not found
		d=document.createElement("DIV");
		d.id=POP_UP_DIV_ID;
		d.style.display='none';
		if(document.body){document.body.appendChild(d)};	
	}
	//Check DIV and returned data
	if(d && req.responseText){
		RECEIVE_FLAG = true;	//Mark flag
		d.innerHTML = req.responseText;	//Fill DIV with returned data
		alterPopUpStyle();	//Process style change
	}
}
//Function to alter DIV layer display style
function alterPopUpStyle(){
	if(RECEIVE_FLAG){
		var d= document.getElementById(POP_UP_DIV_ID);
		if(d){
			if(POP_UP_STYLE.display){d.style.display=POP_UP_STYLE.display;}
			d.style.borderStyle='solid';
			d.style.borderWidth='1px';
			d.style.position='absolute';
			if(POP_UP_STYLE.width){d.style.width=POP_UP_STYLE.width;}
			if(POP_UP_STYLE.height){d.style.height=POP_UP_STYLE.height;}
			if(POP_UP_STYLE.top){d.style.top=POP_UP_STYLE.top;}
			if(POP_UP_STYLE.left){d.style.left=POP_UP_STYLE.left;}
			if(POP_UP_STYLE.pLeft){d.style.paddingLeft=POP_UP_STYLE.pLeft;}
			if(POP_UP_STYLE.pRight){d.style.paddingRight=POP_UP_STYLE.pRight;}
			if(POP_UP_STYLE.pTop){d.style.paddingTop=POP_UP_STYLE.pTop;}
			if(POP_UP_STYLE.pBottom){d.style.paddingBottom=POP_UP_STYLE.pBottom;}
			if(POP_UP_STYLE.backgroundColor){d.style.backgroundColor=POP_UP_STYLE.backgroundColor;}		
		}
	}
}
//Function to hide PopUp Layer
function hidePopWin(){var d= document.getElementById(POP_UP_DIV_ID);if(d){d.style.display='none';}}
//Pop Up Style Class
function popUpStyle(display,width,height,top,left,pLeft,pRight,pTop,pBottom,bgColor){
	this.display=display;
	this.width=width;
	this.height=height;
	this.top=top;
	this.left=left;
	this.paddingLeft=pLeft;
	this.paddingRight=pRight;
	this.paddingTop=pTop;
	this.paddingBottom=pBottom;
	this.backgroundColor=bgColor;
	this.getDefaultLPos=function(){if(this.width){return(screen.width-this.width)/2;}else{return 0;}}
}
