function ilostPass(email)
{
	$.post(
		'/index.html',
		{lost_email:email},
		function (data)
		{
			if(data)
			{
				setTimeout(function(){$('#messages').html('');$('#message').slideUp();document.location.href='/';},5000);
				$('#messages').html(data);
				$('#message').slideDown();
			}
		}
	);
}

var URL;

(function() {
var isIE = window.navigator.userAgent.indexOf('MSIE') != -1;

URL = function(url) {
    var data = {href: '', protocol: '', host: '', hostname: '', port: '', pathname: '', search: '', hash: ''};

    var gs = {
        getHref: function() {
            return data.href;
        },
        setHref: function(val) {
            data.href = val;
            parseURL.call(this);
            return data.href;
        },

        getProtocol: function() {
            return data.protocol;
        },
        setProtocol: function(val) {
            if (!val)
                val = data.protocol || window.location.protocol; // update || init
            data.protocol = val;
            updateURL.call(this);
            return data.protocol;
        },

        getHost: function() {
            return data.host;
        },
        setHost: function(val) {
            val = val || '';
            var v = val.split(':');
            var h = v[0], p = v[1] || '';
            data.host = val;
            data.hostname = h;
            data.port = p;
            updateURL.call(this);
            return data.host;
        },

        getHostname: function() {
            return data.hostname;
        },
        setHostname: function(val) {
            if (!val)
                val = data.hostname || window.location.hostname; // update || init
            data.hostname = val;
            data.host = val + (("" + data.port) ? ":" + data.port : "");
            updateURL.call(this);
            return data.hostname;
        },

        getPort: function() {
            return data.port;
        },
        setPort: function(val) {
            data.port = val;
            data.host = data.hostname + (("" + data.port) ? ":" + data.port : "");
            updateURL.call(this);
            return data.port;
        },

        getPathname: function() {
            return data.pathname;
        },
        setPathname: function(val) {
            if (val.indexOf("/") != 0) { // relative url
                var _p = (data.pathname || window.location.pathname).split("/");
                _p[_p.length - 1] = val;
                val = _p.join("/");
            }
            data.pathname = val;
            updateURL.call(this);
            return data.pathname;
        },

        getSearch: function() {
            return data.search;
        },
        setSearch: function(val) {
            return data.search = val;
        },

        getHash: function() {
            return data.hash;
        },
        setHash: function(val) {
            return data.hash = val;
        }
    };

    if (isIE) { // IE5.5+
        var el=document.createElement('div');
        el.style.display='none';
        document.body.appendChild(el);
        el.assign = URL.prototype.assign;
        el.replace = URL.prototype.replace;
        var keys = ["href", "protocol", "host", "hostname", "port", "pathname", "search", "hash"];
        el.onpropertychange=function(){
            var pn = event.propertyName;
            var pv = event.srcElement[event.propertyName];
            if (this._holdOnMSIE || pn == '_holdOnMSIE')
                return pv;
            this._holdOnMSIE = true;
            for (var i = 0, l = keys.length; i < l; i++)
                el[keys[i]] = data[keys[i]];
            this._holdOnMSIE = false;
            for (var i = 0, l = keys.length; i < l; i++) {
                var key = keys[i];
                if (pn == key) {
                    var sKey = 'set' + key.substr(0, 1).toUpperCase() + key.substr(1);
                    return gs[sKey].call(el, pv);
                }
            }
        }
        url = url || "";
        parseURL.call(el, url);
        return el;
    } else if (URL.prototype.__defineSetter__) { // FF
        var keys = ["href", "protocol", "host", "hostname", "port", "pathname", "search", "hash"];
        for (var i = 0, l = keys.length; i < l; i++) {
            (function(i) {
                var key = keys[i];
                var gKey = 'get' + key.substr(0, 1).toUpperCase() + key.substr(1);
                var sKey = 'set' + key.substr(0, 1).toUpperCase() + key.substr(1);
                URL.prototype.__defineGetter__(key, gs[gKey]);
                URL.prototype.__defineSetter__(key, gs[sKey]);
            })(i);
        }
        url = url || "";
        parseURL.call(this, url);
    }
}

URL.prototype = {
    assign: function(url) {
        parseURL.call(this, url);
        window.location.assign(this.href);
    },

    replace: function(url) {
        parseURL.call(this, url);
        window.location.replace(this.href);
    }
}

function parseURL(url) {
    if (this._innerUse)
        return;

    url = url || this.href;
    var pattern = "^(([^:/\\?#]+):)?(//(([^:/\\?#]*)(?::([^/\\?#]*))?))?([^\\?#]*)(\\?([^#]*))?(#(.*))?$";
    var rx = new RegExp(pattern);
    var parts = rx.exec(url);

    // Prevent infinite recursion
    this._innerUse = true;

    this.href = parts[0] || "";
    this.protocol = parts[1] || "";
    //this.host = parts[4] || "";
    this.hostname = parts[5] || "";
    this.port = parts[6] || "";
    this.pathname = parts[7] || "/";
    this.search = parts[8] || "";
    this.hash = parts[10] || "";

    if (!isIE)
        delete this._innerUse;
    else
        this._innerUse = false;

    updateURL.call(this);
}

function updateURL() {
    if (this._innerUse)
        return;

    // Prevent infinite recursion
    this._innerUse = true;

    this.href = this.protocol + '//' + this.host + this.pathname + this.search + this.hash;

    if (!isIE)
        delete this._innerUse;
    else
        this._innerUse = false;
}

})()

