$(document).ready(function(){    jQuery.fn.linkedSelect = function(url, destination, params){        var params = $.extend({            firstOption: 'Please Select',            loadingText: 'Loading...'        }, params);        var $dest = $(destination);        return this.each(function(){            $(this).bind('change', function(){                var $$ = $(this);                $dest.attr('disabled', 'false').append('<option value="">' + params.loadingText + '</option>').ajaxStart(function(){                    $$.show();                });                $.getJSON(url, {                    str: $$.val()                }, function(j){                    if (j.length > 0) {                        var options = '<option value="">' + params.firstOption + '</option>';                        for (var i = 0; i < j.length; i++) {                            options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>';                        }                    }                    $dest.removeAttr('disabled').html(options).find('option:first').attr('selected', 'selected');                });            });        });    };    jQuery.fn.extend({        check: function(){            return this.each(function(){                this.checked = true;            });        },        uncheck: function(){            return this.each(function(){                this.checked = false;            });        },        is_selected: function(){            return this.each(function(){                if (this.checked == true)                     return this.val();            });        },        select: function(){            return this.each(function(){                this.selected = true;            });        },        unselect: function(){            return this.each(function(){                this.selected = false;            });        },        disable: function(){            return this.each(function(){                this.disabled = true;            });        },        enable: function(){            return this.each(function(){                this.disabled = false;            });        },        readonly: function(){            return this.each(function(){                this.readonly = true;            });        },        unreadonly: function(){            return this.each(function(){                this.readonly = false;            });        }    });});jQuery.fn.appendDom = function(template){    return this.each(function(){        for (element in template) {            var el = (typeof(template[element].tagName) === 'string') ? document.createElement(template[element].tagName) : document.createTextNode('');            delete template[element].tagName;            for (attrib in template[element]) {                switch (typeof(template[element][attrib])) {                    case 'string':                        if (typeof(el[attrib]) === 'string') {                            el[attrib] = template[element][attrib];                        }                        else {                            el.setAttribute(attrib, template[element][attrib]);                        }                        break;                    case 'function':                        el[attrib] = template[element][attrib];                        break;                    case 'object':                        if (attrib === 'childNodes') {                            $(el).appendDom(template[element][attrib]);                        }                        break;                }            }            this.appendChild(el);        }    });};function resetSubmitCount(responseText, statusText){    submitcount = 0;}function showResponse(responseText, statusText){    $("#oStatus").empty();    $("#oStatus").html('status: ' + statusText + '\n\nresponseText: \n' + responseText);    $("#oStatus").show();    return false;}function openWindow(url, targetW){    window.open(url, targetW, "status=yes,resizable=yes,scrollbars=yes,toolbar=no,menubar=no");    window.focus();}var secureWindow, url;function makeSecureWindow(url){    secureWindow = window.open(url, "secureWindow", "status=yes,resizable=yes,scrollbars=yes,toolbar=no,menubar=no");    secureWindow.focus();}function postSecureWindow(fId, formData){    var formData = (formData == null) ? [] : formData;    formData.push({        name: "BFP",        value: BFP    });    formData.push({        name: "iBES4",        value: iBES4    });    formData.push({        name: "action",        value: "ibes"    });    formData.push({        name: "ibes",        value: "true"    });    formData.push({        name: "fId",        value: fId    });    secureWindow = window.open();    secureWindow.focus();    secureWindow.$.post('.?', formData);}function doPostBackNewWindow(fId, formData){    $("#" + fId).block('<h3>Processing</h3>', {        border: '3px solid #a00'    });    var formData = (formData == null) ? [] : formData;    formData.push({        name: "BFP",        value: BFP    });    formData.push({        name: "iBES4",        value: iBES4    });    formData.push({        name: "action",        value: "ibes"    });    formData.push({        name: "ibes",        value: "true"    });    formData.push({        name: "fId",        value: fId    });        secureWindow = window.open('ibes.light.html', "secureWindow", "status=yes,resizable=yes,scrollbars=yes,toolbar=no,menubar=no");    secureWindow.$.post(".?", formData, unBUI);        //    secureWindow = window.open(url, "secureWindow", "status=yes,resizable=yes,scrollbars=yes,toolbar=no,menubar=no");    //    secureWindow.focus();}function doPostBack(fId, formData){    $("#" + fId).block('<h3>Processing</h3>', {        border: '3px solid #a00'    });    var formData = (formData == null) ? [] : formData;    formData.push({        name: "BFP",        value: BFP    });    formData.push({        name: "iBES4",        value: iBES4    });    formData.push({        name: "action",        value: "ibes"    });    formData.push({        name: "ibes",        value: "true"    });    formData.push({        name: "fId",        value: fId    });    $.post(".?", formData, unBUI);}function doGetBack(fId, formData){    $("#" + fId).block('<h3>Processing</h3>', {        border: '3px solid #a00'    });    var formData = (formData == null) ? [] : formData;    formData.push({        name: "BFP",        value: BFP    });    formData.push({        name: "iBES4",        value: iBES4    });    formData.push({        name: "action",        value: "ibes"    });    formData.push({        name: "ibes",        value: "true"    });    formData.push({        name: "fId",        value: fId    });    $.get("?", formData, unBUI);}function initForms(myResponse){    var fId;    $(".ibesForm", myResponse).each(function(){        fId = $(this).attr('id');        $("#" + fId).ajaxForm({            beforeSubmit: formValidation,            success: unBUI        });        fId = "";    })}jQuery.fn.equalizeCols = function(){    var height = 0;    return this.css("height", "auto").each(function(){        height = Math.max(height, jQuery(this).outerHeight());    }).css("height", height);};function formComet(formData, jqForm, options){    var fId = jqForm.attr('id');    formData.push({        name: "BFP",        value: BFP    });    formData.push({        name: "action",        value: "ibes"    });    formData.push({        name: "ibes",        value: "true"    });    formData.push({        name: "fId",        value: fId    });    formData.push({        name: "last",        value: lastMessage    });    $("#" + fId).validate();    if (!$("#" + fId).valid()) {        alert("You have missed some required fields in RED.\n\nYour form has not been submitted yet.\n\nPlease check the information you provided above.");        return false;    }    else {        if (submitcount == 0) {            $("#" + fId).block('<h3>Processing</h3>', {                border: '3px solid #a00'            });            submitcount++;            return true;        }        else {            alert("This form has already been submitted. Please be patient.");            return false;        }    }    alert("This form has already been submitted. Please be patient.");    return false;}var submitcount = 0;function formValidation(formData, jqForm, options){    var fId = jqForm.attr('id');        //		var formData=(formData==null)?[]:formData;        /*		     formData.push({     name: "BFP",     value: BFP     });          formData.push({     name: "ibes",     value: "true"     });     */    formData.push({        name: "action",        value: "ibes"    });        formData.push({        name: "rType",        value: "formValidation"    });        formData.push({        name: "fId",        value: fId    });    $("#" + fId).validate();    if (!$("#" + fId).valid()) {        alert("You have missed some required fields in RED.\n\nYour form has not been submitted yet.\n\nPlease check the information you provided above.");        return false;    }    else {        if (submitcount == 0) {            $("#" + fId).block('<h3>Processing</h3>', {                border: '3px solid #a00'            });            submitcount++;            return true;        }        else {            alert("This form has already been submitted. Please be patient.");            return false;        }    }    alert("This form has already been submitted. Please be patient.");    return false;}var lastMessage = '';function unBUI(responseText, statusText){    submitcount = 0;    var fIdUnblock = $('ibes', responseText).attr('fId');    lastMessage = $('ibes', responseText).attr('lastMessage');        $("#" + fIdUnblock).unblock();}function ajax_pmv_log(pmv_urlPmv, pmv_site, pmv_pname, pmv_vars){    var pmv_urlCur = getUrl;    var pmv_pos = pmv_urlCur.indexOf("//");    if (pmv_pos > 0) {        pmv_urlCur = pmv_urlCur.substr(pmv_pos);    }    var pmv_src = pmv_getUrlStat(pmv_urlPmv, pmv_site, pmv_urlCur, pmv_pname, "", pmv_vars);    $("#oStatus").load(pmv_src);}/* > This works though: $('head')[0].appendChild($('<script type="text/javascript" src="what.js"></script>')[0]); * This function checks if the given script already exists in the * document head section. It uses the following two rules: * * External scripts are checked against their 'src' attribute. * Inline scripts are checked against their 'id' attribute. * * @param script is a <script> DOM element. */function canAddScript(script){    var id = script.getAttribute("id");    if (id) {        // Check if another script exists with the same id attribute        if ($('#' + id).length) {            log('script with id: "' + id + '" already exists');            return false;        }    }    var src = script.getAttribute("src");    if (src) {        // Check if another script exists with the same src attribute        if ($('script[src=' + src + ']').length) {            log('script with src: "' + src + '" already exists');            return false;        }    }    return true;}/* //BOOTING INTO JQUERY. //USEFUL FOR A CRM HACK var script = document.createElement('script'); script.language = 'javascript'; script.src = '/ISV/scripts/jquery-1.2.3.js'; script.onreadystatechange = function() { if (event.srcElement.readyState == "complete" || event.srcElement.readyState == "loaded") jQueryIsReady(); }; document.getElementsByTagName('head')[0].appendChild(script); function jQueryIsReady() { // jQuery is loaded and initialised // custom code should be inserted here } */