var printWin;
var disclaimerWin;
var mapEPWin;

function closePrintWin()
{
	if(printWin)
	{
		$('dummyContent').parentNode.removeChild($('dummyContent'));
		createCSS('#print_logo','display: none','screen');
		createCSS('#print_url','display: none','screen');
		createCSS('#print_content','width: 100%','screen');
		createCSS('#gototop','display: block','screen');
		printWin.destroy();
	}
}

function openPrintWin(element_id,width,height)
{
	// Print the page first if IE
	if(document.all)
	{
		window.print();
	}


	// Setting defaults
	//var width	= ( !width ? parseInt(getStyle($(element_id),'width')) + 50 : width );
	var width	= 735;
	var height	= ( !height ? parseInt(getStyle($(element_id),'height')) + 200 : height );
	

	// Insert dummy content height to avoid the footer getting dragged upwards
	if(document.all) // if IE
	{
		//var width	= $(element_id).offsetWidth;
		var height	= $(element_id).offsetHeight + 120;
		if(navigator.appVersion.indexOf("6.0") != -1) // if IE 6.0
		{
			var footerH	= $(element_id).offsetHeight + 43;
		}
		else
		{
			var footerH	= $(element_id).offsetHeight + 23;
		}
	}
	else
	{
		var footerH	= $(element_id).offsetHeight + 46;	
	}
	var arrCol	= getElementsByClassName('column_middle');
	arrCol[0].innerHTML += '<div id="dummyContent" style="height: '+ footerH +'px; background-color: #FFFFFF;"></div>';

	// Open win
	printWin = new Window({
						className: "printwin",
						zIndex: 2000,
						maximizable: false,
						resizable: false,
						draggable: false,
						hideEffect: Element.hide,
						showEffect: Element.show,
						minWidth: width,
						minHeight: height,
						destroyOnClose: true});
	printWin.setContent(element_id,false,true);
	printWin.show();
	//printWin.showCenter(false,50);
	printWin.setCloseCallback(closePrintWin);
	printWin.setDestroyOnClose();

	// Resize height
	if(!height) // IE return NaN
	{
		var arr_size	= printWin.getSize();
		printWin.setSize(arr_size['width'],arr_size['height'] + 200);
	}

	// Show misc. content in new win
	createCSS('#print_logo','display: block','screen');
	createCSS('#print_url','display: block','screen');
	createCSS('#print_content','width: 650px','screen');
	createCSS('#gototop','display: none','all');

	// Print the page last if anything else but IE
	if(!document.all)
	{
		window.print();
	}
}

function openDisclaimerWin(urlDisclamer)
{
	// If firefox on mac, we use a more basic approach because of an bug in FF mac
	if(navigator.platform.indexOf("Mac") != -1 && navigator.userAgent.indexOf("Firefox") != -1)
	{
		$('disclaimer').style.display	= 'block';
	}
	else
	{
		disclaimerWin = new Window({
							className: "disclaimerwin",
							maximizable: false,
							resizable: false,
							draggable: true,
							hideEffect: Element.hide,
							showEffect: Element.show,
							minWidth: 870,
							minHeight: 392,
							destroyOnClose: true });
		disclaimerWin.setURL(urlDisclamer);
		disclaimerWin.setZIndex(800000);
		disclaimerWin.showCenter(false,50);
		disclaimerWin.setDestroyOnClose();
		disclaimerWin.show();
	} // END__ all other browsers
}

function openGoogleWin(address) {
	var scrollY = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;

	// Show
	$('googlemap').style.top = '80px';
	$('googlemap').style.display = 'block';
	$('googlemap').style.top = (scrollY + 80) + 'px';
	window.onscroll = function() {
		var scrollY = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
		$('googlemap').style.top = (scrollY + 80) + 'px';
	}

	// Color the links
	var arrLinks = $('googlemap').getElementsByTagName('a');
	if (arrLinks.length > 0) {
		for (var i = 0; i < arrLinks.length; i++) {
			arrLinks[i].style.color = '#009EBA';
		}
	}

	// Position google logo
	var array = $('googlemap').getElementsByClassName('gmnoprint');
	if (array.length > 0) {
		for (var i = 0; i < array.length; i++) {
			if (array[i].style.left == '2px') // Google logo
			{
				array[i].style.left = '9px';
				array[i].style.bottom = '9px';
			}
			if (array[i].style.right == '3px') // terms text
			{
				array[i].style.right = '9px';
				array[i].style.bottom = '9px';
			}
		}
	}

	if (geocoder) {
		geocoder.getLatLng(
			address,
			function(point) {
				if (!point) {
					alert(address + " not found");
				}
				else {
					map.setCenter(point, 13);
					var marker = new GMarker(point);
					map.addOverlay(marker);
					//marker.openInfoWindowHtml(address);
				}
			}
		);
	}
}
function closeGoogleWin()
{
	$('googlemap').style.display	= 'none';
}

function closeDisclaimerWin()
{
	$('disclaimer').style.display	= 'none';
}

function openEPMapWin(urlDisclamer)
{
	if(document.all)
	{
		mapEPWin = new Window({
							className: "mapEPwin",
							maximizable: false,
							resizable: false,
							draggable: true,
							hideEffect: Element.hide,
							showEffect: Element.show,
							minWidth: 920,
							minHeight: 450,
							maxHeight: 450,
							destroyOnClose: true });
		mapEPWin.setURL(urlDisclamer);
		mapEPWin.setZIndex(800000);
		mapEPWin.showCenter(false,65);
		mapEPWin.setDestroyOnClose();
		mapEPWin.show();
		mapEPWin.updateHeight();
	}
	else
	{
	  $('iframeMap').src = urlDisclamer;
	  $('iframeMap').width = "920px";
	  $('iframeMap').height = "450px";
		$('map').style.display	= 'block';
		window.scrollTo(0,1);
	}
}

function closeEPMapWin()
{
	if(mapEPWin)
	{
		mapEPWin.destroy();
	}
	$('map').style.display = 'none';
	$('iframeMap').width = "0px";
	$('iframeMap').height = "0px";

}
