﻿
/*Headlines rotator*/
var c = "ctl00_MainContent_"
var headline_count;
var headline_interval;
var old_headline = 0;
var current_headline = 0;
var tabId = "Li1";
$.ui.dialog.defaults.bgiframe = true;

var pn = {}; //entered part number set of info
var sn = {}; //supersession part number set of info
var ln = "";
var sid;//sets the current supersession idreturn "";
var id; //sets the current id
var oldQty; //sets the previous/old value on the textbox
var q; //sets the New(user input) value on the textbox
var line = "";
var isDup = false;
var binArray = new Array();

var sessionExpired = false;
var sessionTimeout = 10000;

var dialogArray = new Array();
var submitWithoutReference = false;
var cancelOrderConfirmed = false;
//http://forums.asp.net/p/1426825/3183546.aspx



$(document).ready(function() {
    //alert("loading ...");
    LoadDocument();
});         //end of $(document).ready function


function LoadDocument() {
    //_Alert("in document.ready", false);
    var pg0 = $('#aspnetForm').attr('action');
    var pg = CurrentPage();

    switch (pg || pg0) {
        case 'stockorder_additems.aspx': addItemLoad(); break;
        case 'stock_order.aspx': stockOrderLoad(); break;
        case 'stock_order_new.aspx': stockOrderLoad(); break;
        case 'stock_orders.aspx': stockOrderLoad(); break;
        case 'returns.aspx': returnsLoad(); break;
        //case 'locator.aspx': locatorLoad(); break;
        //case 'select_dealer.aspx': selectDealerLoad(); break;    
        case 'overrides.aspx': overridesLoad(); break;
        //case 'smartgauge.aspx': smartGaugeLoad("td SmartBoxHeader"); break;             
        case 'smartgauge.aspx':
            smartGaugeLoad("div.smartBox_photoShop td a.SmartBoxHeader");
            break;
        case 'smartgaugeaging.aspx': smartGaugeLoad("td.HoverLink a"); break;
        case 'support.aspx': supportLoad(); break;

        default:
            break;
    }
    generalLoad();
    LoadSearchfunction();
}

function SetTimeOut(functionName, timeoutSeconds) {
    window.setTimeout(functionName, timeoutSeconds*1000);
}

/*
function scriptLoad() {
    $('').click(function() {
        $.download('/export.php', 'filename=mySpreadsheet&format=xls&content=' + spreadsheetData);
    });
}
*/


