﻿
/*community*/
var img_home_community_unique_off = new Image();
img_home_community_unique_off.src = "_images/content/home/community/unique_off.jpg";
var img_home_community_unique_on = new Image();
img_home_community_unique_on.src = "_images/content/home/community/unique_on.jpg";
var img_home_community_neighbor_off = new Image();
img_home_community_neighbor_off.src = "_images/content/home/community/neighbor_off.jpg";
var img_home_community_neighbor_on = new Image();
img_home_community_neighbor_on.src = "_images/content/home/community/neighbor_on.jpg";

var community_tab_images = new Array ( "imgHomeCommunityUnique", "imgHomeCommunityNeighbor" );
var community_tabs = new Array( "img_home_community_unique", "img_home_community_neighbor" );
var community_tab_content = new Array ( "community_tab_content_unique", "community_tab_content_neighbor" );

/*collection*/
var img_home_buildmodel_off = new Image();
img_home_buildmodel_off.src = "_images/content/home/collection/buildmodel_off.jpg";
var img_home_buildmodel_on = new Image();
img_home_buildmodel_on.src = "_images/content/home/collection/buildmodel_on.jpg";
var img_home_tour_off = new Image();
img_home_tour_off.src = "_images/content/home/collection/tour_off.jpg";
var img_home_tour_on = new Image();
img_home_tour_on.src = "_images/content/home/collection/tour_on.jpg";
var img_home_send_off = new Image();
img_home_send_off.src = "_images/content/home/collection/send_off.jpg";
var img_home_send_on = new Image();
img_home_send_on.src = "_images/content/home/collection/send_on.jpg";

function HomeIFrame_ButtonRollover (id, imgSrc){
	var elem = window.frames['ifrm_tertiary_content'].document.getElementById ( id );	
	elem.src = eval ( imgSrc + ".src" );	
}

function HomeIFrame_TabClick (id, imgSrc, contentId){
	var content_type = 'community';
	if( contentId.search(/collection/i) > -1 )
	{
		content_type = 'collection';
	}
	
	HomeIFrame_ResetTabs( content_type );	

	var elem = window.frames['ifrm_tertiary_content'].document.getElementById ( id );	
	elem.src = eval ( imgSrc + ".src" );
	
	var content_elem = window.frames['ifrm_tertiary_content'].document.getElementById ( contentId );
	content_elem.style.display = 'block';
}

function HomeIFrame_ResetTabs ( type ){
	var tab_images;
	var tabs;
	var tab_content;

	if( type == 'community' )
	{
		tab_images = community_tab_images;
		tabs = community_tabs;
		tab_content = community_tab_content;
	}
	
	for (var i = 0; i < tab_images.length; i++ )
		{
			var elem = window.frames['ifrm_tertiary_content'].document.getElementById ( tab_images[i].toString( ) );	
			elem.src = eval ( tabs[i].toString( ) + "_off.src" );
			
			var content_elem = window.frames['ifrm_tertiary_content'].document.getElementById ( tab_content[i].toString( ) );	
			content_elem.style.display = 'none';
		}
}

function HomeIFrame_OpenEmailWindow ( type, id ){
	var base_href = document.getElementsByTagName('base')[0].href;
	var url = base_href + '_cfm/common/emailfriend.cfm?type=' + type + '&id=' + id;
	var name = 'Send_Email_to_Friend';
	var attr = 'location=0,resizable=0,scrollbars=0,width=470,height=479';
	
	var winl = (screen.width - 470) / 2;
    var wint = (screen.height - 479) / 2;
    
    attr += ',top=' + wint + ',left=' + winl;
    
    window.open(url, name, attr);
}

function HomeIFrame_OpenFloorPlanWindow ( pid ){
	var base_href = document.getElementsByTagName('base')[0].href;
	var url = base_href + '_cfm/common/floorplan.cfm?pid=' + pid;
	var name = 'Floor_Plan';
	var attr = 'location=0,resizable=1,scrollbars=1,width=600,height=550';
	
	var winl = (screen.width - 600) / 2;
    var wint = (screen.height - 550) / 2;
    
    attr += ',top=' + wint + ',left=' + winl;
    
    window.open(url, name, attr);
}

function HomeIFrame_OpenDesignHomeDetailWindow ( ihid ){
	var base_href = document.getElementsByTagName('base')[0].href;
	var url = base_href + '_cfm/common/homedetail.cfm?ih=' + ihid;
	var name = 'Designer_Home_Detail';
	var attr = 'location=0,resizable=0,scrollbars=0,width=550,height=320';
	
	var winl = (screen.width - 550) / 2;
    var wint = (screen.height - 320) / 2;
    
    attr += ',top=' + wint + ',left=' + winl;
    
    window.open(url, name, attr);
}

