/*
 * FourthMedia Show Dialog base on BlcokUI
 * Version 1.0 (1 Dec 2008)
 * @requires jQuery v1.2.3 , JQuery BlcokUI 2.10 or later
 * Created By Brand HU
 */
var thecontainer // Global Object
var refrehfunction
function WindowSelfRefresh(){
    window.location = window.location ;
}
function autorefresh(ID){
    if (typeof(refrehfunction) != "undefined" ){
            if(typeof(ID) != "undefined" && ID != 0 ){
                eval(refrehfunction+"("+ID+")");
            }
            else
            {eval(refrehfunction+"()");}
        }
    else{
    alert("function not found")
    }
}
function closedialog(){
    jQuery.unblockUI({
        onUnblock: function(){ jQuery("#dialogcontent").html("");} 
    });
//    jQuery.unblockUI({ 
//       onUnblock: function(){ jQuery("#dialogcontent").html("");document.body.removeChild(thecontainer) } 
//    }); 

}

function showdialog(title,url,w,h,createContainerfunction){
    if (!document.getElementById("thecontainer")){
        if (typeof(createContainerfunction) != "undefined" && createContainerfunction != "" ){
            eval(createContainerfunction + "();")
        }
        else{
            createContainer();
        }
	    
	}
	
	jQuery.blockUI({ message: jQuery('#FM_BlockUI_Dialog'),css: { 
	    top: '1%',
	    width: '98%',
        border: 'none',
        height: '98%',    
	    left: '1%',
	    backgroundColor:'transparent',
	    cursor: 'point' 
        },
	overlayCSS:  {  
        backgroundColor:'#000',  
        opacity:        '0.2'  
    	} ,
	fadeOut:  300 }); 
	jQuery("#dialogcontent").html("<iframe class='ui-iframe' width='"+w+"' height='"+h+"' src='" + url + "' style='border:0px;'  frameborder='0' SCROLLING=no></iframe>")

	jQuery("#dialogtitle").html(title)
    
}

function createContainer(){ // Create Container MTS Style
thecontainer =  document.createElement("div")
thecontainer.id = "thecontainer"
thecontainer.style.display = "none"
thecontainer.innerHTML =
"<div id='FM_BlockUI_Dialog'><table width='100%' height='100%' cellpadding='0' cellspacing='0' border='0'><tr><td valign='middle' align='center'>" +
"<table cellpadding='0' cellspacing='0' border='0' height='100'>"+
"<tr><td class='tl' height='9' width='9'></td><td class='tb' height='9'></td>"+
"<td class='tr' height='9' width='9'></td></tr>"+
"<tr><td class='lb' valign='top'><div class='lbt'> </div></td><td class='inner' valign='top'>"+
"<table cellpadding='0' cellspacing='0' border='0' width='100%' class='titlebar'><tr><td align='left'>&nbsp;&nbsp;<span id='dialogtitle'></span></td>"+
"<td align='right' nowrap='nowrap' valign='top'><a href='javascript:void(0);' class='closebutton' onclick='closedialog()'><img src='images/popup_btnClose.gif' border='0' /></a></td></tr></table>"+
"<div id='dialogcontent'></div>"+
"</td><td class='rb' valign='top'><div class='rbt'> </div></td></tr>"+
"<tr><td class='bl' width='9' height='9'></td><td class='b'></td>"+
"<td class='br' width='9' height='9'></td></tr></table></td></tr></table></div>"
document.body.appendChild(thecontainer)
}

function createContainerBTF(){ // Create Container BTF style
thecontainer =  document.createElement("div")
thecontainer.id = "thecontainer"
thecontainer.style.display = "none"
thecontainer.innerHTML =
"<div id='FM_BlockUI_Dialog'><table width='100%' height='100%' cellpadding='0' cellspacing='0' border='0'><tr><td valign='middle' align='center'>" +
"<table cellpadding='0' cellspacing='0' border='0' height='100'>"+
"<tr><td class='td1_1'></td><td class='td1_2' ><div class='titlebar'><a href='javascript:void(0);' class='dialog_closebutton' onclick='closedialog()'></a><span id='dialogtitle'></span></div></td>"+
"<td class='td1_3'></td></tr>"+
"<tr><td class='td2_1' ></td><td class='inner' valign='top'>"+
"<div id='dialogcontent'></div>"+
"</td><td class='td2_2' ></td></tr>"+
"<tr><td class='td3_1' ></td><td class='td3_2'></td>"+
"<td class='td3_3' ></td></tr></table></td></tr></table></div>"
document.body.appendChild(thecontainer)
}

/*-----------Auto start token holder------------------------------*/
function StartEditToolbar(){
    var thetoolbars = jQuery(".token_holder")
    if (thetoolbars){
        thetoolbars.hover(
            function(){
                jQuery(this).find(".token_holder_toolbar").css({'display':'block'})
                 jQuery(this).css({'border':'1px dashed #3300ff'})
             
            },
            function(){
               jQuery(this).find(".token_holder_toolbar").css({'display':'none'})
                   jQuery(this).css({'border':'1px dashed #cccccc'})
              
                
            }
        )
    }
}
jQuery(function(){
try{
      StartEditToolbar();
}
catch(e){
}
  
});
