    function scopeParam() {
        this.easingin = 0;
        this.easingout = 0;
        this.speed = 0;
        this.routes = 0;
        this.offLeft = 0;
        this.offTop = 0;
        this.step = 0;
        this.start = document.location.href.split('#')[1];
        if (typeof(this.start) != "undefined") {
            this.start = this.start.split('?')[0];
        }
        this.stop = 'Home';
        this.hash = 'Home';
    }

    function prepareData() {
        //routes
        gP.routes = new Array("Menu", "Order-Online", "OrderOnline", "Home", "Talk-to-Frank", "Que-Pasa", "Our-locations");
        jQuery.each(gP.routes, function (key, child) {
            gP.routes[child] = new Array("Menu", "Order-Online", "OrderOnline", "Home", "Talk-to-Frank", "Que-Pasa", "Our-locations");
        });
		/*
        gP.routes['Menu']['Order-Online'] = new Array("Menu", "a4", "a5", "Order-Online");
        gP.routes['Menu']['Home'] = new Array("Menu", "a3", "Home");
        gP.routes['Menu']['Talk-to-Frank'] = new Array("Menu", "a1","b1", "Talk-to-Frank");
        gP.routes['Menu']['Que-Pasa'] = new Array("Menu", "d2", "Que-Pasa");
        gP.routes['Menu']['Our-locations'] = new Array("Menu", "d2", "e2", "Our-locations");

        gP.routes['Order-Online']['Menu'] = new Array("Order-Online", "a5", "a4", "Menu"); //!
        gP.routes['Order-Online']['Home'] = new Array("Order-Online", "c5", "c4", "Home");
        gP.routes['Order-Online']['Talk-to-Frank'] = new Array("Order-Online", "b4","b1", "Talk-to-Frank");
        gP.routes['Order-Online']['Que-Pasa'] = new Array("Order-Online", "d5", "Que-Pasa");
        gP.routes['Order-Online']['Our-locations'] = new Array("Order-Online", "e5", "Our-locations");
        gP.routes['Order-Online']['OrderOnline'] = new Array("Order-Online", "OrderOnline");

        gP.routes['OrderOnline']['Menu'] = new Array("OrderOnline", "Order-Online","a5", "a4", "Menu"); //!
        gP.routes['OrderOnline']['Home'] = new Array("OrderOnline", "Order-Online", "c5", "c4", "Home");
        gP.routes['OrderOnline']['Talk-to-Frank'] = new Array("OrderOnline", "Order-Online", "b4","b1", "Talk-to-Frank");
        gP.routes['OrderOnline']['Que-Pasa'] = new Array("OrderOnline", "Order-Online", "d5", "Que-Pasa");
        gP.routes['OrderOnline']['Our-locations'] = new Array("OrderOnline", "Order-Online", "e5", "Our-locations");
        gP.routes['OrderOnline']['Order-Online'] = new Array("OrderOnline", "Order-Online");

        gP.routes['Home']['Menu'] = new Array("Home", "a3", "Menu"); //!
        gP.routes['Home']['Order-Online'] = new Array("Home", "c4", "c5", "Order-Online"); //!
        gP.routes['Home']['Talk-to-Frank'] = new Array("Home", "c1", "Talk-to-Frank");
        gP.routes['Home']['Que-Pasa'] = new Array("Home", "d3", "Que-Pasa");
        gP.routes['Home']['Our-locations'] = new Array("Home", "Our-locations");

        gP.routes['Talk-to-Frank']['Menu'] = new Array("Talk-to-Frank", "b1", "a1", "Menu"); //!
        gP.routes['Talk-to-Frank']['Order-Online'] = new Array("Talk-to-Frank", "b1", "b4", "Order-Online"); //!
        gP.routes['Talk-to-Frank']['Home'] = new Array("Talk-to-Frank", "c1", "Home"); //!
        gP.routes['Talk-to-Frank']['Que-Pasa'] = new Array("Talk-to-Frank", "d2", "Que-Pasa");
        gP.routes['Talk-to-Frank']['Our-locations'] = new Array("Talk-to-Frank", "e1", "Our-locations");

        gP.routes['Que-Pasa']['Menu'] = new Array("Que-Pasa", "d2", "Menu"); //!
        gP.routes['Que-Pasa']['Order-Online'] = new Array("Que-Pasa", "d5", "Order-Online"); //!
        gP.routes['Que-Pasa']['Home'] = new Array("Que-Pasa", "d3", "Home"); //!
        gP.routes['Que-Pasa']['Talk-to-Frank'] = new Array("Que-Pasa", "d2", "Talk-to-Frank"); //!
        gP.routes['Que-Pasa']['Our-locations'] = new Array("Que-Pasa", "e4", "Our-locations");

        gP.routes['Our-locations']['Menu'] = new Array("Our-locations", "e2", "d2", "Menu"); //!
        gP.routes['Our-locations']['Order-Online'] = new Array("Our-locations", "e5", "Order-Online"); //!
        gP.routes['Our-locations']['Home'] = new Array("Our-locations", "Home"); //!
        gP.routes['Our-locations']['Talk-to-Frank'] = new Array("Our-locations", "e1", "Talk-to-Frank"); //!
        gP.routes['Our-locations']['Que-Pasa'] = new Array("Our-locations", "e4", "Que-Pasa"); //!
        */
        /////////////////////

        gP.routes['Menu']['Order-Online'] = new Array("Menu", "a5", "Order-Online");
        gP.routes['Menu']['Home'] = new Array("Menu", "a3", "Home");
        gP.routes['Menu']['Talk-to-Frank'] = new Array("Menu", "a1", "Talk-to-Frank");
        gP.routes['Menu']['Que-Pasa'] = new Array("Menu", "d2", "Que-Pasa");
        gP.routes['Menu']['Our-locations'] = new Array("Menu", "e2", "Our-locations");

        gP.routes['Order-Online']['Menu'] = new Array("Order-Online", "a5", "Menu"); //!
        gP.routes['Order-Online']['Home'] = new Array("Order-Online", "c5", "Home");
        gP.routes['Order-Online']['Talk-to-Frank'] = new Array("Order-Online", "b1", "Talk-to-Frank");
        gP.routes['Order-Online']['Que-Pasa'] = new Array("Order-Online", "d5", "Que-Pasa");
        gP.routes['Order-Online']['Our-locations'] = new Array("Order-Online", "e5", "Our-locations");
        gP.routes['Order-Online']['OrderOnline'] = new Array("Order-Online", "OrderOnline");

        gP.routes['OrderOnline']['Menu'] = new Array("OrderOnline", "Order-Online", "a5", "Menu"); //!
        gP.routes['OrderOnline']['Home'] = new Array("OrderOnline", "Order-Online", "c5", "Home");
        gP.routes['OrderOnline']['Talk-to-Frank'] = new Array("OrderOnline", "b1", "Talk-to-Frank");
        gP.routes['OrderOnline']['Que-Pasa'] = new Array("OrderOnline", "Order-Online", "d5", "Que-Pasa");
        gP.routes['OrderOnline']['Our-locations'] = new Array("OrderOnline", "Order-Online", "e5", "Our-locations");
        gP.routes['OrderOnline']['Order-Online'] = new Array("OrderOnline", "Order-Online");

        gP.routes['Home']['Menu'] = new Array("Home", "a3", "Menu"); //!
        gP.routes['Home']['Order-Online'] = new Array("Home", "c5", "Order-Online"); //!
        gP.routes['Home']['Talk-to-Frank'] = new Array("Home", "c1", "Talk-to-Frank");
        gP.routes['Home']['Que-Pasa'] = new Array("Home", "d3", "Que-Pasa");
        gP.routes['Home']['Our-locations'] = new Array("Home", "Our-locations");

        gP.routes['Talk-to-Frank']['Menu'] = new Array("Talk-to-Frank", "a1", "Menu"); //!
        gP.routes['Talk-to-Frank']['Order-Online'] = new Array("Talk-to-Frank",'b1', "Order-Online"); //!
        gP.routes['Talk-to-Frank']['Home'] = new Array("Talk-to-Frank", "c1", "Home"); //!
        gP.routes['Talk-to-Frank']['Que-Pasa'] = new Array("Talk-to-Frank", "Que-Pasa");
        gP.routes['Talk-to-Frank']['Our-locations'] = new Array("Talk-to-Frank", "e1", "Our-locations");

        gP.routes['Que-Pasa']['Menu'] = new Array("Que-Pasa", "d2", "Menu"); //!
        gP.routes['Que-Pasa']['Order-Online'] = new Array("Que-Pasa", "d5", "Order-Online"); //!
        gP.routes['Que-Pasa']['Home'] = new Array("Que-Pasa", "d3", "Home"); //!
        gP.routes['Que-Pasa']['Talk-to-Frank'] = new Array("Que-Pasa", "Talk-to-Frank"); //!
        gP.routes['Que-Pasa']['Our-locations'] = new Array("Que-Pasa", "e4", "Our-locations");

        gP.routes['Our-locations']['Menu'] = new Array("Our-locations", "e2", "Menu"); //!
        gP.routes['Our-locations']['Order-Online'] = new Array("Our-locations", "e5", "Order-Online"); //!
        gP.routes['Our-locations']['Home'] = new Array("Our-locations", "Home"); //!
        gP.routes['Our-locations']['Talk-to-Frank'] = new Array("Our-locations", "e1", "Talk-to-Frank"); //!
        gP.routes['Our-locations']['Que-Pasa'] = new Array("Our-locations", "e4", "Que-Pasa"); //!
    }

    function adjustLocation(id) {
        gP.offLeft = -parseInt(($(window).width() - 960) / 2);
        //gP.offTop = -parseInt(($(window).height()-600)/2)+20;
        gP.offTop = -parseInt(($(window).height() - 600) / 2);
        
        if (gP.offTop < 0) {
            $("#canvas").height(5 * 600 - gP.offTop * 2);
            $("#canvas").css("margin-top", -gP.offTop);
            $("#canvas").css("margin-bottom", -gP.offTop);

            //hack +1
            $(window).scrollTop($("#" + id).position().top + 1);
        }
        if (gP.offLeft < 0) {

            $("#canvas").width(7 * 960 - gP.offLeft * 2);
            $("#canvas").css("margin-left", -gP.offLeft);
            $("#canvas").css("margin-right", -gP.offLeft);
            $(window).scrollLeft($("#" + id).position().left);
        }

		$(".horizontal-nav-left, .horizontal-nav-right").css("margin-top",-gP.offTop-18).css("margin-bottom",-gP.offTop).css("width",-gP.offLeft-34+"px");
		$(".vertical-nav-top, .vertical-nav-bottom").height(-gP.offTop-18+"px");
		$(".vertical-nav, .horizontal-nav").css("display","table-cell");
		
        if (gP.offLeft > -25) {
            $(".horizontal-nav-left, .horizontal-nav-right").width("0px");
        }
        if (gP.offTop > -26) {
            $(".vertical-nav-top, .vertical-nav-bottom").height("0px");
        }
        		
    }

    function hashChanged() {
	
        var hash = window.location.hash.split('#')[1];
        var id = hash;
        if (id == null) {
            id = "Home";
            window.location = "#" + id;
        }
		id = id.split('?')[0];
		if( $("#"+id).length == 0) {
			id = "Home";
            window.location = "#" + id;
        }
        gP.hash = id;
		if (id == "Que-Pasa"){
		    $('#news').load(getAddress(hash),
			   function () {
			       //overwrite pagination
			       $('#DataPager1 a').each(function (index) {
			           if ($(this).html() == '...') {

			           } else {
			               $(this).attr('href', '#Que-Pasa?newslist_' + $(this).html());
			           }
			           $(this).html();
			       });
			   });
		}
        //$("#" + id).addClass('selectedPanel');
        adjustLocation(id);
    }

    //move
	function scroll (){
		var top = ($("#"+gP.routes[gP.start][gP.stop][gP.step +1]).position().top - $("#"+gP.routes[gP.start][gP.stop][gP.step]).position().top);
		var left = ($("#"+gP.routes[gP.start][gP.stop][gP.step +1]).position().left - $("#"+gP.routes[gP.start][gP.stop][gP.step]).position().left);
		var speed = 0.6;
		
		if(top != 0){
			$.scrollTo($('#' + gP.routes[gP.start][gP.stop][gP.step + 1]), { axis: 'y', duration: Math.abs(top)*speed, easing: 'swing', offset: { top: gP.offTop, left: gP.offLeft }, onAfter: function () { gP.step++; goToNextStep(); } });
		}else{
			$.scrollTo($('#' + gP.routes[gP.start][gP.stop][gP.step + 1]), { axis: 'x', duration: Math.abs(left)*speed, easing: 'swing', offset: { top: gP.offTop, left: gP.offLeft }, onAfter: function () { gP.step++; goToNextStep(); } });
		}		
	}
	
    function goToNextStep() {
        if (typeof (gP.routes[gP.start]) != "undefined") {
            if (typeof (gP.routes[gP.start][gP.stop]) != "undefined") {
                if (gP.routes[gP.start][gP.stop].length - 1 > gP.step) {
                    /*
                    var currentElem = gP.routes[gP.start][gP.stop][gP.step];
					if (currentElem == 'a3' || currentElem == 'a4' || currentElem == 'b1' || currentElem == 'b4' || currentElem == 'c1' || currentElem == 'c4' || currentElem == 'd2' || currentElem == 'd5' || currentElem == 'e1' || currentElem == 'e5' ){
						setTimeout( scroll , 800 );
					}else if (nextElem == 'a3' || nextElem == 'a4' || nextElem == 'b1' || nextElem == 'b4' || nextElem == 'c1' || nextElem == 'c4' || nextElem == 'd2' || nextElem == 'd5' || nextElem == 'e1' || nextElem == 'e5' ){
						scroll();
					}else{
						setTimeout( scroll , 5 );
					}
                    */
                    setTimeout(scroll, 5);
                } else {
                    gP.step = 0;
                    hashChanged();
                    $(window).bind('hashchange', hashChanged);
                    $(".horizontal-nav").addClass('opacity75');
                    $(".vertical-nav").addClass('opacity75');
                }
            } else {
                $(window).bind('hashchange', hashChanged);
            }
        }
        else {
            $.scrollTo($('#' + gP.stop), gP.speed[gP.start][gP.stop], { easing: gP.easingin[stop], offset: { top: gP.offTop, left: gP.offLeft} });
            $(window).bind('hashchange', hashChanged);
        }
    }

    //javascript:void(prompt('',gApplication.getMap().getCenter()));

    function setGoogle() {
        $().gmap3(
            'setDefault',
                {
                    unit: 'mi',
                    init: {
                        mapTypeId: google.maps.MapTypeId.ROADMAP,
                        zoom: 16
                    }
                }
        );
        $('#GM1-soho').gmap3({
            action: 'addMarker',
            address: "32 Old Compton Street, London W1D 4TP, United Kingdom (Poncho 8)",
            map:{
                center: true
            }
        });
        $('#GM1-stpaul').gmap3({
            action: 'addMarker',
            address: "11 Queens Head Passage, Paternoster Square EC4M 7DZ",
            map:{
                center: true
            }
        });
        $('#GM1-spitalfield').gmap3({
            action: 'addMarker',
            //address: "3-4 Stuart Street,Spitalfields, City of London E1 6AJ",
            latLng: [51.518863, -0.077433],
            map:{
                center: true
            }
        });
        /////
        $('#GM2-soho').gmap3({
            action: 'addMarker',
            address: "32 Old Compton Street, London W1D 4TP, United Kingdom (Poncho 8)",
            map:{
                center: true
            }
        });
        $('#GM2-stpaul').gmap3({
            action: 'addMarker',
            address: "11 Queens Head Passage, Paternoster Square EC4M 7DZ",
            map:{
                center: true
            }
        });
        $('#GM2-spitalfield').gmap3({
            action: 'addMarker',
            latLng: [51.518863,-0.077433],
            map:{
                center: true
            }
        });
    }

    function setFlash(){
		var params = { quality: "medium", wmode: "opaque" };
        swfobject.embedSWF("Poncho/flash/BIRDS.swf", "a3flash", "458", "377", "9.0.0", "Poncho/flash/expressInstall.swf", null, params, null);
        swfobject.embedSWF("Poncho/flash/woodpecker.swf", "b1flash", "155", "255", "9.0.0", "Poncho/flash/expressInstall.swf", null, params, null);
        swfobject.embedSWF("Poncho/flash/DROPS.swf", "b4flash", "280", "520", "9.0.0", "Poncho/flash/expressInstall.swf", null, {quality: "medium", wmode: "transparent" }, null);
        swfobject.embedSWF("Poncho/flash/boat.swf", "c1flash", "680", "179", "9.0.0", "Poncho/flash/expressInstall.swf", null, { quality: "high", wmode: "opaque" }, null);
        swfobject.embedSWF("Poncho/flash/windmill.swf", "c3flash", "141", "123", "9.0.0", "Poncho/flash/expressInstall.swf", {}, params, {});
        swfobject.embedSWF("Poncho/flash/waves.swf", "c4flash", "400", "330", "9.0.0", "Poncho/flash/expressInstall.swf", null, {quality: "medium", wmode: "transparent" }, null);
        swfobject.embedSWF("Poncho/flash/pinata.swf", "d2flash", "315", "270", "9.0.0", "Poncho/flash/expressInstall.swf", null, params, null);
        swfobject.embedSWF("Poncho/flash/sloth.swf", "d5flash", "470", "155", "9.0.0", "Poncho/flash/expressInstall.swf", null, params, null);
        swfobject.embedSWF("Poncho/flash/bear.swf", "e1flash", "760", "155", "9.0.0", "Poncho/flash/expressInstall.swf", null, params, null);
        swfobject.embedSWF("Poncho/flash/bike.swf", "e4flash", "1170", "320", "9.0.0", "Poncho/flash/expressInstall.swf", null, { quality: "medium", wmode: "opaque" }, null);
    }
	
    function getAddress(hash) {
        var ajaxPath = "/Poncho/Ajax/";
        if (hash.indexOf("Que-Pasa?news_") == 0) {
            return ajaxPath + "News.aspx?id=" + hash.substring(14);
        }
        if (hash.indexOf("Que-Pasa?list_") == 0) {
            return ajaxPath + "NewsList.aspx?init=" + hash.substring(14);
        }
        if (hash.indexOf("Que-Pasa?newslist_") == 0) {
            return ajaxPath + "NewsList.aspx?pageno=" + hash.substring(18);
        }
        /*
		if (hash.indexOf("Que-Pasa") == 0) {
            return ajaxPath + "NewsList.aspx?pageno=1";
        }
        */
    }

    function setCountdown() {
        var now = new Date();
        var hour = now.getHours();
        var time;
        var textCompleted;
		var temp = 0;
        if (hour < 15 ) {
            time = "11:00";
            $("#untilLunch").show();
            textCompleted = "It's lunch time!";
        }
        else if (hour > 21) {
            time = "11:00";
			temp = 1;
            $("#untilLunch").show();
            textCompleted = "It's lunch time!";
        } 
        else{
            time = "18:00";
            $("#untilDinner").show();
            textCompleted= "It's dinner time";
        }

        $("#time").countdown({
            date: now.getMonth() + 1 + "/" + (now.getDate() + temp) + "/" + now.getFullYear() + ", " + time,
            onComplete: function (event) {
                $(this).html("");
                $("#untilLunch").hide();
                $("#untilDinner").hide();
                $("#completed").html(textCompleted);
                $("#completed").show();
            },
            leadingZero: true
        });
    }
	
