    $(document).ready(function () {$("#AJAX_CART").submit(function () {if (!$(this).find("input:checked").id("fid[]").val()) {return TM_show({msg: "You must select at least one product!!", width: 300, classname: "info", delay: 3000});}$(this).ajaxSubmit("#AJAX_CART", cartafter, cartbefore, null, null, true);return false;});$("#loginform").submit(function () {if (!$(this).find("input").id("email").val()) {return TM_show({msg: "Invalid E-mail address.", width: 300, classname: "info"});}$(this).ajaxSubmit("#AJAX_userpanel", after, before, null, null, true);return false;});cartdisplay();});

    function cartdisplay() {
        if ($("div#AJAX_backet").is("div")) {
            $.get("/index.php?controller=default&action=getcart&lang=en", function (xml) {var tt = $("eproot/AJAX_backet", xml).text();if (tt != "") {$("div#AJAX_backet").html(tt);} else {$("div#AJAX_backet").html("");}});
        }
    }


    function cartbefore(formData) {
        TM_show({msg: "Processing...Please Wait!", width: 300, classname: "info", delay: 3000});
        return true;
    }


    function cartafter(data) {
        TM_remove_now();
        var tt = $("eproot/AJAX_backet", data).text();
        var ts = $("eproot/AJAX_backet", data).text();
        if (ts == "false") {
            return TM_show({msg: $("eproot/AJAX_backet", data).text(), width: 300, classname: "info", delay: 3000});
        }
        $("div#AJAX_backet").html(tt);
    }


    function before(formData) {
        TM_show({msg: "Processing...Please Wait!", width: 300, classname: "info", delay: 3000});
        return true;
    }


    function after(data) {
        TM_remove_now();
        var tt = $("eproot/AJAX_userpanel", data).text();
        var ts = $("eproot/AJAX_userpanel_status", data).text();
        if (ts == "false") {
            return TM_show({msg: $("eproot/AJAX_userpanel_msg", data).text(), width: 300, classname: "info", delay: 3000});
        } else {
            $.get("/index.php?controller=default&action=loginmsg&lang=en", function (xml) {var tm = $("eproot/AJAX_usermsg", xml).text();if (tm != "") {TD_show({msg: tm, width: 300, height: 100, ok: "OK", cancel: "Cancel"}, null, null);}});
        }
        $("div#AJAX_userpanel").html(tt);
    }


    function selectAll() {
        $(".PList input[@type=\"checkbox\"]").each(function () {this.checked = true;});
    }


    function unselectAll() {
        $(".PList input[@type=\"checkbox\"]").each(function () {this.checked = false;});
    }


function inquery(uid) {
    TB_remove_now();
    if(document.referrer){
    	opensubwindow("You may leave us feedback using this form, we will work on your inquiry as soon as possible.", "/readyscript/fb/embed.php?id=1&cid="+urlencode(document.referrer), 1);
    }else{
    	opensubwindow("You may leave us feedback using this form, we will work on your inquiry as soon as possible.", "/readyscript/fb/embed.php?id=1", 1);
    	}
    
}



	function inquirynow(uid) {
	    TB_remove_now();
	    opensubwindow("", "/readyscript/fb/embed.php?id=1", 1);
	}



    function addcart(uid) {
        TM_show({msg: "Processing...Please Wait!", width: 300, classname: "info", delay: 1000});
        $.post("/index.php?controller=default&action=addcart&lang=en", {'fid[0]': uid}, function (xml) {var tt = $("eproot/AJAX_backet", xml).text();var ts = $("eproot/AJAX_backet", xml).text();if (ts == "false") {return TM_show({msg: $("eproot/AJAX_backet", xml).text(), width: 300, classname: "info", delay: 3000});}$("div#AJAX_backet").html(tt);});
    }


    function TB_remove_now() {
        $("#TB_window,#TB_overlay,#TB_HideSelect").remove();
        $("#TB_load").remove();
    }


    function opensubwindow(tTitle, tURL, tType) {
        switch (tType) {
          case 1:
            TB_show(tTitle, tURL + "&KeepThis=true&TB_iframe=true&width=500&height=500", "");
            break;
          case 2:
            TB_show(tTitle, tURL + "&width=500&height=500", "");
            break;
          case 3:
            TB_show(tTitle, tURL + "&KeepThis=true&TB_iframe=true&width=500&height=200", "");
            break;
          default:;
        }
    }


    function finishReg() {
        TB_remove_now();
        return TM_show({msg: "Thank you!  The registration was successful.  You log on yourselfs now with your user name and the password", width: 300, classname: "info", delay: 3000});
    }


    function finishInquiry() {
        TB_remove_now();
        return TM_show({msg: "Thank you for your E-mail, we will try to reply to it as soon as possible!", width: 300, classname: "info", delay: 3000});
    }


    function finishContact() {
        TB_remove_now();
        return TM_show({msg: "Thank you for your E-mail, we will try to reply to it as soon as possible!", width: 300, classname: "info", delay: 3000});
    }


    function finishUpdateUser() {
        TB_remove_now();
        return TM_show({msg: "Your profile has been successfully edited", width: 300, classname: "info", delay: 3000});
    }


    function finishGetPwd() {
        TB_remove_now();
        return TM_show({msg: "You will receive an Email soon, please follow the link given in it.", width: 300, classname: "info", delay: 3000});
    }


function openContact() {
    opensubwindow("", "/readyscript/fb/embed.php?id=2", 1);
}



    function logout() {
        TM_show({msg: "Your request is processing now, please wait....", width: 300, classname: "info", delay: 3000});
        $.get("/index.php?controller=default&action=logout&lang=en", function (xml) {var tt = $("eproot/AJAX_userpanel", xml).text();if (tt != "") {$("div#AJAX_userpanel").html(tt);}});
    }

