﻿function showModalDialog(hdn,img,preview)
{
	doc=window.document;
	navVersion=navigator.appVersion.toLowerCase();
	this.ie4=(!doc.getElementById&&doc.all)?true:false;
	this.ie5=(navVersion.indexOf("msie 5.0")!=-1)?true:false;
	this.ie55=(navVersion.indexOf("msie 5.5")!=-1)?true:false;
	this.ie6=(navVersion.indexOf("msie 6.0")!=-1)?true:false;
	this.ie7=(navVersion.indexOf("msie 7.0")!=-1)?true:false;
	this.isIE=(this.ie5||this.ie55||this.ie6||this.ie7)?true:false;
	this.isGecko=!this.isIE;
	var url='/Admin/FileUploader.aspx?currentImageUrl='+document.getElementById(hdn).value+'&ShowSelect=1&hdnId='+hdn+'&imgId='+img+'&previewId='+preview;
	window.open(url,"", "resizable=yes,scrollbars=auto,status=yes,width="+window.screen.availWidth+",height="+window.screen.availHeight,true);
}
/*PAYMENT METHODS SCRIPTS*/
function onUseGiftCardClick(txtAmountSelectedId, maxAmount, pwId, parentPwId) {
    var txtAmountSelected = document.getElementById(txtAmountSelectedId);

    if (txtAmountSelected.value == maxAmount) {
        showMPE(pwId, '-1');
        return false;
    }
    else {
        hideMPE(parentPwId);
        return true;
    }
}

function onSelectGiftCertNotAllowed() {
    alert('You cannot select another gift certificate because the price of the order is already covered!');
    return false;
}

function onSelectGiftCertAmountHigherThanInvoice(totalAmountCoveredByCreditCardPaymentMethods) {
    var agree;
    agree = confirm('Warning! The gift certificate amount exceeds the invoice total by ' + totalAmountCoveredByCreditCardPaymentMethods + '. No change can be given. Do you want to continue anyway?');

    if (!agree)
        return false;
    else
        return true;
}

function onCreditCardSelectOrderAlreadyCovered() {
    alert('The payment of this order is totally covered by the gift card credit, gift certificates, in-store account credit. Please press NEXT button.');
    return false;
}

/*PAYMENT METHODS SCRIPTS*/


/*CUSTOMER SELECT SCRIPTS*/
function SetSelectedControl(hiddenFieldId, value) {    
    var hiddenField = document.getElementById(hiddenFieldId);

    hiddenField.value = value;
}

function CheckRadioListSelected(radioListName, messageLabelId, popupWindowId) {
    var radioSelected = false;
    var radioButtonList = document.getElementsByName(radioListName);
    for (counter = 0; counter < radioButtonList.length; counter++) {
        if (radioButtonList[counter].checked)
            radioSelected = true;
    }

    var label = document.getElementById(messageLabelId);
    if (!radioSelected && label != null) {
        label.innerText = 'Please select a group!';
        alert(label.innerText);
        return false;
    }
    else {
        label.innerText = '';
        return showMPE(popupWindowId, '-1');
    }
}
/*CUSTOMER SELECT SCRIPTS*/

/*PACKAGES SCRIPTS*/
function DontAllowSelecting(maximumNumberOfItems) {
    alert('You cannot select more that the maximum number of products allowed in this package group (' + maximumNumberOfItems + ' items(s)). In order to select a different item you need to deselect one of the selected one(s).');
    return false;
}
/*PACKAGES SCRIPTS*/


/*GENERAL SCRIPTS 


- can be used alternatively with AjaxToolkit: Confirmation - which has a bug when used on the same page with a PopupWindow*/
function onButtonConfirm(text) {
    var agree;
    agree = confirm(text);

    if (!agree)
        return false;
    else
        return true;
}

function FocusOnElement(elementId) {
    var element = document.getElementById(elementId);
    if (element != null) {
        element.focus();
    }
}

function IsCheckBoxChecked(elementId, message) {
    var element = document.getElementById(elementId);
    if (element != null && element.checked) {
        return true;
    }
    if (message != null)
        alert(message);
    return false;
}

function ClearSpanText(elementId) {
    var element = document.getElementById(elementId);
    if (element != null) {
        element.innerHTML = '';
    }
}
/*GENERAL SCRIPTS*/
if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();