/* ### This script is to be used when you need to get a contact us form opened within a new window. ### */

var cuWinWidth = 480;
var cuWinHeight = 680; //725;
var cuSubject = "";
var wantCategory = "no"; // Default
var cuWin = "";

function openCUWin(id, url){		

	var addressee = "";	
		
	if(cuWin &&  cuWin.closed == false){
		alert("You can only open one window at a time.\n Please close the other window first.");
		cuWin.focus();
		return;
	}
	
	if(document.getElementById(id)){
		addressee = document.getElementById(id).title;
	}

	if(url.indexOf("?") == -1){
		url += "?id=" + id;
	} else {
		url += "&id=" + id;
	}	

	url += "&addressee=" + addressee;
	url += "&emailSent=no";
	url += "&wantCategory=" + wantCategory;
	url += "&subject=" + cuSubject;
	
	properties = "width=" + cuWinWidth + ",";
	properties += "height=" + cuWinHeight + ",";
	properties += "left=" + getWinLeftPos(cuWinWidth) + ",";
	properties += "top=" + getWinTopPos(cuWinHeight) + ",";
	properties += "titlebar=no,toolbar=no,location=no,resizable=no,status=0,scrollbars=no";

	cuWin = window.open(url,"",properties);	
}	

function openContactUsWin(id){
	var url = "http://www.jtbusa.com/en/about/a-contact.asp";
	openCUWin(id, url);
}

function openContactUs2Win(id){
	var url = "http://www.jtbusa.com/en/about/a-contact.asp?type=2";
	openCUWin(id, url);
}

function setSubject(sub){
	if(sub != "") cuSubject = sub;
}

function setWantCategory(want){
	if(want != "") wantCategory = want;
}

function setWinWidth(w){
	if(450 < parseInt(w)) cuWinWidth = w;	
}

function setWinHeight(h){
	if(500 < parseInt(h)) cuWinHeight = h;	
}

function getWinTopPos(height){

	var posTop = 0;		
	var pageHeight = window.screen.height;		

	posTop = (pageHeight - height) / 2;

	return posTop;	
}

function getWinLeftPos(width){

	var posLeft = 0;	
	var pageWidth = window.screen.width;	

	posLeft = (pageWidth - width) / 2;	

	return posLeft;	
}

function closeContactUs(){
	cuWin.close();
}