﻿// JScript File

function PageReady()
{
    document.aspnetForm.action = window.location.href;
}

function animateObj(obj, properties, timeout)
{
    jQuery(obj).animate( properties , timeout )
}

function offerBlowup(oid)
{
  var imageURL = "images/offers/"+oid+"_blowup.jpg"
  var w = 311
  var h = 670
  var windowBody 
  windowBody = "<HTML><HEAD><TITLE>Panel Stock</TITLE><style>body {padding:0px;margin:0px;font-family:verdana;color:#011E84}</style></HEAD><BODY bgcolor='#FFFFFF' text='#000000'>"
  windowBody = windowBody + "<table cellpadding='0' cellspacing='0' border='0' style='padding:10px'><tr><td><img src='"+ imageURL + "' border='0'></td></tr></table>"
  windowBody = windowBody + "</BODY></HTML>"
  
  newWindow = window.open('','newWin','scrollbars=auto,width='+w+',height='+h) 
  newWindow.document.write(windowBody);
  newWindow.focus()
}

/************* Wizard Related ************/
function Wizard_BuildSteps()
{
    jQuery(".wizard-step").each(function(){
        $this = jQuery(this);
        $this
            .wrap("<div class='wizard-step-container'><\/div>")
            .before("<div class='wizard-step-top'><\/div>")
            .after("<div class='styling-clear-left'><\/div>")
            .children("div.wizard-step-item")
                .append("<div class='styling-clear-left'><\/div>")
                .find("div:first")
                    .addClass("user-input");
    });
}

function Wizard_SelectionsToggle()
{
    jQuery(".wizard-selections-stage-details").each(function(){
        jQuery(this).find("a").each(function(){
            jQuery(this).toggle(
                function(){
                    jQuery(this).parent().siblings(".wizard-selections-items-group").slideDown(800, function(){
                        jQuery(this).fadeIn();
                    });
                },
                function(){
                    jQuery(this).parent().siblings(".wizard-selections-items-group").fadeTo(800, 0.1, function(){
                        jQuery(this).slideUp(800);
                    });
                }
            );
        });
        jQuery(this).find(".wizard-selections-item")
            .append("<div class='styling-clear-left'><\/div>")
            .wrapAll("<div class='wizard-selections-items-group'></div>");
    });    
}

// Callback for the ajax requests when finished selecting list item
function Select_Panel_ListItem_OnResponseEnd(sender, args)
{
    // RadAjaxManger does not like re-written url's too much
    // So when we are finished with the manager (now), revert the page form action to
    // the current window location
    document.aspnetForm.action = window.location.href;

    // Get control which just triggered ajax post
    var controlTrigger = args.EventTarget;
    
    // If its the glass design drop down
    if (controlTrigger == "ctl00$ContentPlaceHolder_Main$ddl_Glass_Design")
    {
        /* Flash the wizard-selections-total box to show updated price
        jQuery(".wizard-selections-total")
            .css("background-color","#F1740A")
            
        var animateProperties = { backgroundColour:"#2D3236" };
        
        window.setTimeout( function()
        {
            animateObj('.wizard-selections-total', animateProperties, '500');
        }, 1000);
        */
    }
}
/* ////////// Wizard Related ////////// */

/************* Composite Door Wizard Related ************/
function CompDoor_SelectFrame()
{
    jQuery(".page-overlay")
        .css("opacity",0)
        .css("display","block")
        .animate( { opacity:0.8 }, 600, function()
        {
            $el = jQuery(this).next();
            var x = jQuery("body").width();
            $el.css("left", ( (jQuery("body").width()/2)-($el.width()/2) ) );
            $el.fadeIn(200);
        })
        
}
function CompDoor_GetFrames()
{
    jQuery(".frame-item").hide();
    // Get selected items from dropdown
    pivotSelected = jQuery("#frame-select-pivotside").val();
    swingSelected = jQuery("#frame-select-swing").val();
    
    if (pivotSelected != "" && swingSelected != "")
    {
        // Go through each frame, and see if it matches the one we want, if so show it    
        jQuery(".frame-item").each(function(){
            $this = jQuery(this);
            pivotSide = $this.children(".frame-pivot").text();
            swingDir = $this.children(".frame-swing").text();
                        
            if ( (pivotSide == pivotSelected) && (swingDir == swingSelected) )
            {
                $this.fadeIn(300);
            }
        });
    }
}
function CompDoor_FrameSelected(pID, pName)
{
    jQuery(".frame-TypeID").val(pID);
    jQuery(".frame-Type").val(pName);

    jQuery(".lbl_FrameType").text(pName);
    
    if (pName == "DOOR SLAB ONLY")
    {
        jQuery(".addon-top, .addon-hinge, .addon-lock, .threshold-type, .cill-type, .frame-colour").each(
            function(){
                jQuery("option", this).each(function(){
                    if (jQuery(this).text() == "Not Required")
                    {
                        jQuery(this).attr("selected",true);
                    }
                });
            }
        );
    }
    else
    {
        jQuery(".addon-top, .addon-hinge, .addon-lock, .threshold-type, .cill-type, .frame-colour").each(
            function(){
                jQuery("option:first", this).attr("selected", true);
            }
        );
    }
    
    jQuery(".wizard-frame-selection").fadeOut(600, function(){
        jQuery(".page-overlay").fadeOut(200)
    });
}
/* /////////// Composite Door Wizard Related ////////// */

/************* Rad Windows ************/
function RadWindow_ShowLogin()
{
    jQuery("#index_flash_panel").css("visibility","hidden");
    var newWindow = window.radopen("/controls/User_Login/Login_Minified.aspx", "Login_Minified");
    return false;
}
function RadWindow_LoginClosed(sender)
{
    if (sender.Argument)
    {
        if (sender.Argument.success == "1")
        {
            if (sender.Argument.redirect != "")
            {
                window.location.href = sender.Argument.redirect;
            }
        }
    }
    jQuery("#index_flash_panel").css("visibility","visible");
}
function RadWindow_View_CTS_Order(pOrder)
{
    var wnd = window.radopen("/controls/ViewOrder/ViewOrder_CTS.aspx?order=" + pOrder, "ViewOrder");
	wnd.Maximize();
    return false;
}
function RadWindow_ViewOrder(pOrder)
{
    var wnd = window.radopen("/controls/ViewOrder/ViewOrder.aspx?order=" + pOrder, "ViewOrder");
    wnd.Maximize();
	return false;
}
function RadWindow_ViewCompositeOrder(pOrder)
{
    var wnd = window.radopen("/controls/ViewOrder/ViewCompOrder.aspx?order=" + pOrder, "ViewCompOrder");
    wnd.Maximize();
	return false;
}

/* ////////// Rad Windows ////////// */