﻿var t_window=false;
var t_window_layer=false;
var ref=false;
function ShowWindow(AnchorObj,url,width,height,contentDivId,opt)
{
    var top=(opt=="-")?($(AnchorObj).offset().top-400):($(AnchorObj).offset().top+50);
    if(!t_window_layer)	
    {
	    t_window_layer = document.createElement('DIV');
	    $(t_window_layer).css({
	                            backgroundColor:"#000000",
	                            position:"absolute",
	                            left:"0px",
	                            top:"0px",
	                            width:$(document).width()+"px",
	                            height:$(document).height()+"px",
	                            display:"block",
	                            zIndex:"10000000"	                            
	                         }).attr("id","div_t_window_layer").fadeTo("slow", 0.33);
	    $(document.body).append(t_window_layer);
    }
    if(!t_window)
    {
       
	    t_window = document.createElement('DIV');
	    $(t_window).css({
	                        backgroundColor:"#ffffff",
	                        position:"absolute",
	                        zIndex:"10000001",
	                        display:"block",
	                        left:(($(document.body).width()/2)-(width/2))+"px",
	                        width:width+"px"
//	                        height:height+"px"
	                   }).attr("id","div_t_window");
	    $(document.body).append(t_window);
    }
    $("#div_t_window").css({top:top+"px",display:"block"}).html($("#"+contentDivId).html());
    if($("#"+contentDivId))
    {
        $("#div_t_window").html($("#"+contentDivId).html());
        $("#div_t_window img[id*='imgClose']").css({cursor:"pointer"}).click(function(){
            HideWindow(url);
        });
    }
    $("#div_t_window_layer").css("display","block");
    ref=window.setTimeout("HideWindow('"+url+"')",5000);
    return false;
}

function HideWindow(url)
{
    $("#div_t_window").css("display","none");
    $("#div_t_window_layer").css("display","none");
    window.open(url,"_blank");
    if(ref) window.clearInterval(ref);
}
