﻿
var showWaitpanel = true;
var makeStatic = false;
//------------------------ order loginbox jobs
var btnName;

function menuOver(sender, i, depth) {
    sender.style.color = '#AEBF4C';
    sender.style.backgroundPosition = 'left top';
    sender.style.backgroundColor = 'white';
    sender.style.backgroundImage = 'url(App_Themes/layoutImages/bgCat1.png)';
    document.getElementById('catMenuItem' + i).style.backgroundImage = 'url(App_Themes/layoutImages/bgCat2.png)';
}

function menuOut(sender, i, depth) {
    if (depth == 0) { sender.style.color = 'white'; }
    else {sender.style.color = '#D5F85F';}
    sender.style.backgroundPosition = 'left center';
    sender.style.backgroundColor = 'Transparent';
    
    //if (depth == 0) { sender.style.backgroundImage = 'url(App_Themes/layoutImages/cat1Bg.png)'; }
    //else if (depth == 1) { sender.style.backgroundImage = 'url(App_Themes/layoutImages/cat2Bg.png)'; }
    sender.style.backgroundImage = 'none';
    document.getElementById('catMenuItem' + i).style.backgroundImage = 'none';
}

function clearName(bttnName) {
    WebForm_GetElementById('nameNAvailable').style.display = "none";
    WebForm_GetElementById('nameAvailable').style.display = "none";
    WebForm_GetElementById(bttnName).disabled = true;
    btnName = bttnName;
}
function checkName(txtName) {
    var val = WebForm_GetElementById(txtName);
    WebService.freeName(val.value, onNameCheckDone);
}
function onNameCheckDone(result) {
    if (result == true) {
        WebForm_GetElementById('nameNAvailable').style.display = "none";
        WebForm_GetElementById('nameAvailable').style.display = "block";
        WebForm_GetElementById(btnName).disabled = false;
    }
    else {
        WebForm_GetElementById('nameNAvailable').style.display = "block";
        WebForm_GetElementById('nameAvailable').style.display = "none";
        WebForm_GetElementById(btnName).disabled = true;
    }
}
function orderRegister(txtLogin, txtPass, ddlProfile) {

    WebService.saveSession('createLogin&createPass&createProfile', WebForm_GetElementById(txtLogin).value + '&' + WebForm_GetElementById(txtPass).value + '&' + WebForm_GetElementById(ddlProfile).value, orderRegisterDone);
}
function orderNotRegister(ddlProfile) {
    WebService.saveSession('createProfile', WebForm_GetElementById(ddlProfile).value, orderNotRegisterDone);
}
function orderRegisterDone() {
    showCashDesk(1);
}
function orderNotRegisterDone() {
    showCashDesk(2);
}

//------------------------ order checks
function checkEighteen(text, chckName) {
    if (WebForm_GetElementById(chckName).checked == true) return true;
    else return confirm(text);
}


//------------------------ order menu funcs

var onOffering = false;

function divColor(name, color) {
    var divColorize = WebForm_GetElementById(name);
    divColorize.style.background = color;
}
function order(cType, idWare, txtCount) {
    var tct = WebForm_GetElementById(txtCount);
    showWaitpanel = false;
    WebService.orderItem(idWare, tct.value, cType, onOrderDone);
}
function onOrderDone() {
    __doPostBack('cartPan', '');
}
function setOrderHeight(hghtValue, divName) {
    var hght = WebForm_GetElementById(divName);
    hght.style.height = hghtValue + "px";
}
function addPiece(name) {
    var tb = WebForm_GetElementById(name);
    tb.value = Number(tb.value) + 1;
}
function remPiece(name) {
    var tb = WebForm_GetElementById(name);
    if (tb.value > 1) tb.value -= 1;
}

//------------------------ showing ajax panel