json_parse = (function () {

    var at,     // The index of the current character
        ch,     // The current character
        escapee = {
            '"':  '"',
            '\\': '\\',
            '/':  '/',
            b:    '\b',
            f:    '\f',
            n:    '\n',
            r:    '\r',
            t:    '\t'
        },
        text,

        error = function (m) {

            throw {
                name:    'SyntaxError',
                message: m,
                at:      at,
                text:    text
            };
        },

        next = function (c) {

            if (c && c !== ch) {
                error("Expected '" + c + "' instead of '" + ch + "'");
            }

            ch = text.charAt(at);
            at += 1;
            return ch;
        },

        number = function () {

            var number,
                string = '';

            if (ch === '-') {
                string = '-';
                next('-');
            }
            while (ch >= '0' && ch <= '9') {
                string += ch;
                next();
            }
            if (ch === '.') {
                string += '.';
                while (next() && ch >= '0' && ch <= '9') {
                    string += ch;
                }
            }
            if (ch === 'e' || ch === 'E') {
                string += ch;
                next();
                if (ch === '-' || ch === '+') {
                    string += ch;
                    next();
                }
                while (ch >= '0' && ch <= '9') {
                    string += ch;
                    next();
                }
            }
            number = +string;
            if (isNaN(number)) {
                error("Bad number");
            } else {
                return number;
            }
        },

        string = function () {

            var hex,
                i,
                string = '',
                uffff;

            if (ch === '"') {
                while (next()) {
                    if (ch === '"') {
                        next();
                        return string;
                    } else if (ch === '\\') {
                        next();
                        if (ch === 'u') {
                            uffff = 0;
                            for (i = 0; i < 4; i += 1) {
                                hex = parseInt(next(), 16);
                                if (!isFinite(hex)) {
                                    break;
                                }
                                uffff = uffff * 16 + hex;
                            }
                            string += String.fromCharCode(uffff);
                        } else if (typeof escapee[ch] === 'string') {
                            string += escapee[ch];
                        } else {
                            break;
                        }
                    } else {
                        string += ch;
                    }
                }
            }
            error("Bad string");
        },

        white = function () {

            while (ch && ch <= ' ') {
                next();
            }
        },

        word = function () {

            switch (ch) {
            case 't':
                next('t');
                next('r');
                next('u');
                next('e');
                return true;
            case 'f':
                next('f');
                next('a');
                next('l');
                next('s');
                next('e');
                return false;
            case 'n':
                next('n');
                next('u');
                next('l');
                next('l');
                return null;
            }
            error("Unexpected '" + ch + "'");
        },

        value,  // Place holder for the value function.

        array = function () {

            var array = [];

            if (ch === '[') {
                next('[');
                white();
                if (ch === ']') {
                    next(']');
                    return array;   // empty array
                }
                while (ch) {
                    array.push(value());
                    white();
                    if (ch === ']') {
                        next(']');
                        return array;
                    }
                    next(',');
                    white();
                }
            }
            error("Bad array");
        },

        object = function () {

            var key,
                object = {};

            if (ch === '{') {
                next('{');
                white();
                if (ch === '}') {
                    next('}');
                    return object;   // empty object
                }
                while (ch) {
                    key = string();
                    white();
                    next(':');
                    if (Object.hasOwnProperty.call(object, key)) {
                        error('Duplicate key "' + key + '"');
                    }
                    object[key] = value();
                    white();
                    if (ch === '}') {
                        next('}');
                        return object;
                    }
                    next(',');
                    white();
                }
            }
            error("Bad object");
        };

    value = function () {

        white();
        switch (ch) {
        case '{':
            return object();
        case '[':
            return array();
        case '"':
            return string();
        case '-':
            return number();
        default:
            return ch >= '0' && ch <= '9' ? number() : word();
        }
    };

    return function (source, reviver) {
        var result;

        text = source;
        at = 0;
        ch = ' ';
        result = value();
        white();
        if (ch) {
            error("Syntax error");
        }

        return typeof reviver === 'function' ? (function walk(holder, key) {
            var k, v, value = holder[key];
            if (value && typeof value === 'object') {
                for (k in value) {
                    if (Object.hasOwnProperty.call(value, k)) {
                        v = walk(value, k);
                        if (v !== undefined) {
                            value[k] = v;
                        } else {
                            delete value[k];
                        }
                    }
                }
            }
            return reviver.call(holder, key, value);
        }({'': result}, '')) : result;
    };
}());


