/* eibJS version 1 - generated on 20.3.2008 */

// Configuration
// ----------------------------------------------------------------------


var Config = {	
	debug: false, // Set global debug option
	//debug: (location.href.indexOf("debug=true") != -1), // OR use this to allow live site debugging
	absoluteHttpPath: "http://www.ewm.co.uk"   ,
	absoluteHttpsPath: "https://www.ewm.co.uk", 
	
	absoluteWebPath: function() {
		return Core.Url.absoluteWebPath();
	},
	
	Validation: {
		// All front-end validation messages go here
		invalidQuantity: "Please enter a quantity"
	},
	
	Access: {
		// Accessibility messages that use C#-esque string formatting with indexed curly braces
		addToBasket: "{0} has been added to your basket",
		addToBasketDefault: "Product has been added to your basket",
		addToWishlist: "Product has been added to your wish list"
	},
	
	Text: {
		// All front-end text for localisation etc.
		MiniBasket: {
			total: "{0} items in your basket"
		}
	},
	Fx: {
		framerate: 28, // Default framerate
		duration: 4 // Default duration of the tween
	},
	page: null, // The Id of the page on the BODY tag.
	
	MaxWishlistRecipients: 16,  // max number of wishlist email recipients
	
	init: function() {
		// List all DOM load functionality here
		Core.Utils.flickerFix();

        // Replace all missing images with a no-image image
        //Core.AlternativeImage.init("catalogue", "missing");

        // Add enter event handler
        Core.Search.init();

        var txtSearch = document.getElementById("textSearch");
        if (txtSearch)
        {
	        txtSearch.onkeydown = function (oEvent) 
	        {
	            Core.Form.assignButton(oEvent, "searchSubmit");
	        }
        }
        
        txtSearch = document.getElementById("textRefinedSearch");
        if (txtSearch)
        {
	        txtSearch.onkeydown = function (oEvent) 
	        {
	            Core.Form.assignButton(oEvent, "searchRefinedSubmit");
	        }
        }

   
      var txtPassword = document.getElementById("ctl00_cphContent_tbPassword");
        if (txtPassword) {
	        txtPassword.onkeydown = function(e) {	           
	           var code;
		        if (!e) {
			        e = window.event
		        }
		        if (e.keyCode) {
			        code = e.keyCode;
		        } else if (e.which) {
			        code = e.which;
		        }
		        if (code == 13) {
			        var button = document.getElementById("btnLogin");
			        if (button) {
				        button.focus();				       
			        }
		        }
        	 }   
        }
		// Do the a check to load up page-specific functionality 
		Config.page = document.body.id;
        Core.Browser.hookup(['external'], [function() { return Core.Browser.newPage(this); }]);

		switch (Config.page) {
			case "detail-page": 
				if( typeof ProductZoom != "undefined" && ProductZoom.init )
				    ProductZoom.init();
				if( typeof Product != "undefined" && Product.init )
				    Product.init();
			    break;
			case "checkout-external-payment-page":
				if( typeof DataCash != "undefined" && DataCash.init )
				    DataCash.init();
			    break;
			case "checkout-payment-page":
			    if( typeof Checkout != "undefined" && Checkout.init )
			        Checkout.init("txtCCNumber", "dropDownCreditcard");
			    break;
			case "product-page":
			case "search-page":
                if( typeof PagingControls != "undefined" && PagingControls.init )
                    PagingControls.init();
                break;
            case "basket-page":
                /*
                ** Hide the update quantity buttons if script is enabled
                ** as there is script attached to the select element to
                ** auto-postback changes.
                */
                var e = document.getElementsByTagName("input") || [];
                if( e.length == 0 ) break;
                for( var n = 0; n < e.length; n++ ) {
                    if( /submit-update-[a-fA-F0-9]+/.test(e[n].name) )
                        e[n].style.display = "none";
                }
                break;
            case "advanced-delivery-page":
            case "checkout-delivery-page":
                if( GiftWrapping && GiftWrapping.init )
                    GiftWrapping.init();
                break;						
		}
		
    	if( typeof Custom != "undefined" && Custom.init )
		    Custom.init();
	},
	
	load: function() {

	}
};

/*
// Catch runtime errors and debug
window.onerror = function(a, b, c) {
	if (!Debug.release) {
		Debug.ex(a + " <br />File: " + b + " <br />Line: " + c);
		return true;
	} else {
		return false;
	}	
};	
// If ajax fails, prevent page loading to read error
window.onbeforeunload = function() {
	if (Config.prison) {
		return false;
	}
}
*/


// Functionality
// ----------------------------------------------------------------------


var Core = {}; 


var Site = {
	Page: {},
	Global: {}
}; 
