var isCGSChat;

function launchCGSChatPopup() {

	isCGSChat = 'yes';
	launchChatPopup_cgs();
}


function launchChatPopup_cgs() {

	var winW;
	var winH;
	var newH;
	var loadPage;
	
	if(isCGSChat == 'yes'){
		loadPage = 'cgsform.html';
		isCGSChat = '';

	}
	else{
		loadPage = 'genformsecure.html';
	}

// set a default target height for the window in case we can't calculate one dynamically

	var targetH = 300;

// set default height and width for the screen in case we can't sniff one

	var screenW = 800;
	var screenH = 600;

// get the screen width and height to make sure we don't size things inappropriately



// get window width and height. if we get it, we reset the default target height to
// the current window height.
// first property is IE implementation, second is Moz/Gecko/Saf.
// Moz/Gecko/Saf recognize IE function, but some return bad numbers, so
// calling it second corrects the var values.



// calculate the difference in height between the screen and the window



// we only resize the window if it's too tall to display the popup...

// ...or if it's so short that we think it will need to be resized to cover the popup


// set the new window height

// resize the parent window



// now we get the parent window position and move if absolutely necessary to work well with the popup.
// if we can't get it, we'll move the window to the top left by default

	topP = 1;
	leftP = 1;

// first method Moz/Gecko (Safari?), second method IE. For IE we can only get the position of the display screen,
// so we additionally subtract the height and width of the window frame and toolbars with default installation settings.



// failsafe to correct for unfriendly IE behavior


	
// move parent window and reset it to be resizable, which is sometimes loses in IE



// set top position and tweak width for chat popup window

	var chatTopP = topP + targetH;
	var chatW = winW - 8;
        self.name = "new";
	
//	var chatUrl = httpHost + '/rei/livehelp/genformsecure.html?cm_sp=checkout*livehelp*general'; replaces the line below this for interim.
	var chatUrl = '/rei/livehelp/' + loadPage;
	var newWindow = 'chatPopup';
	var openParams ='width=800' + chatW +',height=300, top =' + chatTopP + ', left=10' + leftP;

	chatPopupOpen = window.open(chatUrl, newWindow, openParams);
	if(window.focus){
		chatPopupOpen.focus();
	}
}