﻿
$.history.callback = function(reinstate, cursor) {
    var hash = reinstate.hash
    hash = hash.replace(/^.*#/, '');
    if (hash) {
        var step = hash.split(',')[0];
        switch (step) {
            case 'Step1':
                setupStep1();
                break;
            case 'Step2':
                var page = hash.split(',')[1]
                page = (page == undefined) ? 1 : page;
                setupStep2(page);
                break;
            case 'Step3':
                var page = hash.split(',')[1];
                page = (page == undefined) ? 1 : page;
                setupStep3(page);
                break;
            case 'Step4':
                setupStep4();
                break;
            case 'Step5':
                setupStep5();
                break;
            case 'Step6':
                setupStep6();
                break;
            case 'BestSellers':
                searchType = 'b';
                setupStep2(1);
                break;
            case 'LandingPage':
                setupStep1();
                openLandingPage();
                break;
            default:
                //setupStep1();
                break;

        }
    } 
};
function setTitle() {
    document.title = 'חיבוק :: מתנה לכל אירוע :: ספרים באינטרנט :: חנות ספרים :: מתנה ליום הולדת';
}
$(document).ready(function() {
    $.history({ 'hash': 'Step1' });
    var hash = window.location.hash;
    if (hash == '')
        hash = 'Step1';
    historyClick(hash);

});
function FlashClick(step) {
    var hash = 'Step' + step;
    //window.location.hash = hash;
    $.history({ 'hash': hash });

}
function historyClick(hash) {
    
    $.history({ 'hash': hash });
}

/*
$(document).ready(
	function() {
        $.history(window.location.hash);
	});

	function trace(msg) {
	    $('#traceElm').html(msg);
	}
	function traceAppend(msg) {
	    $('#traceElm').html($('#traceElm').html()+msg + '<br>');
	}

	$.history.callback = loadcenter;
	
function loadcenter(reinstate, cursor) {
	var hash = reinstate;
	setTitle();
    hash = hash.replace(/^.*#/, '');
    if (hash) {
        var step = hash.split(',')[0];
        switch (step) {
            case 'Step1':
                setupStep1();
                break;
            case 'Step2':
                var page = hash.split(',')[1]
                page = (page == undefined) ? 1 : page;
                setupStep2(page);
                break;
            case 'Step3':
                var page = hash.split(',')[1];
                page = (page == undefined) ? 1 : page;
                setupStep3(page);
                break;
            case 'Step4':
                setupStep4();
                break;
            case 'Step5':
                setupStep5();
                break;
            case 'Step6':
                setupStep6();
                break;
            case 'BestSellers':
                searchType = 'b';
                setupStep2(1);
                break;
            case 'LandingPage':
                setupStep1();
                openLandingPage();
                break;
            default:
                //setupStep1();
                break;
                
        }
        setTitle();
    } else {
    }
}


function executeHash(hash) {
    if (hash == undefined) return;
    var parsed = 'Get' + hash.replace('?', '(').replace('&', ',') + ')';
    eval(parsed);
}

var i = 0;

function FlashClick(step) {
    var hash = 'Step' + step;
    //window.location.hash = hash;
    $.history(hash);

}*/