//###########################################################################################################
//General Functions
//rotator
function generalLoad() {
    headline_count = $("div.headline a").size();
    $("div.headline a:eq(" + current_headline + ")").css('top', '5px');
    headline_interval = setInterval(headline_rotate, 6000);
    $('#scrollup').hover(function() {
        clearInterval(headline_interval);
    }, function() {
        headline_interval = setInterval(headline_rotate, 6000);
        headline_rotate();
    });
    //this assign click events to the scrolls on the header
    $("div.headline a").click(function() {
        var e = document.URL.substring(document.URL.lastIndexOf("/") + 1);
        if (e != "Default.aspx") {
            //          document.location = "http://staging.partseye.net/Default.aspx";

        }
        else {
            closeAll();
            var id = $(this).attr("title");
            $("#" + id).addClass("down");
            // AJAX Call to the article.aspx to load details
            //$.get("articles.aspx?id=" + id, function(data) {
            $.get("articles.aspx?id=" + id, function(data) {
                $("#details" + id).html(data);
            });
            $("#details" + id).addClass("news_detail");
            showLink(id);
        }
    });

    //this assign click events to the view detail links of the hot topics
    $(".view").click(function() {
        closeAll();
        var id = $(this).attr("title");
        $("#" + id).addClass("down");
        //AJAX Call to the article.aspx to load details
        //$.get("articles.aspx?id=" + id, function(data) {
        $.get("articles.aspx?id=" + id, function(data) {
            $("#details" + id).html(data);
        });
        $("#details" + id).addClass("news_detail");
        showLink(id);
    })
    //this is hiding the Hide Details link
    $(".tog").click(function() {
        closeAll();
    })
    var ids = new Array("Li1", "Li2", "Li3", "Li4", "Li5", "Li6", "Li7", "Li8", "Li9", c+"Li10");
    for (var i = 0; i < ids.length; i++) {
        $("#" + ids[i]).removeClass("current");
    }
    var pg = $('#aspnetForm').attr('action');
    if (pg) {
        pg = pg.substring(0, pg.indexOf("?"));
    }
    //    switch (pg ||$('form').attr('action'))
    switch (pg || $("#aspnetForm").attr("action")) {
        case "smartgauge.aspx":
        case "smartGaugeAging.aspx":
            tabId = "Li2"; break;
        case "reports.aspx":
        case "inventory_list.aspx":
        case "orders.aspx":
        case "order_detail.aspx":
        case "special_order.aspx":
        case "special_report.aspx":
        case "suggested_report.aspx":
        case "suggested_stock.aspx":
        case "ppi.aspx":
        case "parts.aspx":
        case "reports_email.aspx":
        case "return_summary.aspx":
        case "return_detail.aspx":
        case "custom_report.aspx":
            tabId = "Li3"; break;
        case "stock_order.aspx":
        case "stock_orders.aspx":
        case "stock_order_new.aspx":
        case "stockorder_additems.aspx":
            tabId = "Li4"; break;
        case "locator.aspx":
            tabId = "Li5"; break;
        case "returns.aspx":
            tabId = "Li6"; break;
        case "support.aspx":
        case "support_faq.aspx":
            tabId = "Li7"; break;
        case "overrides.aspx":
            tabId = "Li8"; break;
        case "select_dealer.aspx":
            tabId = "Li9"; break;
        case "errors.aspx":
            tabId = "ctl00_Li10"; break;
        default:
            tabId = "Li1";
            break;
    }
    $("#" + tabId).addClass("current"); //this assigns the active tab

    //this selects the calendar in the Manual Override list and tooltip fuctions
    if($("#"+c+"from_tb").length > 0)
    {
        try{ $("#"+c+"from_tb").datepicker(); }
        catch(e){ }
    }
    if ($("#" + c + "to_tb").length > 0) {
        try{ $("#" + c + "to_tb").datepicker(); }
         catch(e){ }
     }
    //$(".date-picker").datepicker();
    //Alert("is stock tool tip",true);
    
    //use this class for image hooking of ajax
    //$("img.tooltips, .tooltip a").tooltip({
    $("img.tooltips, .tooltip a").tooltip({
        bodyHandler: function() {
           
            var part = "";
            if (CurrentPage().indexOf("stock_order") >= 0) {
                part = $('#' + this.id.replace("hist", "part_hl")).attr("title");
            }
            else {
                part = $(this).attr("href");
                if (part) {
                    part = part.substring(1, part.length);
                } else {
                    //user this part if getting it directly from image
                    part = $(this).attr("id");
                }
            }
            if (!part) {
                $(this).tooltip($.tooltip.block);
                return ""; 
            }

            var retVal = "Tool Tip Failed";

            $.ajax({
                type: "GET",
                url: "override_history.aspx?part=" + part,
                data: {},
                cache: false,
                async: false,
                success: function(html) {
                    retVal = html;
                },
                error: function(XMLHttpRequest, textStatus, message) {
                    //alert("There was an error on the process please try to enter the part again");
                    //ERROR ACTION - NEEDS TO BE FILLED WITH PROPER CODE
                    retVal = "Tool Tip Failed " + textStatus + " " + message;
                }
            });

            return retVal;
        },
        track: false,
        delay: 0,
        showURL: false,
        positionLeft: true,
        //top: -40,
        top: 17,
        //left: -15
        left: 55
    });

    InitHistoryDialog();

    $("#dialogMaster").dialog({
        autoOpen: false,
        title: '&nbsp;&nbsp;',
        modal: true,
        overlay: {
            backgroundColor: '#000',
            opacity: 0.5
        },
        buttons: {
            "OK": function() {
                $(this).dialog("close");
            }
        }
        , close: function(event, ui) { }
    });

    $("#invalidContactDialog").dialog({
        autoOpen: false,
        title: '&nbsp;&nbsp;Found Invalid Contact Information',
        modal: true,
        overlay: {
            backgroundColor: '#000',
            opacity: 0.5
        },
        buttons: {
            "OK": function() {
                $(this).dialog("close");
            }
        }
        , close: function(event, ui) { }
    });

    $("#prntHistBtn").remove("attr", "onclick");
    $("#prntHistBtn").click(function () {
        popUp('stkOrder_prtHist.aspx?oref=' + Get("#" + c + "orderRef_tb"), 1050, 650);
        return true;
    });      
} //end of generalLoad()
//###########################################################################################################

