﻿/*
 * pageStructure.js - Created by Feizel Daud Kidia as part of Scarab change request EGGP122.
 * This file contains the code that structures the interface objects on the page of eGGP2008.
 * It has been separated from the application code in eggp.aspx hence allowing client cofiguration of the interface to
 * a greater extent in addition to CSS and INI file configurations. This will allow resizing and repositioning of the page
 * framework structure.
 *
 * Separating the code will allow updates to be applied to extra-customised interfaces without affecting the customisation itself.
 *
 * 30/04/2008.
 */

var leftBlockW=280;
var headBlockH=96;
var topBarBlockH=38;
var statusBarBlockH=35;
var pleaseWaitBlockH=32;
var pleaseWaitBlockW=140;
var copyBarBlockH=20;
var lyrSrcHUDH=20;
var currentScaleH = 20;
var topW=(document.all)?3:0;
var panBarW=12;
var breadCrumbBlockH=20;

function buildPageStructure() {
    //headBlock
	objeGGP.blockFramework().registerAutoConstraint("headBlock","t","0px", true);
	objeGGP.blockFramework().registerAutoConstraint("headBlock","l","0px", true);
	objeGGP.blockFramework().registerAutoConstraint("headBlock","w","bw", true);
	objeGGP.blockFramework().registerAutoConstraint("headBlock","h",headBlockH+"px", true);
	
	//breadCrumbBlock
	objeGGP.blockFramework().registerAutoConstraint("breadCrumbBlock","t",headBlockH+"px", true);
	objeGGP.blockFramework().registerAutoConstraint("breadCrumbBlock","l","0px", true);
	objeGGP.blockFramework().registerAutoConstraint("breadCrumbBlock","w","bw", true);
	objeGGP.blockFramework().registerAutoConstraint("breadCrumbBlock","h",breadCrumbBlockH+"px", true);
	
	//leftBlock
	objeGGP.blockFramework().registerAutoConstraint("leftBlock","t",headBlockH+"px"+"+"+breadCrumbBlockH+"px", true);
	objeGGP.blockFramework().registerAutoConstraint("leftBlock","l","0px", true);
	objeGGP.blockFramework().registerAutoConstraint("leftBlock","w",""+leftBlockW+"px", true);
	objeGGP.blockFramework().registerAutoConstraint("leftBlock","h","(bh-h@id:headBlock)+2px", true);
	
	//topBarBlock
	objeGGP.blockFramework().registerAutoConstraint("topBarBlock","t",headBlockH+"px"+"+"+breadCrumbBlockH+"px", true);
	objeGGP.blockFramework().registerAutoConstraint("topBarBlock","l","w@id:leftBlock", true);
	objeGGP.blockFramework().registerAutoConstraint("topBarBlock","w","bw-("+leftBlockW+"px)+"+topW+"px", true);
	objeGGP.blockFramework().registerAutoConstraint("topBarBlock","h",topBarBlockH+"px", true);
	
	//ImgContainer
	objeGGP.blockFramework().registerAutoConstraint("ImgContainer","t","("+headBlockH+"px+h@id:topBarBlock)+"+panBarW+"px"+"+"+breadCrumbBlockH+"px", true);
	objeGGP.blockFramework().registerAutoConstraint("ImgContainer","l","(w@id:leftBlock)+"+panBarW+"px", true);
	objeGGP.blockFramework().registerAutoConstraint("ImgContainer","w","(bw-w@id:leftBlock)+2px-(2*"+panBarW+")", true);
	objeGGP.blockFramework().registerAutoConstraint("ImgContainer","h","((bh-(h@id:topBarBlock+h@id:headBlock+"+breadCrumbBlockH+"px))-("+statusBarBlockH+"px))-(2*"+panBarW+"px)", true);
	
	//pleaseWaitBlock
	objeGGP.blockFramework().registerAutoConstraint("pleaseWaitBlock","t","(bh/2)-(" + pleaseWaitBlockH + "px/2)", true);
	objeGGP.blockFramework().registerAutoConstraint("pleaseWaitBlock","l","(bw/2)+(" + pleaseWaitBlockW + "px/2)", true);
	objeGGP.blockFramework().registerAutoConstraint("pleaseWaitBlock","w",pleaseWaitBlockW+"px", true);
	objeGGP.blockFramework().registerAutoConstraint("pleaseWaitBlock","h",pleaseWaitBlockH+"px", true);
	
	//panTools
	objeGGP.blockFramework().registerAutoConstraint("panTools","t","t@id:ImgContainer+10px", true);
	objeGGP.blockFramework().registerAutoConstraint("panTools","l","bw-30px-w@id:panTools", true);
	
	//customScale
	objeGGP.blockFramework().registerAutoConstraint("customScale","t","t@id:ImgContainer+20px", true);
	objeGGP.blockFramework().registerAutoConstraint("customScale","l","l@id:ImgContainer+20px", true);
		
	//getInfoHUD
	getInfoHUDH = 20;
	objeGGP.blockFramework().registerAutoConstraint("sw-getInfoHUD","t","t@id:ImgContainer+10px", true);
	objeGGP.blockFramework().registerAutoConstraint("sw-getInfoHUD","l","l@id:ImgContainer+10px", true);
	objeGGP.blockFramework().registerAutoConstraint("sw-getInfoHUD","w","w@id:ImgContainer-20px", true);
	objeGGP.blockFramework().registerAutoConstraint("sw-getInfoHUD","h",getInfoHUDH+"px", true);
	
	objeGGP.blockFramework().registerAutoConstraint("sw-getInfoHUD-body","t","t@id:ImgContainer+10px+"+getInfoHUDH+"px", true);
	objeGGP.blockFramework().registerAutoConstraint("sw-getInfoHUD-body","l","l@id:ImgContainer+10px", true);
	objeGGP.blockFramework().registerAutoConstraint("sw-getInfoHUD-body","w","w@id:ImgContainer-20px", true);
	objeGGP.blockFramework().registerAutoConstraint("sw-getInfoHUD-body","h","h@id:ImgContainer", true);
	
	//lyrFormResults
	lyrSrcHUDH = 20;
	objeGGP.blockFramework().registerAutoConstraint("sw-lyrFormResults","t","t@id:ImgContainer+10px", true);
	objeGGP.blockFramework().registerAutoConstraint("sw-lyrFormResults","l","l@id:ImgContainer+10px", true);
	objeGGP.blockFramework().registerAutoConstraint("sw-lyrFormResults","w","w@id:ImgContainer-20px", true);
	objeGGP.blockFramework().registerAutoConstraint("sw-lyrFormResults","h",lyrSrcHUDH+"px", true);
	
	objeGGP.blockFramework().registerAutoConstraint("sw-lyrFormResults-body","t","t@id:ImgContainer+10px+"+lyrSrcHUDH+"px", true);
	objeGGP.blockFramework().registerAutoConstraint("sw-lyrFormResults-body","l","l@id:ImgContainer+10px", true);
	objeGGP.blockFramework().registerAutoConstraint("sw-lyrFormResults-body","w","w@id:ImgContainer-20px", true);
	objeGGP.blockFramework().registerAutoConstraint("sw-lyrFormResults-body","h","h@id:ImgContainer", true);
	
	//gzFormResults
	gzSrcHUDH = 20;
	objeGGP.blockFramework().registerAutoConstraint("sw-gzFormResults","t","t@id:ImgContainer+10px", true);
	objeGGP.blockFramework().registerAutoConstraint("sw-gzFormResults","l","l@id:ImgContainer+10px", true);
	objeGGP.blockFramework().registerAutoConstraint("sw-gzFormResults","w","w@id:ImgContainer-20px", true);
	objeGGP.blockFramework().registerAutoConstraint("sw-gzFormResults","h",gzSrcHUDH+"px", true);
	
	objeGGP.blockFramework().registerAutoConstraint("sw-gzFormResults-body","t","t@id:ImgContainer+10px+"+gzSrcHUDH+"px", true);
	objeGGP.blockFramework().registerAutoConstraint("sw-gzFormResults-body","l","l@id:ImgContainer+10px", true);
	objeGGP.blockFramework().registerAutoConstraint("sw-gzFormResults-body","w","w@id:ImgContainer-20px", true);
	objeGGP.blockFramework().registerAutoConstraint("sw-gzFormResults-body","h","h@id:ImgContainer", true);
	
	//nrFormResults
	nrSrcHUDH = 20;
    objeGGP.blockFramework().registerAutoConstraint("sw-nrFormResults","t","t@id:ImgContainer+10px", true);
	objeGGP.blockFramework().registerAutoConstraint("sw-nrFormResults","l","l@id:ImgContainer+10px", true);
	objeGGP.blockFramework().registerAutoConstraint("sw-nrFormResults","w","w@id:ImgContainer-20px", true);
	objeGGP.blockFramework().registerAutoConstraint("sw-nrFormResults","h",nrSrcHUDH+"px", true);
	
	objeGGP.blockFramework().registerAutoConstraint("sw-nrFormResults-body","t","t@id:ImgContainer+10px+"+nrSrcHUDH+"px", true);
	objeGGP.blockFramework().registerAutoConstraint("sw-nrFormResults-body","l","l@id:ImgContainer+10px", true);
	objeGGP.blockFramework().registerAutoConstraint("sw-nrFormResults-body","w","w@id:ImgContainer-20px", true);
	objeGGP.blockFramework().registerAutoConstraint("sw-nrFormResults-body","h","h@id:ImgContainer", true);
	
	//statusBarBlock
	objeGGP.blockFramework().registerAutoConstraint("statusBarBlock","t","t@id:ImgContainer+h@id:ImgContainer+"+panBarW+"px", true);
	objeGGP.blockFramework().registerAutoConstraint("statusBarBlock","l","w@id:leftBlock", true);
	objeGGP.blockFramework().registerAutoConstraint("statusBarBlock","w","bw-w@id:leftBlock", true);
	objeGGP.blockFramework().registerAutoConstraint("statusBarBlock","h",statusBarBlockH+"px", true);
	
	//copyBarBlock
	objeGGP.blockFramework().registerAutoConstraint("copyBarBlock","t","(t@id:ImgContainer+h@id:ImgContainer)-"+currentScaleH+"px", true);
	objeGGP.blockFramework().registerAutoConstraint("copyBarBlock","l","w@id:leftBlock-"+panBarW+"px", true);
	objeGGP.blockFramework().registerAutoConstraint("copyBarBlock","w","bw-w@id:leftBlock", true);
	objeGGP.blockFramework().registerAutoConstraint("copyBarBlock","h",copyBarBlockH+"px", true);
	
	//currentScale
	objeGGP.blockFramework().registerAutoConstraint("currentScale","t","(t@id:ImgContainer+h@id:ImgContainer)-"+currentScaleH+"px", true);
	objeGGP.blockFramework().registerAutoConstraint("currentScale","l","w@id:leftBlock+"+panBarW+"px", true);
	objeGGP.blockFramework().registerAutoConstraint("currentScale","h",currentScaleH+"px", true);
	
	//tabs
	objeGGP.blockFramework().registerAutoConstraint("tab_mapsAvailable", "t", "h@id:hovermenu", true);
	objeGGP.blockFramework().registerAutoConstraint("tab_mapsAvailable", "w", leftBlockW+"px", true);
	objeGGP.blockFramework().registerAutoConstraint("tab_mapsAvailable", "h", "bh-(t@id:hovermenu+h@id:hovermenu)", true);
	objeGGP.blockFramework().registerAutoConstraint("tab_searchMap", "t", "h@id:hovermenu", true);
	objeGGP.blockFramework().registerAutoConstraint("tab_searchMap", "w", leftBlockW+"px", true);
	objeGGP.blockFramework().registerAutoConstraint("tab_searchMap", "h", "bh-(t@id:hovermenu+h@id:hovermenu)", true);
	objeGGP.blockFramework().registerAutoConstraint("tab_toolsTab", "t", "h@id:hovermenu", true);
	objeGGP.blockFramework().registerAutoConstraint("tab_toolsTab", "w", leftBlockW+"px", true);
	objeGGP.blockFramework().registerAutoConstraint("tab_toolsTab", "h", "bh-(t@id:hovermenu+h@id:hovermenu)", true);
	
	// top search bar
	var  searchContainerW = 560;
	objeGGP.blockFramework().registerAutoConstraint("searchContainer", "l", "375px", true);
	objeGGP.blockFramework().registerAutoConstraint("searchContainer", "t", "22px", true);
	
	//panBars (surrounding the map image):
	var vWidthFactor=3;
	var cornerInset=100;
	//<div class="panBar" id="panN" />
	objeGGP.blockFramework().registerAutoConstraint("panN","t","t@id:topBarBlock+h@id:topBarBlock", true);
	objeGGP.blockFramework().registerAutoConstraint("panN","l","l@id:ImgContainer+"+cornerInset+"px", true);
	objeGGP.blockFramework().registerAutoConstraint("panN","w","w@id:ImgContainer-(2*"+cornerInset+"px)", true);
	objeGGP.blockFramework().registerAutoConstraint("panN","h",panBarW+"px", true);
	//<div class="panBar" id="panE" />
    objeGGP.blockFramework().registerAutoConstraint("panE","h","h@id:ImgContainer-(2*"+cornerInset+"px)", true);
    objeGGP.blockFramework().registerAutoConstraint("panE","t","t@id:ImgContainer+"+cornerInset+"px", true);
	objeGGP.blockFramework().registerAutoConstraint("panE","l","l@id:ImgContainer+w@id:ImgContainer", true);
	objeGGP.blockFramework().registerAutoConstraint("panE","w",panBarW+"px", true);
    //<div class="panBar" id="panS" />
	objeGGP.blockFramework().registerAutoConstraint("panS","t","t@id:ImgContainer+h@id:ImgContainer", true);
	objeGGP.blockFramework().registerAutoConstraint("panS","l","l@id:ImgContainer+"+cornerInset+"px", true);
	objeGGP.blockFramework().registerAutoConstraint("panS","w","w@id:ImgContainer-(2*"+cornerInset+"px)", true);
	objeGGP.blockFramework().registerAutoConstraint("panS","h",panBarW+"px", true);
	//<div class="panBar" id="panW" />
    objeGGP.blockFramework().registerAutoConstraint("panW","h","h@id:ImgContainer-(2*"+cornerInset+"px)", true);
    objeGGP.blockFramework().registerAutoConstraint("panW","t","t@id:ImgContainer+"+cornerInset+"px", true);
	objeGGP.blockFramework().registerAutoConstraint("panW","l","l@id:topBarBlock", true);
	objeGGP.blockFramework().registerAutoConstraint("panW","w",panBarW+"px", true);
    //<div class="panBar" id="panNE" />
    objeGGP.blockFramework().registerAutoConstraint("panNE","t","t@id:topBarBlock+h@id:topBarBlock", true);
	objeGGP.blockFramework().registerAutoConstraint("panNE","l","l@id:panN+w@id:panN", true);
	objeGGP.blockFramework().registerAutoConstraint("panNE","w",(cornerInset+panBarW)+"px", true);
	objeGGP.blockFramework().registerAutoConstraint("panNE","h",(cornerInset+panBarW)+"px", true);
    //<div class="panBar" id="panSE" />
	objeGGP.blockFramework().registerAutoConstraint("panSE","t","t@id:panE+h@id:panE", true);
	objeGGP.blockFramework().registerAutoConstraint("panSE","l","l@id:panN+w@id:panN", true);
	objeGGP.blockFramework().registerAutoConstraint("panSE","w",(cornerInset+panBarW)+"px", true);
	objeGGP.blockFramework().registerAutoConstraint("panSE","h",(cornerInset+panBarW)+"px", true);
    //<div class="panBar" id="panSW" />
    objeGGP.blockFramework().registerAutoConstraint("panSW","t","t@id:panW+h@id:panW", true);
	objeGGP.blockFramework().registerAutoConstraint("panSW","l","l@id:topBarBlock", true);
	objeGGP.blockFramework().registerAutoConstraint("panSW","w",(cornerInset+panBarW)+"px", true);
	objeGGP.blockFramework().registerAutoConstraint("panSW","h",(cornerInset+panBarW)+"px", true);
    //<div class="panBar" id="panNW" />
    objeGGP.blockFramework().registerAutoConstraint("panNW","t","t@id:topBarBlock+h@id:topBarBlock", true);
	objeGGP.blockFramework().registerAutoConstraint("panNW","l","l@id:topBarBlock", true);
	objeGGP.blockFramework().registerAutoConstraint("panNW","w",(cornerInset+panBarW)+"px", true);
	objeGGP.blockFramework().registerAutoConstraint("panNW","h",(cornerInset+panBarW)+"px", true);
	//East West
    objeGGP.blockFramework().registerAutoConstraint("panEIcon","t","(h@id:panE*0.5)-(h@id:panEIcon*0.5)", true);
	objeGGP.blockFramework().registerAutoConstraint("panWIcon","t","(h@id:panW*0.5)-(h@id:panWIcon*0.5)", true);
	
	var mapsPanelH = 150;
	objeGGP.blockFramework().registerAutoConstraint("layersPanel","h","bh-(t@id:hovermenu+h@id:hovermenu+"+mapsPanelH+"px+105px)", true);
	
	applyObjectOpacity();
}

