document.domain	= "priceline.com";
var formElements = ['tgUserId', 'tgUserReviewId', 'tgUserFirstName', 'tgUserHomeTown', 'tgUserEmailAddress'
				  , 'tgUserNotificationFlag', 'tgUserSubscriptionFlag', 'tgIsSubmitted'];
var revFrame	= "reviewFrame";
var imgFrame	= "photoFrame";

function populateTGFormFields (tgFormVals) {
	for (var elemId=0; elemId<formElements.length; ++elemId) {
		getElemById(formElements[elemId]).value = tgFormVals[formElements[elemId]];
	}
}

function syncToFrame(iframeWindow) {
	var tgFormVals		= new Object();
	for (var elemId=0; elemId<formElements.length; ++elemId) {
		eval ("tgFormVals." + formElements[elemId] + " = getElemById('" + formElements[elemId] + "').value");
	}
	iframeWindow.populateTGFormFields(tgFormVals, getElemById('tgCID').value);
	adjustIFrameSize (iframeWindow);
}

function setUGCResponse(ugcResponse) {
	if (ugcResponse) {
		if (ugcResponse.userId > 0)
			getElemById('tgUserId').value = ugcResponse.userId;
		if (ugcResponse.reviewId > 0)
			getElemById('tgUserReviewId').value = ugcResponse.reviewId;
	}
}

function resetTgForm() {
	for (var elemId=0; elemId<formElements.length; ++elemId) {
		getElemById(formElements[elemId]).value = "";
	}
}

function tgHideFrame(frameName) {
	var oFrame = (document.frames?document.frames[frameName].window:eval('window.' + frameName));
	closeIFrame(oFrame);
}

function tgShowFrame (frameName, skipSync) {
	var antiFrame = (frameName == revFrame ? imgFrame : revFrame);
	tgHideFrame(antiFrame);

	var oFrame = (document.frames?document.frames[frameName].window:eval('window.' + frameName));
	adjustIFrameSize(oFrame);
	if (!skipSync)
		syncToFrame(oFrame);
}

function adjustIFrameSize (iframeWindow) {
	if (iframeWindow.document.height) {
		var iframeElement = document.getElementById(iframeWindow.name);
		iframeElement.style.height = "0px";
		iframeElement.style.height = iframeWindow.document.body.scrollHeight + 0 + 'px';
	} else if (document.all) {
		var iframeElement = document.all[iframeWindow.name];
		iframeElement.style.height = "0px";
		if (iframeWindow.document.compatMode && iframeWindow.document.compatMode != 'BackCompat') {
			iframeElement.style.height = iframeWindow.document.documentElement.scrollHeight + 0 + 'px';
		} else {
			iframeElement.style.height = iframeWindow.document.body.scrollHeight + 0 + 'px';

		}
	} else {
		var iframeElement = document.getElementById(iframeWindow.name);
		iframeElement.style.height = "0px";
		iframeElement.style.height = iframeWindow.document.body.scrollHeight + 0 + 'px';
	}
}

function closeIFrame (iframeWindow) {
	try {
		if (iframeWindow.document.height) {
			var iframeElement = document.getElementById(iframeWindow.name);
			iframeElement.style.height = '0px';
		} else if (document.all) {
			var iframeElement = document.all[iframeWindow.name];
			if (iframeWindow.document.compatMode && iframeWindow.document.compatMode != 'BackCompat') {
				iframeElement.style.height = '0px';
			} else {
				iframeElement.style.height = '0px';
			}
		} else {
			var iframeElement = document.getElementById(iframeWindow.name);
			iframeElement.style.height = '0px';
		}
	} catch (e) { }
}

function popTGImageURL (url) {
	var width, height, left, top;
	width = 200;
	height = 200;
	left = (screen.availWidth-width)/2;
	top = (screen.availHeight-height)/2;
	var oWnd = window.open(url, 'pclnUGC', 'menubar=no,location=no,directories=no,scrollbars=yes,resizable=yes,status=no,toolbar=no,'
				+ 'width=' + width + ',height=' + height + ',left=' + left + ',top=' + top);
	if (oWnd != null) 
		oWnd.focus();
	else 
		alert ("Your pop-up blocker seems to be enabled.\nPlease turn-off your pop-up blocker to view this information.", "Priceline Travel Guide");
}

function tgViewAllReviews () {
	hideObject ("idMoreReviewLink");
	showObject ("idMoreReviewText");
}