/* Minification failed. Returning unminified contents.
(2,1): run-time error CSS1019: Unexpected token, found '$'
(2,2): run-time error CSS1019: Unexpected token, found '('
(2,11): run-time error CSS1031: Expected selector, found ')'
(2,11): run-time error CSS1025: Expected comma or open brace, found ')'
(23,2): run-time error CSS1019: Unexpected token, found ')'
(23,3): run-time error CSS1019: Unexpected token, found ';'
(25,10): run-time error CSS1031: Expected selector, found 'AcceptOrRejectBrowser('
(25,10): run-time error CSS1025: Expected comma or open brace, found 'AcceptOrRejectBrowser('
(66,10): run-time error CSS1031: Expected selector, found 'global_SharepointSearch('
(66,10): run-time error CSS1025: Expected comma or open brace, found 'global_SharepointSearch('
(70,10): run-time error CSS1031: Expected selector, found 'global_ChangeStyleSheet('
(70,10): run-time error CSS1025: Expected comma or open brace, found 'global_ChangeStyleSheet('
(80,10): run-time error CSS1031: Expected selector, found 'global_print_cookies('
(80,10): run-time error CSS1025: Expected comma or open brace, found 'global_print_cookies('
(89,10): run-time error CSS1031: Expected selector, found 'get_cookies_array('
(89,10): run-time error CSS1025: Expected comma or open brace, found 'get_cookies_array('
(106,1): run-time error CSS1019: Unexpected token, found '/'
(106,2): run-time error CSS1019: Unexpected token, found '/'
(106,13): run-time error CSS1031: Expected selector, found '/'
(106,13): run-time error CSS1025: Expected comma or open brace, found '/'
(131): run-time error CSS1002: Unterminated string: ');
 */

$(document).ready(function() {

    $("[data-funct='stylesheet-updater']").click(function() {
        var stylesheetUrl = "/Content/" + $(this).data("sstype") + ".css";
        //alert("we are changing style-sheet to: " + stylesheetUrl);
        global_ChangeStyleSheet(stylesheetUrl);
    });

    $("#search").click(function () {
        global_SharepointSearch($("#txtSearch").val());
    });

    $("#txtSearch").keypress(function (e) {
        
        var keycode = (e.keyCode ? e.keyCode : e.which);
        if (keycode == '13')
            global_SharepointSearch($(this).val());
    });

    AcceptOrRejectBrowser();

});

function AcceptOrRejectBrowser() {

    var isQuicksMode = false;
    var isIe8Compatible = $.browser.name == "msie" && $.browser.versionX == 7 && document.documentMode > $.browser.versionX;

    //accept the browser if is ie-8 compatibility mode by exiting this function
    if (isIe8Compatible) return;
    
    if ($.browser.name == "msie" && $.browser.versionX >= 8 && document.documentMode < $.browser.versionX)
        isQuicksMode = true;

    if (isQuicksMode) {
        $.reject({
            reject: {
                all: true
            },
            header: 'Your browser is not supported by the Electronic Public Register', // Header Text  
            paragraph1: 'You are running internet explorer (IE) ' + $.browser.versionX + ' in Quirks mode or IE ' + document.documentMode + ' compatibility mode', // Paragraph 1  
            paragraph2: 'You should run internet explorer (IE) ' + $.browser.versionX + ' with IE ' + $.browser.versionX + ' standards. You can change this by pressing F12 and then changing the document mode',
            closeMessage: 'Press F12 to change the document mode to internet explorer ' + $.browser.versionX, // Message below close window link 
            imagePath: '/Scripts/plugins/jReject/browsers/'
        });

    } else {
        $.reject({
            reject: {
                all: false,
                msie5: true,
                msie6: true,
                msie7: true
            },
            header: 'Your browser is not supported by the Electronic Public Register', // Header Text  
            paragraph1: 'You are currently using an unsupported browser', // Paragraph 1  
            paragraph2: 'We have detected that you are using an unsupported web browser.Please install one the many browsers below to be able to enjoy the ePR application.',
            closeMessage: 'Close this window and use a suggested alternative browser!', // Message below close window link 
            imagePath: '/Scripts/plugins/jReject/browsers/'
        });
    }
    
}

function global_SharepointSearch(val) {
    top.location.href = "http://search.ofgem.gov.uk/search.aspx?aid=6581&pckid=755724950&pt=6018936&sw=" + val;
}

function global_ChangeStyleSheet(stylesheetUrl) {

    //add the style sheet to the header if it doesnt already exist else just change its url (href)
    if ($('#dynamic-stylesheet').attr("href") != undefined)
        $('#dynamic-stylesheet').attr('href', stylesheetUrl);
    else
        $('head').append('<link id="dynamic-stylesheet" rel="stylesheet" type="text/css" href="' + stylesheetUrl + '" />');

}

function global_print_cookies() {
    
    var cookies = get_cookies_array();
    for (var name in cookies) {
        document.write(name + " : " + cookies[name] + "<br />");
    }
    
}

function get_cookies_array() {

    var cookies = {};

    if (document.cookie && document.cookie != '') {
        var split = document.cookie.split(';');
        for (var i = 0; i < split.length; i++) {
            var nameValue = split[i].split("=");
            nameValue[0] = nameValue[0].replace(/^ /, '');
            cookies[decodeURIComponent(nameValue[0])] = decodeURIComponent(nameValue[1]);
        }
    }

    return cookies;

}

//dummy file//
//end of file//
/*!
 * jQuery Cookie Plugin v1.3.1
 * https://github.com/carhartl/jquery-cookie
 *
 * Copyright 2013 Klaus Hartl
 * Released under the MIT license
 */
(function ($, document, undefined) {

	var pluses = /\+/g;

	function raw(s) {
		return s;
	}

	function decoded(s) {
		return unRfc2068(decodeURIComponent(s.replace(pluses, ' ')));
	}

	function unRfc2068(value) {
		if (value.indexOf('"') === 0) {
			// This is a quoted cookie as according to RFC2068, unescape
			value = value.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
		}
		return value;
	}

	function fromJSON(value) {
		return config.json ? JSON.parse(value) : value;
	}

	var config = $.cookie = function (key, value, options) {

		// write
		if (value !== undefined) {
			options = $.extend({}, config.defaults, options);

			if (value === null) {
				options.expires = -1;
			}

			if (typeof options.expires === 'number') {
				var days = options.expires, t = options.expires = new Date();
				t.setDate(t.getDate() + days);
			}

			value = config.json ? JSON.stringify(value) : String(value);

			return (document.cookie = [
				encodeURIComponent(key), '=', config.raw ? value : encodeURIComponent(value),
				options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
				options.path    ? '; path=' + options.path : '',
				options.domain  ? '; domain=' + options.domain : '',
				options.secure  ? '; secure' : ''
			].join(''));
		}

		// read
		var decode = config.raw ? raw : decoded;
		var cookies = document.cookie.split('; ');
		var result = key ? null : {};
		for (var i = 0, l = cookies.length; i < l; i++) {
			var parts = cookies[i].split('=');
			var name = decode(parts.shift());
			var cookie = decode(parts.join('='));

			if (key && key === name) {
				result = fromJSON(cookie);
				break;
			}

			if (!key) {
				result[name] = fromJSON(cookie);
			}
		}

		return result;
	};

	config.defaults = {};

	$.removeCookie = function (key, options) {
		if ($.cookie(key) !== null) {
			$.cookie(key, null, options);
			return true;
		}
		return false;
	};

})(jQuery, document);