function showDetail(id) {
    window.scrollTo(0,100);
    var val = WebForm_GetElementById("aTxt");
    val.value = id;
    if (document.getElementById("warePage_amount2_ddlOptions") != null) { document.getElementById("warePage_amount2_ddlOptions").style.display = "none"; }
    __doPostBack('aPan', '');
}
function showCashDesk(id) {
    window.scrollTo(0,100);
    var val = WebForm_GetElementById("aTxt");
    val.value = "cd" + id;
    if (document.getElementById("warePage_amount2_ddlOptions") != null) { document.getElementById("warePage_amount2_ddlOptions").style.display = "none"; }
    __doPostBack('aPan', '');
}
function showCashLogin() {
    window.scrollTo(0,100);
    var val = WebForm_GetElementById("aTxt");
    val.value = "lb";
    if (document.getElementById("warePage_amount2_ddlOptions") != null) { document.getElementById("warePage_amount2_ddlOptions").style.display = "none"; }
    __doPostBack('aPan', '');
}
function showFriendMail() {
    window.scrollTo(0,100);
    var val = WebForm_GetElementById("aTxt");
    val.value = "mb" + WebForm_GetElementById("friendMail").value;
    
    //if (document.getElementById("warePage_amount2_ddlOptions") != null) { document.getElementById("warePage_amount2_ddlOptions").style.display = "none"; }
    __doPostBack('aPan', '');
}
function hideAjaxPanel() {
    //var val = WebForm_GetElementById("aTxt");
    //val.value = "";
    //__doPostBack('aPan', '');
    if (document.getElementById("warePage_amount2_ddlOptions") != null) { document.getElementById("warePage_amount2_ddlOptions").style.display = "inline"; }
    WebForm_GetElementById("aDiv").style.display = "none";
}
function reloadAjaxPanel() {
    __doPostBack('aPan', '');
}
function reportAjaxActivity() {
    WebForm_GetElementById("waitPanel").style.display = "block";
}
function clearAjaxActivity() {
    WebForm_GetElementById("waitPanel").style.display = "none";
}

//------------------------ ajax handlers
//handles updatePanel request starting
function BeginRequestHandler(sender) {
    if (showWaitpanel == true) reportAjaxActivity();
    //disable orderbuttons, if possible
    var btns = WebForm_GetElementById("orderButtons");
    if (btns != null) btns.style.display = "none";

    
}

//handles updatePanel request ending
function EndRequestHandler(sender, args) {
    if (args.get_error() == undefined) {
        clearAjaxActivity();
        showWaitpanel = true;
    }
    else { args.set_errorHandled(true); }
}

//initialize updatepanel-set
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler);



//------------------------ rolling "added to cart"

var movingIn = false;
var movingOut = false;
var delaying = false;

function moveIn(strDisplay, divName) {
    var myDiv = WebForm_GetElementById(divName);
    if (myDiv == null) return;
    myDiv.className = 'roller' + strDisplay;
    if (movingIn || movingOut || delaying) { setTimeout('moveIn("' + strDisplay + '", "' + divName + '");', 100); return; }
    t = 120;
    if (movingOut) clearInterval(moveOutTimer);
    if (movingIn) clearInterval(moveInTimer);
    movingIn = true;
    moveInTimer = setInterval('stepIn("' + strDisplay + '", "' + divName + '")', 1);
}

function stepIn(strDisplay, divName) {
    t += 2;
    var wi = parseInt(180 - 0.1 * (180 - t) * (180 - t));
    if (wi < 0) wi = 0;
    var myDiv = WebForm_GetElementById(divName)
    if (myDiv == null) {
        return;
        clearInterval(moveInTimer);
        movingIn = false;
    }
    myDiv.style.width = wi + "px";

    if (t == 180) {
        clearInterval(moveInTimer);
        delaying = true;
        movingIn = false;
        setTimeout('moveOut("' + divName + '")', 1000);
    }
}

function moveOut(divName) {
    movingOut = true;
    delaying = false;
    moveOutTimer = setInterval('stepOut("' + divName + '")', 10);
}

function stepOut(divName) {
    t -= 2;
    var myDiv = WebForm_GetElementById(divName);
    if (myDiv == null) {
        clearInterval(moveOutTimer);
        movingOut = false;
    }
    myDiv.style.width = parseInt(180 - 0.05 * (180 - t) * (180 - t)) + "px";
    if (t <= 120) {
        clearInterval(moveOutTimer);
        movingOut = false;
        t = 120;
    }
}

function showSpan(id) {
    for (i = 0; i < 9; i++) {
        document.getElementById("Span" + i).style.display = 'none';
    }
    document.getElementById("Span" + id).style.display = 'inline';
}


//------------------------ add handler and handle mail enter


function friendMail() {

    document.getElementById("mBox1_txtTo").value = document.getElementById("friendMail").value;
document.getElementById("staticcontent2").style.display='block';

}