var newWindow;
function openPopup(popup_width,popup_height,popup_url,var_name){
	var windowHeight = popup_height;
	var windowWidth = popup_width;
	var windowName = var_name;
	var windowUri = popup_url;

	var centerWidth = (window.screen.width - windowWidth) / 2;
	var centerHeight = (window.screen.height - windowHeight) / 2;

	if ( !newWindow || newWindow.closed ){
		try{
		newWindow = window.open(windowUri, windowName,'addressbar=0,menubar=0,location=0,status=0,scrollbars=yes,resizable=yes,width=' + windowWidth + 
			',height=' + windowHeight + 
			',left=' + centerWidth + 
			',top=' + centerHeight);
			//newWindow.location.href; // throws exception if after reload
			//newWindow.location = windowUri;
		}catch(e){};
	}else if ( newWindow && ! newWindow.closed ){
		newWindow.location.replace(windowUri);
		newWindow.focus();
	}
}

function gotoURL(popup_url , target ,popup_width,popup_height){
		if(target.toLowerCase() == "_self"){
			window.location.replace(popup_url);
		}else if(target.toLowerCase() == "_blank" && popup_width && popup_height){
			openPopup(popup_width,popup_height,popup_url);
		}else{
			if ( !newWindow || newWindow.closed ){
				try{
					newWindow = window.open(popup_url,"newWindow")
				}catch(e){};
			}
			 if ( newWindow && ! newWindow.closed ){
				newWindow.location.replace(windowUri);
				newWindow.focus();
			}
		}
	
	}
function showpoll(id){
	openPopup(800,700,'question.aspx?psid='+ id );
}

function popupWindow() {
	openPopup(800, 600, 'http://support.truecorp.co.th/truecarechat/chat?ch=support.truecorp', 'trueChat');
	// window.open("http://support.truecorp.co.th/truecarechat/chat?ch=support.trueinternet", "_blank", "directories=no,location=no,menubar=no,resizable=yes,status=no,titlebar=no,toolbar=no,width=600,height=500");
	// window.open("http://support.truecorp.co.th/truecarechat/chat?ch=support.truecorp", "_blank", "directories=no,location=no,menubar=no,resizable=yes,status=no,titlebar=no,toolbar=no,width=600,height=500");
} 
