﻿try
{
    document.execCommand('BackgroundImageCache', false, true);
} catch(e) {}

function showColumnMenu(columnNum)
{
    $get(hidColumnNumId).value = columnNum;
    eval(RefreshColumnListPostBack);
    HideSWFObjects();
    var modalPopupBehavior = $find('ColumnMenuPopupBehavior');
    modalPopupBehavior.show();
}
function hideColumnMenu(ev)
{
    var modalPopupBehavior = $find('ColumnMenuPopupBehavior');
    modalPopupBehavior.hide();
    ShowSWFObjects();
}

function ReceiveServerData(arg, context)
{
	var result = new Array();
	result = arg.split('|');
	switch(result[0])
	{
		case 'DELETE':
			var element = $get(result[1]);
			element.parentNode.removeChild(element);
			break;
		case 'ERROR':
		    alert('An error has occurred, the page will now refresh. If the problem persists please contact Internova UK Ltd.');
		    location.reload(true);
		    break;
		default:
			break;
	}
}

function beginRequest(sender, args)
{
    var r=args.get_request();
    if (r.get_headers()["X-MicrosoftAjax"])
    {
        b=r.get_body();
        var a="__MicrosoftAjax=" +
        encodeURIComponent(r.get_headers()["X-MicrosoftAjax"]);
        if (b!=null && b.length>0)
        {
            b+="&";
        }
        else
        b="";
        r.set_body(b+a);
    }
}
$(document).ready(function() {
    try {
        Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(beginRequest);
    } catch (e) { }

    // hide button values for opera
    if ($.browser.opera)
        $('#ColumnLeft .miniBasket .button,#Content .imageChooserMenuBox .button,#Content .productDetails .buyBtn, #Content .productDetails .buyBtnDisabled,.imageChooserPopup .chooserButtons .button,.imageChooserPopup .enlarge .description .button,.carouselButtons .button').val('');

    // Menu functions (will only operate when menu divs are present
    $('#Sheet #Navigation ul li').mouseover(function() {
        $(this).contents('.navSub').css({ display: 'block', visibility: 'visible' });
    });

    $('#Sheet #Navigation ul li').mouseout(function() {
        $(this).contents('.navSub').css({ display: 'none', visibility: 'hidden' });
    });
});

function hideModuleOptions(modalPopupBehaviour, validationGroup)
{
    ShowSWFObjects();
    if(validationGroup)
    {
        var valid = true;
        try {
            Page_ClientValidate(validationGroup);
            valid = Page_IsValid;
        } catch (e) { } 
        if(valid)
            $find(modalPopupBehaviour).hide();
    }
    else
        $find(modalPopupBehaviour).hide();
}


function HideSWFObjects()
{
    $('.swfObject').css('visibility', 'hidden');
}

function ShowSWFObjects()
{
    $('.swfObject').css('visibility', 'visible');
}