//all Functions out of document ready
function closeAll() {
    $(".news_detail").addClass("hide");
    $(".news_detail").removeClass("news_detail"); //hides all other details
    $(".down").removeClass("down"); //corrects all arrows
    $(".view").addClass("show"); //shows all other View Details link 
    $(".tog").removeClass("show");
    $(".tog").addClass("hide"); //hides all other Hide Details link
}
function showLink(id) {
    $("#view" + id).removeClass("show");
    $("#view" + id).addClass("hide");
    $("#hide" + id).removeClass("hide");
    $("#hide" + id).addClass("show");
}


//rotator functions
function headline_rotate() {
    current_headline = (old_headline + 1) % headline_count;
    $("div.headline a:eq(" + old_headline + ")")
 .animate({ top: -205 }, "slow", function() {
     $(this).css('top', '210px');
 });

    $("div.headline a:eq(" + current_headline + ")")
 .animate({ top: 5 }, "slow");
    old_headline = current_headline;
}

function ChangeCheckBoxState(id, checkState) {
    var cb = document.getElementById(id);
    if (cb != null)
        cb.checked = checkState;
}
function ChangeAllCheckBoxStates(checkState) {
    if (CheckBoxIDs != null) {
        for (var i = 0; i < CheckBoxIDs.length; i++)
            ChangeCheckBoxState(CheckBoxIDs[i], checkState);
    }
}

//Locator page - search options box hide and show function
function displaySearch(id) {
    
    if (id == "hideLnk") {
        $("#showLnk").removeClass("hide");
        $("#showLnk").addClass("show");
        $("#hideLnk, #locator").removeClass("show");
        $("#hideLnk, #locator").addClass("hide");
    }
    else {
        $("#showLnk").removeClass("show");
        $("#showLnk").addClass("hide");
        $("#hideLnk, #locator").removeClass("hide");
        $("#hideLnk, #locator").addClass("show");
    }
}

//Report printing for pages: order and order_detail 
function popUp(url, width, height) {
    sealWin = window.open
        (url, "win", 'toolbar=0,location=1,directories=0,status=0,menubar=0,scrollbars=yes,resizable=0,width='
            + width + ',height=' + height);
    self.name = "mainWin";
}

function OpenPage() {
    //mywindow = window.open('PrintSmartGauge.aspx', 'mywindow', 'resizable=yes,scrollbars=yes,location=1,status=0,menubar=1,toolbar=1,height=1000, width=1000');
    //moved page to base
    mywindow = window.open('PrintSmartGauge.aspx', 'mywindow', 'resizable=yes,scrollbars=yes,location=1,status=0,menubar=1,toolbar=1,height=1000, width=1000');
    mywindow.focus();
}


//###########################################################################################################
//stock_order page general functions
function addLineArray(tbValue) {
    for (var i = 0; i < binArray.length; i++) {
        if (tbValue == binArray[i]) {
            tbValue = "";
            return
        }
    }
    binArray.push(tbValue);
    $("#" + c + "arrayContainer").val(binArray);
}

function SetFocus(id) {
    var elem = $("#" + id);
    if (elem) {
        elem.focus();
    }
}

function ShowSelectDealerDialog() {
    var elem = $('#selectDealerDialog');
    if (elem) {
        var status = $('#ctl00_MainContent_dealerStatus').val();
        if (status && status == "1") {
            //alert("User has not selected a dealer");
            $('#selectDealerDialog').dialog('open');
        }
    }
}

function ShowMakeMessage() {
    $("div#dialogMakeMessage").dialog({
        autoOpen: false,
        title: '&nbsp;&nbsp;Subaru Announcement',
        modal: true,
        overlay: {
            backgroundColor: '#000',
            opacity: 0.5
        },
        buttons: {
            "OK": function() {
                $(this).dialog("close");
            }
        }
        , close: function(event, ui) { }
    });
    //$("#dialogMakeMessage").dialog("option", "title", "&nbsp;&nbsp;Subaru Announcement");
    $("#dialogMakeMessage").dialog("open");
}

function ShowDealerAnnouncement() {
    $("a#dealerAnnouncementLink").click();
}