function ajaxErrorProccess()
{
    $('#modal').jqm({
        overlay: 50,
        modal: true,
        trigger: false
    });

    $.ajaxSetup({
        error:function(x,e){
            if(x.status==0){
                $('#modal_content').html('You are offline!!\n Please Check Your Network.');
            }else if(x.status==404){
                $('#modal_content').html('Requested URL not found.');
            }else if(x.status==500){
                $('#modal_content').html('Internel Server Error.');
            }else if(e=='parsererror'){
                $('#modal_content').html('Error.\nParsing JSON Request failed.');
                $('#modal').jqmShow();
            }else if(e=='timeout'){
                $('#modal_content').html('Request Time out.');
            }else {
                $('#modal_content').html('Unknow Error.\n'+x.responseText);
            }
        }
    });
}

$(document).ready(function(){
	$('.tabs a').click(function(){
		$('.tabs a').each(function(){$(this).removeClass('active');});
		$('.tab-content .topBlock').each(function(){$(this).css('display','none');});
		$(this).addClass('active');
		$('.tab-content .topBlock').eq($('.tabs a').index(this)).css('display','block');
	});

	$('#mySelectList a').click(function(){
		$('#mySelect').text($(this).text());
		$('#mySelectList').toggle();
		$('.overlay').toggle();
	});

	$('.listTab tr').hover(
		function(){
			$(this).addClass('hover');
		},
		function(){
			$(this).removeClass('hover');
	});

	$('.checkboxImg').click(function(){
		if($('#forgot').attr('checked'))
		{
			$('#forgot').attr('checked',false);
			$('#nocheckedImg').css('display','none');
			$('#checkedImg').css('display','inline');
		}else{
			$('#forgot').attr('checked',true);
			$('#checkedImg').css('display','none');
			$('#nocheckedImg').css('display','inline');
		}

	});

        $('.pricesUL .row').hover(function(){
            $(this).addClass('act');
        },
        function(){
            $(this).removeClass('act');
        });

        var u = new URL(document.location.href);
        var cPath = u.pathname;

        $("#userMenu .submenu li a").each( function(){
            var aPath = new URL(this.href);
            if(aPath.pathname == cPath && !aPath.hash) {$(this).addClass('active');}
        });



        $('.part').click(function()
        {
            var closedMenus = new Array();
            i = 0;

            $(this).next().slideToggle('fast',
                function(){
                    $('span.part').each(function(){
                        //create array for cookie opened menus
                        if( $(this).next().css('display') == 'none' ) {
                            closedMenus[i] = 1;
                        }else{
                            closedMenus[i] = 0;
                        }
                        i++;
                    });
                    $.cookie("closedMenus", closedMenus);
                }
            );
        });

        ajaxErrorProccess();

});