﻿//Input type class inserter.
window.onload = function() { var coll = document.getElementsByTagName('input'); for (var i = 0; i < coll.length; i++) { if (coll[i].type) { coll[i].className += ' ' + coll[i].type + ' '; } } }

// Contains General Java Script Functions for Venue Wise Pages.
function EditorAttachTo(controlId) { WYSIWYG.setSettings(controlId); WYSIWYG_Core.includeCSS(WYSIWYG.config[controlId].CSSFile);WYSIWYG._generate(controlId); return false; } 
function EditorLoadValue(controlId, value){ return false; }

function ShowViewStateSize() { var buf = document.forms[0]["__VIEWSTATE"].value; alert("View state is " + buf.length + " bytes"); }

//The follwing two functions ensures that only one node in treeView with checkboxes can be selected.
function client_OnTreeNodeChecked_AllowOnlySingleCheck(event) { var TreeNode = event.srcElement || event.target ; if (TreeNode.tagName == "INPUT" && TreeNode.type == "checkbox") { if(TreeNode.checked){ client_OnTreeNodeChecked_AllowOnlySingleCheck_UnCheckOther(TreeNode.id); } } }

function client_OnTreeNodeChecked_AllowOnlySingleCheck_UnCheckOther(id) { var elements = document.getElementsByTagName('input'); /* loop through all input elements in form */ for(var i = 0; i < elements.length; i++){ if(elements.item(i).type == "checkbox"){ if(elements.item(i).id!=id){ elements.item(i).checked=false; } } } }

//Function displays a FileDownload PopUpDialog.
function AttemptFileDownloadDialog(title, extention, date, size, mime, url) { $("<div title=\"File Download\">" + "<table>" + "<tr><th>Title:</th><td>" + title + "</td></tr>" + "<tr><th>File extention:</th><td>" + extention + "</td></tr>" + "<tr><th>Upload date:</th><td>" + date + "</td></tr>" + "<tr><th>Size:</th><td>" + size + "</td></tr>" + "<tr><th>Mime type:</th><td>" + mime + "</td></tr>" + "</table>" + "</div>").dialog({ modal: true, buttons: { "Cancel": function() { $(this).dialog("close"); }, "Start download": function() { window.open(url, "_blank"); $(this).dialog("close"); } } }); return false; }

//Inserts text into the css editing area
function cssInsertText(text) {
    if (document.selection) {
        $("*[id$='txt']").focus();
        sel = document.selection.createRange();
        sel.text = text;
    }
    //MOZILLA/NETSCAPE support
    else if ($("*[id$='txt']").selectionStart || $("*[id$='txt']").selectionStart == '0') {
    var startPos = $("*[id$='txt']").selectionStart;
    var endPos = $("*[id$='txt']").selectionEnd;
    $("*[id$='txt']").value = $("*[id$='txt']").value.substring(0, startPos) + text + $("*[id$='txt']").value.substring(endPos, $("*[id$='txt']").value.length);
    }
    else {
        ctl00$ContentPlaceHolder2$txt.value += text;
    }
}

//Displays a preview for images.
function cssPreviewImage(url, title){
    $("[id$='imagePreview']").attr("src", url);
    $("[id$='imagePreviewLink']").attr("href", url);
}

//No opperations procedure
function NOP() { }