function HomeIFrame_OpenEbrochureWindow ( url ){
	//var url = base_href + '/_cfm/common/homedetail.cfm?ih=' + ihid;
	var name = 'EBrochure_Detail';
	var attr = 'location=0,resizable=0,scrollbars=0,width=900,height=600';
	
	var winl = (screen.width - 900) / 2;
    var wint = (screen.height - 600) / 2;
    
    attr += ',top=' + wint + ',left=' + winl;
    
    window.open(url, name, attr);
}

function HomeIFrame_OpenVirtualTourWindow ( url ){
	//var url = base_href + '/_cfm/common/homedetail.cfm?ih=' + ihid;
	var name = 'VirtualTour_Detail';
	var attr = 'location=0,resizable=0,scrollbars=0,width=900,height=600';
	
	var winl = (screen.width - 900) / 2;
    var wint = (screen.height - 600) / 2;
    
    attr += ',top=' + wint + ',left=' + winl;
    
    window.open(url, name, attr);
}

function AboutIFrame_NewsDetailDisplay(newsid) {
	//var base_href = document.getElementsByTagName('base')[0].href;
	//news is pulled from Hub
    var url = HubRootDirectory + '/cfm/about/press/newsdetail.cfm?nid=' + newsid;
    var name = 'News_Detail';
    var attr = 'location=0,resizable=0,scrollbars=0,width=550,height=614';

    var winl = (screen.width - 550) / 2;
    var wint = (screen.height - 614) / 2;

    attr += ',top=' + wint + ',left=' + winl;

    window.open(url, name, attr);
}


/*HOME COLLECTION SECTION*/
function HomeIFrame_CollectionTabClick ( id, planID){
	var collections_array = window.frames['ifrm_tertiary_content'].document.getElementById ( 'hidCollections' ).value.toString( ).split( '|' );	
	
	//update the value of the selected plan, to load in elevations
	window.frames['ifrm_tertiary_content'].document.getElementById ( 'selected_planid' ).value = planID;
	//put the focus on the form field to trigger the binding
	window.frames['ifrm_tertiary_content'].document.getElementById ( 'selected_planid' ).focus();
	
	for(var i = 0; i < collections_array.length; i++ )
	{
		var tab = window.frames['ifrm_tertiary_content'].document.getElementById ( 'tab_' + collections_array[i].toString( ) );
		var content = window.frames['ifrm_tertiary_content'].document.getElementById ( 'collection_tab_content_' + collections_array[i].toString( ) );
		if(collections_array[i].toString( ) == id)
		{
			tab.className = 'tab_on';
			content.style.display = 'block';
		}
		else
		{
			tab.className = 'tab_off'; 
			content.style.display = 'none';
		}
	}	
}

function HomeIFrame_CollectionModelRollover(hidID, modelID){
	var models_array = window.frames['ifrm_tertiary_content'].document.getElementById ( hidID ).value.toString( ).split( '|' );	
	for(var i = 0; i < models_array.length; i++ )
	{
		var model = window.frames['ifrm_tertiary_content'].document.getElementById ( 'model_' + models_array[i].toString( ) );		
		if(model.className != 'model_on_set')
		{
			if(modelID == models_array[i].toString( ))
			{
				if(model.className == 'model_on')
				{
					model.className = 'model_off';
				}
				else
				{
					model.className = 'model_on';
				}
			}
		}
	}
}

function HomeIFrame_CollectionModelClick(hidID, modelID, planID){
	var models_array = window.frames['ifrm_tertiary_content'].document.getElementById ( hidID ).value.toString( ).split( '|' );	
	//update the value of the selected plan, to load in elevations
	window.frames['ifrm_tertiary_content'].document.getElementById ( 'selected_planid' ).value = planID;
	//put the focus on the form field to trigger the binding
	window.frames['ifrm_tertiary_content'].document.getElementById ( 'selected_planid' ).focus();
	
	for(var i = 0; i < models_array.length; i++ )
	{
		var model = window.frames['ifrm_tertiary_content'].document.getElementById ( 'model_' + models_array[i].toString( ) );
		var modeldetailcontent = window.frames['ifrm_tertiary_content'].document.getElementById ( 'model_details_' + models_array[i].toString( ) );
		var modeldescriptioncontent = window.frames['ifrm_tertiary_content'].document.getElementById ( 'model_description_' + models_array[i].toString( ) );
		var modelextrascontent = window.frames['ifrm_tertiary_content'].document.getElementById ( 'model_extras_' + models_array[i].toString( ) );
		
		if(models_array[i].toString( ) == modelID)
		{
			model.className = 'model_on_set';
			modeldetailcontent.style.display = 'block';
			modeldescriptioncontent.style.display = 'block';
		}
		else
		{
			model.className = 'model_off';
			modeldetailcontent.style.display = 'none';
			modeldescriptioncontent.style.display = 'none';
		}
	}
}