function OpenDealerAnnouncement(linkClicked) {
    var href = linkClicked.href;
    var message = "Dealer Announcement - Click the X on the right to return to the previous page";
    var showFullScreen = true;
    var closeCallBackFunc = null;
    return GB_showPage(message, href, closeCallBackFunc, showFullScreen);
}

//http: //www.hunlock.com/blogs/Snippets:_Howto_Grey-Out_The_Screen
function grayOut(vis, options) {
    // Pass true to gray out screen, false to ungray  
    // options are optional.  This is a JSON object with the following (optional) properties  
    // opacity:0-100         
    // Lower number = less grayout higher = more of a blackout   
    // zindex: #             
    // HTML elements with a higher zindex appear on top of the gray out  
    // bgcolor: (#xxxxxx)    
    // Standard RGB Hex color code  
    // grayOut(true, {'zindex':'50', 'bgcolor':'#0000FF', 'opacity':'70'});  
    // Because options is JSON opacity/zindex/bgcolor are all optional and can appear
    // in any order.  Pass only the properties you need to set.  var options = options || {};

    var zindex = options.zindex || 50; 
    var opacity = options.opacity || 70;
    var opaque = (opacity / 100); 
    var bgcolor = options.bgcolor || '#000000';
    var dark = document.getElementById('darkenScreenObject');
    if (!dark) {
        // The dark layer doesn't exist, it's never been created.  So we'll
        // create it here and apply some basic styles.
        // If you are getting errors in IE see: http://support.microsoft.com/default.aspx/kb/927917
        var tbody = document.getElementsByTagName("body")[0];
        var tnode = document.createElement('div');
        // Create the layer.        
        tnode.style.position = 'absolute';
        // Position absolutely        
        tnode.style.top = '0px';
        // In the top        
        tnode.style.left = '0px';
        // Left corner of the page       
        tnode.style.overflow = 'hidden';
        // Try to avoid making scroll bars                    
        tnode.style.display = 'none';
        // Start out Hidden        
        tnode.id = 'darkenScreenObject';
        // Name it so we can find it later    
        tbody.appendChild(tnode);
        // Add it to the web page    
        dark = document.getElementById('darkenScreenObject');
        // Get the object.  
    }
    if (vis) {
        // Calculate the page width and height     
        if (document.body && (document.body.scrollWidth || document.body.scrollHeight)) {
            var pageWidth = document.body.scrollWidth + 'px';
            var pageHeight = document.body.scrollHeight + 'px';
        }
        else if (document.body.offsetWidth) {
            var pageWidth = document.body.offsetWidth + 'px';
            var pageHeight = document.body.offsetHeight + 'px';
        }
        else {
            var pageWidth = '100%';
            var pageHeight = '100%';
        }
        //set the shader to cover the entire page and make it visible.    
        dark.style.opacity = opaque;
        dark.style.MozOpacity = opaque;
        dark.style.filter = 'alpha(opacity=' + opacity + ')';
        dark.style.zIndex = zindex;
        dark.style.backgroundColor = bgcolor;
        dark.style.width = pageWidth;
        dark.style.height = pageHeight;
        dark.style.display = 'block';
    }
    else {
        dark.style.display = 'none';
    }
}

/*
See default.css for styling
*/
function grayOutGrid(vis, options, gridID) {
    // Pass true to gray out screen, false to ungray  
    // options are optional.  This is a JSON object with the following (optional) properties  
    // opacity:0-100         
    // Lower number = less grayout higher = more of a blackout   
    // zindex: #             
    // HTML elements with a higher zindex appear on top of the gray out  
    // bgcolor: (#xxxxxx)    
    // Standard RGB Hex color code  
    // grayOut(true, {'zindex':'50', 'bgcolor':'#0000FF', 'opacity':'70'});  
    // Because options is JSON opacity/zindex/bgcolor are all optional and can appear
    // in any order.  Pass only the properties you need to set.  var options = options || {};

    var zindex = options.zindex || 50;
    var opacity = options.opacity || 50;
    var opaque = (opacity / 100);
    var bgcolor = options.bgcolor || '#000000';
    var dark = document.getElementById('grayedOutGrid');
    
    if (!dark) {
        // The dark layer doesn't exist, it's never been created.  So we'll
        // create it here and apply some basic styles.
        // If you are getting errors in IE see: http://support.microsoft.com/default.aspx/kb/927917
        var tbody = document.getElementsByTagName("body")[0];
        var tnode = document.createElement('div');
        var div = document.getElementById('grayedOutGridDiv');
      
        // Create the layer.        
        tnode.style.position = 'absolute';
        // Position absolutely
        //tnode.style.top = gridElem.style.top;
        // In the top
        //tnode.style.left = "";
        // Left corner of the page       
        tnode.style.overflow = 'hidden';
        // Try to avoid making scroll bars                    
        tnode.style.display = 'none';
        // Start out Hidden
        tnode.id = 'grayedOutGrid';
        // Name it so we can find it later
       
        if (div) {
            div.appendChild(tnode);
        }
        else {
            tbody.appendChild(tnode);
        }
        // Add it to the web page
       
        dark = document.getElementById('grayedOutGrid');
        // Get the object.  
    }
    if (vis) {
        //logic has been moved to the css style
        //set the shader to cover the entire page and make it visible.
        
        dark.style.opacity = opaque;
        dark.style.MozOpacity = opaque;
        dark.style.filter = 'alpha(opacity=' + opacity + ')';
        dark.style.zIndex = zindex;
        dark.style.backgroundColor = bgcolor;
        dark.style.display = 'block';
    }
    else {
        dark.style.display = 'none';
    }

    //_Alert($("grayedOutGrid").html(), true);
}


