﻿function includejs(filename) {
    var body = document.getElementsByTagName('head').item(0);
    script = document.createElement('script');
    script.src = filename;
    script.type = 'text/javascript';
    body.appendChild(script)
}
function includecss(filename) {
    var body = document.getElementsByTagName('head').item(0);
    link = document.createElement('link');
    link.href = filename;
    link.type = 'text/css';
    link.rel = 'stylesheet';
    body.appendChild(link)
}
function IncludeJqueryHeaderScriptAndCSS(Path,InCludeMainJS) {
    includecss(Path + "/themes/cupertino/jquery.ui.all.css");
    if(InCludeMainJS)
        includejs(Path + "/jquery-1.4.2.js");
    
    includejs(Path + "/ui/jquery.effects.core.min.js");
    includejs(Path + "/ui/jquery.ui.core.min.js");
    includejs(Path + "/ui/jquery.ui.widget.min.js");
    includejs(Path + "/ui/jquery.ui.mouse.min.js");
    includejs(Path + "/ui/jquery.ui.resizable.min.js");
    includejs(Path + "/ui/jquery.ui.draggable.min.js");
    includejs(Path + "/ui/jquery.ui.position.min.js");
    includejs(Path + "/ui/jquery.ui.dialog.min.js");
    includejs(Path + "/ui/jquery.effects.blind.min.js");
}
function RegisterModal(id, width, height,OnClose) {
    var JSAdd;
    head = document.getElementsByTagName('HEAD')[0];
    JSAdd = document.createElement('SCRIPT');
    JSAdd.type = 'text/javascript';
    JSAdd.text = "$(function() {" +
		"$('" + id + "').dialog({" +
            "autoOpen: false," +
			"height:" + height + "," +
			"width:" + width + "," +
			"modal: true," +
			"show: 'blind'," +
			"hide: 'blind'" +
		"});" +
	    "});"
    if (OnClose != null) {
        JSAdd.text += "$('" + id + "').bind('dialogbeforeclose', eval('" + OnClose + "'))";
    }
    head.appendChild(JSAdd);
}
function OpenModal(id) {
    jQuery(id).dialog('open');return false;
}
function CloseModal(id) {
    jQuery(id).dialog('close');return false;
}
