﻿function ShowPopup1()
{
	var popup1 = document.getElementById( 'guide_popup_1' );
	
	g_oClient.CenterElementInWindow( popup1 );
	popup1.style.visibility = 'visible';
}

function HidePopup1()
{
	var popup1 = document.getElementById( 'guide_popup_1' );
	popup1.style.visibility = 'hidden';
}

function HidePopup2()
{
	var popup2 = document.getElementById( 'guide_popup_2' );
	popup2.style.visibility = 'hidden';
}

function HardCopy()
{
	var sel_state_1	= document.getElementById( 'selState1' ).value;
	var txt_city_1	= document.getElementById( 'txtCity1' ).value;
	
	document.getElementById( 'selState2' ).value	= sel_state_1;
	document.getElementById( 'txtCity2' ).value		= txt_city_1;
	
	var popup_1 = document.getElementById( 'guide_popup_1' );
	var popup_2 = document.getElementById( 'guide_popup_2' );
	
	g_oClient.CenterElementInWindow( popup_2 );
	
	popup_1.style.visibility = 'hidden';
	popup_2.style.visibility = 'visible';
	//RedirectToPdf();
}

function SoftCopy1()
{
	var state_sel	= document.getElementById( 'selState1' ).value;
	var city		= document.getElementById( 'txtCity1' ).value;
	
	RedirectToPdf();
}

function SoftCopy2()
{
	var state_sel	= document.getElementById( 'selState2' ).value;
	var city		= document.getElementById( 'txtCity2' ).value;
	
	RedirectToPdf();
}

function RedirectToPdf()
{
	window.location='visitors_guide.aspx'
}

function Submit()
{
	var fname	= document.getElementById( 'txtFirstName' );
	var lname	= document.getElementById( 'txtLastName' );
	var address	= document.getElementById( 'txtAddress' );
	var city	= document.getElementById( 'txtCity2' );
	var zip		= document.getElementById( 'txtZipCode' );
	var county	= document.getElementById( 'txtCounty' );
	
	if( fname.value == '' || lname.value == '' || address.value == '' || 
		city.value == '' || zip.value == '' || county.value == '' )
	{
		alert( 'Please fill in all required field before submitting the request for a guide.' );
		return;
	}
	
	var ajax = new PhAjaxJson();
	ajax.SendRequest( 'request_hard_copy.aspx', '', document.body.getElementsByTagName( 'form' )[0], SubmitCallback );
}

function SubmitCallback( obj )
{
	if( obj.success == 'false' )
		alert( 'Failed to submit your request for a hard copy.  Please try again shortly.' );
		
	RedirectToPdf();
}

function InitPopup1()
{
	var path	= 'system/resources/global/popup/';
	var parent	= document.getElementById( 'popup_1_content_div' );
	
	var close_btn = new PhButton( path+'popup_closeBtn.jpg', 
						  path+'popup_closeBtn_over.jpg', 
						  path+'popup_closeBtn_down.jpg', 28, 18, 
						  'HidePopup1()' );
	close_btn.SetInlineStyles( 'position: absolute; top: -6px; left: 302px;' );							  
						  
	var reset_btn = new PhButton( path+'wantHardCopyBtn.jpg', 
						  path+'wantHardCopyBtn_over.jpg', 
						  path+'wantHardCopyBtn_down.jpg', 127, 44, 
						  'HardCopy()' );
	reset_btn.SetInlineStyles( 'position: absolute; top: 166px; left: 192px;' );
						  
	var submit_btn = new PhButton( path+'readOnlineBtn.jpg', 
						  path+'readOnlineBtn_over.jpg', 
						  path+'readOnlineBtn_down.jpg', 127, 44, 
						  'SoftCopy1()' );
	submit_btn.SetInlineStyles( 'position: absolute; top: 166px; left: 54px; z-index: 2;' );						  						  						  
						  
	reset_btn.AttachToElement( parent );
	submit_btn.AttachToElement( parent );
	close_btn.AttachToElement( parent );	
}

function ResetPopup2()
{
	var elm		= document.getElementById( 'guide_popup_2' );
	var inputs	= elm.getElementsByTagName( 'input' );
	var areas	= elm.getElementsByTagName( 'textarea' );
	var sels	= elm.getElementsByTagName( 'select' );
	var i		= 0;
	
	for( i = 0; i < inputs.length; i++ )
	{
		inputs[i].value = '';
		inputs[i].checked	= false;	
	}
	
	for( i = 0; i < areas.length; i++ )
		areas[i].value = '';
		
	for( i = 0; i < sels.length; i++ )
		sels[i].selectedIndex = 0;
}

function InitPopup2()
{
	var path	= 'system/resources/global/popup/';
	var parent	= document.getElementById( 'popup_2_content_div' );
	
	var close_btn = new PhButton( path+'popup_closeBtn.jpg', 
						  path+'popup_closeBtn_over.jpg', 
						  path+'popup_closeBtn_down.jpg', 28, 18, 
						  'HidePopup2()' );
	close_btn.SetInlineStyles( 'position: absolute; top: -6px; left: 405px;' );							  
						  

	var reset_btn = new PhButton( path+'resetBtn.jpg', 
						  path+'resetBtn_over.jpg', 
						  path+'resetBtn_down.jpg', 88, 39, 
						  'ResetPopup2()' );
	reset_btn.SetInlineStyles( 'position: absolute; top: 449px; left: 240px;' );
						  
	var submit_btn = new PhButton( path+'submitBtn.jpg', 
						  path+'submitBtn_over.jpg', 
						  path+'submitBtn_down.jpg', 88, 39,
						  'Submit()' );
	submit_btn.SetInlineStyles( 'position: absolute; top: 449px; left: 335px; z-index: 2;' );						  						  						  
	
	var nvmd_btn = new PhButton( path+'nevermindBtn.jpg', 
						  path+'nevermindBtn_over.jpg', 
						  path+'nevermindBtn_down.jpg', 208, 39,
						  'SoftCopy2()' );
	nvmd_btn.SetInlineStyles( 'position: absolute; top: 449px; left: 5px; z-index: 2;' );		

	nvmd_btn.AttachToElement( parent );
	reset_btn.AttachToElement( parent );
	submit_btn.AttachToElement( parent );
	close_btn.AttachToElement( parent );	
}

function InitPopup3()
{
	var path	= 'system/resources/global/popup/';
	var parent	= document.getElementById( 'constant_contact_popup_content' );
	
	var close_btn = new PhButton( path+'popup_closeBtn.jpg', 
						  path+'popup_closeBtn_over.jpg', 
						  path+'popup_closeBtn_down.jpg', 28, 18, 
						  'HidePopup3()' );
	close_btn.SetInlineStyles( 'position: absolute; top: -6px; left: 708px;' );							  
	close_btn.AttachToElement( parent );	
}

function HidePopup3()
{
	var popup1	= document.getElementById( 'constant_contact_popup' );
	var ifrm	= document.getElementById( 'ifrmResult' );
	
	popup1.style.visibility = 'hidden';
	ifrm.src = 'constant_contact_form.aspx';
}