function _SH(part) {
    ShowHistory(histDivOrSpan);
}

function _SH2(partNum) {
    ShowHistoryPart(partNum);
}

function _SH(histDivOrSpan) {
    ShowHistory(histDivOrSpan);
}

function _CH() {
    CloseHistory();
}

function CloseHistory() {
    var dialogName = "history_div";
    var currPage = CurrentPage();
    /*
    //if (currPage == "smartgauge.aspx" || currPage == "smartgaugeaging.aspx") { 
    if(currPage.indexOf("smartgauge.aspx") >= 0 || currPage.indexOf("smartgaugeaging.aspx") >= 0){
        dialogName = "dialog_rpv_tooltip";
    }
    */
    if ($('#' + dialogName)) {
        var dialogOpen = $('#' + dialogName).dialog("isOpen");
        if (dialogOpen) {
            CloseDialog(dialogName);
        }
        else {
            //OpenDialog(dialogName);
        }
    }
}

/* Function used by the spart gauge report viewer to display a modal window version of the part # demand info*/
function InitHistoryDialog() {
    //reset html content used to display the tool tip
    //CreateHistoryDiv();
    $("#history_div").html("");
    $(".ui-widget-content a").css("display", "none"); //hide the top right default close button with the x image

    $("#history_div").dialog({
        autoOpen: false,
        //title: '&nbsp&nbsp',
        modal: false,
        //width: 625,
        width: 645,
        //width: 'auto',//this will make the width extremely large
        //maxWidth: 650,
        maxWidth: 800,
        height: 'auto',
        overlay: {
            backgroundColor: '#000',
            opacity: 0.5
        },
        buttons: {
        },
        //bgiframe:false,
        closeOnEscape: true,
        //draggable: true,
        position: 'top'
        /*,
        //position: { right: '100', top: '0'}
        
        close: function() {
            //reset modocal dialog back to default
        }
        */
    });
     
     /* 
    //hooking into mouseout only if not stock order page. This is now done directly to html function call
    if (CurrentPage() != "stock_order.aspx") {
        //This is now hooked in directly to element on html page
       
        $(".tooltips").mouseover(function(e) {
            //ShowHistory(this);
        });

        $(".tooltips").mouseout(function(e) {
            //CloseHistory();
        });
    }
    */
}

function CreateHistoryDiv()
{
    var histDiv = document.getElementById('historyDiv');
    
    if (!histDiv) {
        var body = document.getElementsByTagName("body")[0];
        var div = document.createElement('div');
        div.id = "historyDiv";
        body.appendChild(div);
        // Add it to the web page
        histDiv = document.getElementById('historyDiv');
    }
    
    return histDiv;
}

function ShowHistory(histDivOrSpan) {
    var img = $(histDivOrSpan).children(":img");
    var part = "";
    var id = $(img).attr("id");
    if (CurrentPage().indexOf("stock_order") >= 0) {
        part = $('#' + id.replace("hist", "part_hl")).attr("title");
    }
    else {
        part = $(img).attr("href");
        if (part) {
            part = part.substring(1, part.length);
        } else {
            //user this part if getting it directly from image
            part = $(img).attr("id");
        }
    }
    if (part) {
        LoadHistory("history_div", part);
        ShowDialog("history_div");
    }
    else {
        return "Tool Tip Failed for part " + part;
    }
}