function applyObjectOpacity()  {
    /**************************************************************************
	 * Set the opacity of objects that display above the map image
	 **************************************************************************/
	gbl_eGGPAlterOpacity(90, "pleaseWaitBlock");
	gbl_eGGPAlterOpacity(90, "sw-getInfoHUD-body");
	gbl_eGGPAlterOpacity(90, "sw-lyrFormResults-body");
	gbl_eGGPAlterOpacity(90, "sw-gzFormResults-body");
	gbl_eGGPAlterOpacity(90, "sw-nrFormResults-body");
	gbl_eGGPAlterOpacity(80, "panTools");
	gbl_eGGPAlterOpacity(80, "customScale");
	gbl_eGGPAlterOpacity(80, "currentScale");
	gbl_eGGPAlterOpacity(80, "copyBarBlock");
}

function buildWizardPageStructure() {
    //The wizard welcome popup
	getId('wizardHeader').style.display = 'block';
	getId('wizardContent').style.display = 'block';
	
	objeGGP.blockFramework().registerAutoConstraint("wizardHeader","t","t@id:ImgContainer",true);
	objeGGP.blockFramework().registerAutoConstraint("wizardHeader","l","l@id:ImgContainer",true);
			
	objeGGP.blockFramework().registerAutoConstraint("wizardContent","t","t@id:ImgContainer+h@id:wizardHeader",true);
	objeGGP.blockFramework().registerAutoConstraint("wizardContent","l","l@id:ImgContainer",true);
	objeGGP.blockFramework().registerAutoConstraint("wizardContent","h","h@id:ImgContainer-h@id:wizardHeader",true);
}
