
function ShowCropper()
{
    var cropperContainer = document.getElementById('cropperDiv');
    if(cropperContainer)
    {
        cropperContainer.className = 'showCropper';
    }
}
function HideCropper()
{
    alert('HideCropper()');
    var cropperContainer = document.getElementById('cropperDiv');
    HideElement(cropperContainer);
}
function HideElement(element)
{
    alert('HideElement(' + element + ')');
    if(element)
    {
        element.className = 'hiddenElement';
    }
}
function SetCropImageId(hiddenId, cropImageId)
{
    alert('SetCropImageId(' + hiddenId + ',' + cropImageId + ')');
    var hidden = document.getElementById(hiddenId);
    if(hidden)
    {
        hidden.value = cropImageId;
        HideCropper();
    }   
}
function EnableUpload(enabled)
{
    var lblFu = document.getElementById('productForm_ucImageUploadView_lblUploadImage');
    if(lblFu){ lblFu.disabled = !enabled; }
    var fuImg = document.getElementById('productForm_ucImageUploadView_fuImage');
    if(fuImg){ fuImg.disabled = !enabled; }
    var btnUpload = document.getElementById('productForm_ucImageUploadView_btnUpload');
    if(btnUpload){ btnUpload.disabled = !enabled; }
    var chkWillEmail = document.getElementById('productForm_ucImageUploadView_chkWillEmailPhoto');
    if(chkWillEmail){ chkWillEmail.disabled = !enabled; }
    var lblEmail = document.getElementById('productForm_ucImageUploadView_lblEmailPhoto');
    if(lblEmail){ lblEmail.disabled = !enabled; }
    //var btnSubmit = document.getElementById('productForm_btnAddToCart');
    //if(btnSubmit){ 
        //alert('enabled: ' + enabled + ', btnSubmit.disabled: ' + btnSubmit.disabled + ', chkWillEmail.checked: ' + chkWillEmail.checked);
        //btnSubmit.disabled |= (enabled || !chkWillEmail.checked); }
}

var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
// Handle all the FSCommand messages in a Flash movie.
function ImageCropper_DoFSCommand(command, args) {
	var ImageCropperObj = isInternetExplorer ? document.all.ImageCropper : document.ImageCropper;
    alert('ImageCropper_DoFSCommand(' + command + ', ' + args + ')');
    if (command == "setCropImageId") {
        var id = args.split('|');
        if(id.length && id.length == 2)
        {
            SetCropImageId(id[0],id[1]);
        }
    }
}
// Hook for Internet Explorer.
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<script language=\"VBScript\"\>\n');
	document.write('On Error Resume Next\n');
	document.write('Sub ImageCropper_FSCommand(ByVal command, ByVal args)\n');
	document.write('	Call ImageCropper_DoFSCommand(command, args)\n');
	document.write('End Sub\n');
	document.write('</script\>\n');
}


 $(document).ready(function() {
    // Cart
    $("div.productEditor").hide("fast",  function(){ $("table.collapsibleTable").css("table-layout","auto"); });
    $("a.editorFader").click(function() { 
        $(this).parent().slideUp("slow");
        $(this).parent().parent().find("div.productEditor").slideDown("slow");
    });
    $("a.viewFader").click(function() { 
        $(this).parent().slideUp("slow");
        $(this).parent().parent().find("div.productView").slideDown("slow");
    });
    // Order history
    $("div.orderProducts").hide("fast",  function(){ $("table.collapsibleTable").css("table-layout","auto"); });
    $("a.orderHeader").click(function() { 
        $(this).parent().parent().next().find("div.orderProducts").slideToggle();
    });
    $("a.productHeader").parent().parent().find("div.productDetails").hide("fast",  function(){ $("table.collapsibleTable").css("table-layout","auto"); });
    $("a.productHeader").click(function() {
     $(this).parent().parent().find("div.productDetails").slideToggle();
   });
 });
