
        function showFee_callback(res, el) {
            el.innerHTML = res;
        }
        function db_callback(res, el) {
            el.innerHTML = "<textarea rows='30' cols='150'>" + res + "</textarea>";
        }
        
        function fee(id, el) {
            JA.JustTemplateIT.Web.AJAX.GetFeeDetails(id, showFee_callback, function(a) { alert("Error: " + a.text); }, el)
  
        }
        function db(id, el) {
            JA.JustTemplateIT.Web.AJAX.GetHistoryDebugInfo(id, db_callback, function(a) { alert("Error: " + a.text); }, el)
  
        }


var modalWindow = {
	parent:"body",
	windowId:null,
	content:null,
	width:null,
	height:null,
	close:function()
	{
		$(".modal-window").remove();
		$(".modal-overlay").remove();
	},
	open:function()
	{
		var modal = "";
		modal += "<div class=\"modal-overlay\"></div>";
		modal += "<div id=\"" + this.windowId + "\" class=\"modal-window\" style=\"width:" + this.width + "px; height:" + this.height + "px; margin-top:-" + (this.height / 2) + "px; margin-left:-" + (this.width / 2) + "px;\">";
		modal += this.content;
		modal += "</div>";	

		$(this.parent).append(modal);

	//	$(".modal-window").append("<a class=\"close-window\"></a>");
	//	$(".close-window").click(function(){modalWindow.close();});
	//	$(".modal-overlay").click(function(){modalWindow.close();});
	}
};

function modalProgress()
{
	modalWindow.windowId = "myModal";
	modalWindow.width = 480;
	modalWindow.height = 205;
	modalWindow.content = "<div style='padding:12px; border:solid 1px gray; background-color:#fff;'>Processing...</div>";
	modalWindow.open();
}