function ShowHistoryPart(partNum)
{
    if (partNum) {
        LoadHistory("history_div", partNum);
        ShowDialog("history_div");
    }
    else {
        return "Tool Tip Failed for part " + partNum;
    }
}

/* Function used by the smartgauge.aspx's report viewer to display a modal window version of the part # demand info*/
function LoadHistory(srcElem, partNum) {
    //make an ajax call to retrive data from override_history page
    var retVal = "Tool Tip Failed";

    $.ajax({
        type: "GET",
        url: "override_history_stock.aspx?part=" + partNum,
        //url: "override_history.aspx?part=" + partNum,
        data: {},
        cache: false,
        async: false,
        success: function(html) {
            retVal = html;
            retVal = retVal.substring(retVal.indexOf("<!--begin-->"), retVal.indexOf("<!--end-->"))
            $("#" + srcElem).html(retVal);
        },
        error: function(XMLHttpRequest, textStatus, message) {
            //alert("There was an error on the process please try to enter the part again");
            //ERROR ACTION - NEEDS TO BE FILLED WITH PROPER CODE
            retVal = "Tool Tip Failed " + textStatus + " " + message;
        }
    });
}



function Destroy(dialog) {
    //The history div does not call this function, so it's safe to say that it's another dialog being closed
    Arrayfunc(dialogArray, dialog.id, 2); //remove dialog from list of open dialog
    //$(dialog).dialog("destroy");
    grayOutGrid(false, { 'zindex': '50', 'bgcolor': '#0000FF', 'opacity': '70' });
}


function CloseDialog(dialogName) {
    $("#" + dialogName).dialog("close");
}

function dialogNormalIsOpen() {
    var arrIsEmpty = Arrayfunc(dialogArray, "", 0);
    if (arrIsEmpty == true) { return false; }
    else { return true; }

}

function ShowDialog(dialogName) {
    var foundNormal = dialogNormalIsOpen();
    if (!dialogName) {
        dialogName = "history_div";
    }
    
    //don't open the history div if a regular dilaog is currently open
    if (dialogName == "history_div" && foundNormal) {
        //close the history if currenlty open and disable it temporarily
        CloseDialog("history_div");
        $("#history_div").dialog("disable");
        return;
    }

    if (dialogName == "history_div" || dialogName == "dialog_rpv_tooltip") {
        $("#" +dialogName).dialog("enable");
        $(".ui-dialog .ui-dialog-titlebar").css("display", "none"); //hide the top empty title bar
    }
    else {
        Arrayfunc(dialogArray, dialogName, 1); //add dialog to list of open dialog
        $(".ui-dialog .ui-dialog-titlebar").css("display", "block"); //hide the top empty title bar
        CloseDialog("history_div");
        $("#history_div").dialog("disable");
        grayOutGrid(true, { 'zindex': '50', 'bgcolor': '#808080', 'opacity': '70' });
    }
    //common properties for all dialog\
    //This has been moved to dialog_red.css
    //$(".ui-dialog").css("border", "2px solid blue"); //hide the top empty title bar
    //$(".ui-dialog .ui-dialog-titlebar").css("padding", "0px"); //hide the top empty title bar
    //$(".ui-dialog .ui-dialog-buttonpane").css("padding", "0px"); //hide the top empty title bar
    //$(".ui-widget-content a").css("color", "#0000FF"); //format the custom close window links
    //$(".ui-widget-content a").css("text-decoration", "underline"); //format the custom close window links
    //$(".ui-widget-header .ui-icon").css("background-color", "blue"); //set back color of default close image to red

    $("#" + dialogName).dialog("open");
}

function ShowOrderReferenceMessage() {
    var orderRefNum = $("#" + c + "orderRef_tb").val();
    var message = orderRefNum + " is an invalid order referece number. Please enter a valid order reference number containing only letters and numbers. Spaces or special characters are not allowed.";
    $("#" + c + "orderRef_tb").val("");
    $("#dialogMaster_txt").html(message);
    $("#dialogMaster").dialog("option", "title", "&nbsp;&nbsp;Invalid Reference Number");
    $("#dialogMaster").dialog("open");
}