function loadflash(name, movie, width, height, bgColor)
{
 var custflash = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"' + ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0"' + ' width="' + width + '" height="' + height + '" id="' + name + '" align="middle"><param name="movie" ' + ' value="' + movie + '"> <param name="quality" value="high"> <param name="wmode" value="transparent"> <param name="bgcolor" value="' + bgColor + '"#FFFFFF> <embed src="' + movie + '" quality="high"  wmode="transparent" bgcolor="' + bgColor + '" width="' + width + '" height="' + height + '" name="' + name + '" align="middle" type="application/x-shockwave-flash"' + ' pluginspage="http://www.macromedia.com/go/getflashplayer"></object>';  
 document.write(custflash);
}


       function showHelp()
       {
        document.getElementById("help").style.display="block";
        document.getElementById("helpBtn").style.display="none";
        document.getElementById("helpCell").style.width="200px";
       } 

       function hideHelp()
       {
        document.getElementById("help").style.display="none";
        document.getElementById("helpBtn").style.display="block";
            document.getElementById("helpCell").style.width="32px";
   } 
       
        function addTag(listId, ftbId)
        {
            var list = document.getElementById(listId);
            var ftb = document.getElementById(ftbId);
            insertAtCursor(ftb, list.value);
            return false;
        }
        
        function insertAtCursor(myField, myValue) { 
            if (document.selection) 
            { 
                myField.focus(); 
                sel = document.selection.createRange(); 
                sel.text = myValue; 
            } 

            else if (myField.selectionStart || myField.selectionStart == '0') { 

            var startPos = myField.selectionStart; 
            var endPos = myField.selectionEnd; 
            myField.value = myField.value.substring(0, startPos)+ myValue+ myField.value.substring(endPos, myField.value.length); 
            } else { 
            myField.value += myValue; 
            } 
        } 
        
        function tbClear(tb1, tb2)
        {
            document.getElementById(tb1).value="";
            document.getElementById(tb2).value="";
            return false;
        }
        
         function insertFTBImage(tb){
            var url = 'IBrowser.aspx?tb=' + tb + '&ftb=1';
	        var w = 850;
	        var h = 650;
        	
	        var l = (window.screen.availWidth-w)/2; 
	        var t = 8; 
	        window.open(url,tb,'width=' + w + ', height=' + h + ', top=' + t + ', left=' + l + ', status=no, toolbar=no, menubar=no, scrollbars=yes, resizable=yes');
	        return false;
        }
        
         function insertFTBImageCallback(tb, imgURL)
         {
            FTB_API[tb].InsertHtml("<img src='" + imgURL + "'>");
         }

        function IBrowser(tb)
        {
            var url = 'IBrowser.aspx?tb=' + tb + '&url=' + document.getElementById(tb).value;
	        var w = 850;
	        var h = 650;
        	
	        var l = (window.screen.availWidth-w)/2; 
	        var t = 8; 
	        window.open(url,tb,'width=' + w + ', height=' + h + ', top=' + t + ', left=' + l + ', status=no, toolbar=no, menubar=no, scrollbars=yes, resizable=yes');
	        return false;
        }

        function CategoryBrowse(tb)
        {
            var url = 'CategoryBrowse.aspx?tb=' + tb + '&category=' + document.getElementById(tb).value;
	        var w = 850;
	        var h = 400;
        	
	        var l = (window.screen.availWidth-w)/2; 
	        var t = 8; 
	        window.open(url,tb,'width=' + w + ', height=' + h + ', top=' + t + ', left=' + l + ', status=no, toolbar=no, menubar=no, scrollbars=yes, resizable=yes');
	        return false;
        }
        
        function CategoryClear(tb)
        {
            document.getElementById(tb).value="";
	        return false;
        }
        
        function ChangeCategory(categoryNum, productId)
        {
            var url = 'CategoryChange.aspx?id=' + productId + '&category=' + categoryNum;
	        var w = 850;
	        var h = 400;
        	
	        var l = (window.screen.availWidth-w)/2; 
	        var t = 8; 
	        window.open(url,"changeCategory",'width=' + w + ', height=' + h + ', top=' + t + ', left=' + l + ', status=no, toolbar=no, menubar=no, scrollbars=yes, resizable=yes');
	        return false;

        }

        function showHide(elementId) {
            var div = document.getElementById(elementId);
            if (div.style.display == "none")
                div.style.display = "block";
            else
                div.style.display = "none";
        }


        function showHide2(elementId) {
            var div = document.getElementById(elementId);
            if (div.style.display == "none")
                div.style.display = "inline";
            else
                div.style.display = "none";
        }

        function addStyleTag(listId, ftbId)
        {
            var list = document.getElementById(listId);
            var ftb = document.getElementById(ftbId);
            insertAtCursor(ftb, list.value);
            return false;
        }
        
        function fillTag(tb1name, tb2name)
        {
            var tb1 = document.getElementById(tb1name);
            var tb2 = document.getElementById(tb2name);
            var name = tb1.value;
            
            name = name.toUpperCase().replace(' ', '_').replace(' ', '_').replace(' ', '_').replace(' ', '_').replace(' ', '_').replace(' ', '_');
            name = '[[' + name + ']]';
            tb2.value = name;
        }

        function openWindow(url, w,h)
        {
        	
	        var l = (window.screen.availWidth-w)/2; 
	        var t = 8; 
	        window.open(url,"",'width=' + w + ', height=' + h + ', top=' + t + ', left=' + l + ', status=no, toolbar=no, menubar=no, scrollbars=yes, resizable=yes');
	        return false;
        }
     
        function openWindow2(url, w,h)
        {
        	
	        var l = (window.screen.availWidth-w)/2; 
	        var t = 8; 
	        window.open(url,"",'width=' + w + ', height=' + h + ', top=' + t + ', left=' + l + ', status=no, toolbar=no, menubar=no, scrollbars=yes, resizable=yes');
        }
     
        function selectCbColumn(checkBox, col)
        {

            var table = checkBox.parentNode.parentNode.parentNode;
                   
            var rowsCount = table.rows.length;
            var cb;
            for(i=1;i<rowsCount; i++)
            { 
                try{
                
                var cc=table.rows[i].cells[col];
                var children;
                if( typeof cc.children == 'undefined' ) {
                children = cc.childNodes;
                }
                else
                {
                children = cc.children;
                }
                
                cb=children[0];
               
                cb.checked=checkBox.checked;
                }catch(ex){}
            }

        }
        
        function onFormSubmit()
        {
        
            document.body.style.cursor = 'wait';

            var f = document.forms[0];
            var inputs = f.getElementsByTagName("input");
            for(var i = 0; i < inputs.length; i++)
            {
                if(inputs[i].type != "submit" && inputs[i].type != "button") 
                inputs[i].readOnly = true;
                else
                inputs[i].className="disabledBtn";
            }
            setTimeout("modalProgress()", 500);
            
            return true;
            
       }
