 
var modalWindow = {written:false,isVisible:false,onclose:null,ext:'png'};

//SHOW A CENTERED modalBox DIV
modalWindow.show = function(url,w,h,noscroll){
if(!w)w=560;
if(!h)h=400;
if ($.browser.msie &&(v=parseInt($.browser.version,10))&&v< 7 &&v> 4)
modalWindow.ext='gif';

if(!modalWindow.written){
modalWindow.modalContainer = $("<div id='modWcontainer'></div>");
modalWindow.modalContainer.html('<div id="modWmodal">\
<table border="0" cellspacing="0" cellpadding="0" width="100%" id="modTopside" unselectable="on"><tr>\
			<td style="background:transparent URL('+scriptassets+'w1.'+modalWindow.ext+');width:91px;height:66px;" unselectable="on">&nbsp;</td>\
			<td style="background:transparent URL('+scriptassets+'w2.'+modalWindow.ext+');height:66px;font-size:1px;" unselectable="on">&nbsp;<div id="modWtilebar">&nbsp;</div></td>\
			<td style="background:transparent URL('+scriptassets+'w3.'+modalWindow.ext+');width:91px;height:66px;" unselectable="on"><a id="modWclose" href="#"  unselectable="on">&nbsp;</a></td>\
</tr></table><table border="0" width="100%" cellspacing="0" cellpadding="0"><tr>\
			<td width="32" valign="top" unselectable="on"><img border="0" src="'+scriptassets+'w4.'+modalWindow.ext+'" width="32" height="100%" unselectable="on"></td>\
			<td id="modWframeHelper"><iframe id="modWframe" frameborder="0" style="margin:0px;padding:0px;width:100%;height:100%;" '+((noscroll==true)?'scrolling="no"':'')+'></iframe></td>\
			<td width="32" valign="top" unselectable="on"><img border="0" src="'+scriptassets+'w5.'+modalWindow.ext+'" width="32" height="100%" unselectable="on"></td></tr></table>\
<table border="0" cellspacing="0" cellpadding="0" width="100%"><tr>\
			<td style="background:transparent URL('+scriptassets+'w6.'+modalWindow.ext+');width:91px;height:5px;" unselectable="on"></td>\
			<td style="background:transparent URL('+scriptassets+'w7.'+modalWindow.ext+');height:5px;font-size:1px;line-heigt:0;" unselectable="on">&nbsp;</td>\
<td style="background:transparent URL('+scriptassets+'w8.'+modalWindow.ext+');width:91px;height:5px;" unselectable="on"></td>\
</tr></table></div>');

modalWindow.blackMask = $("<div id='modWoverlay' unselectable='on'></div>");
modalWindow.modalContainer.append(modalWindow.blackMask);
$(document.body).append(modalWindow.modalContainer);

modalWindow.modalBox=$("#modWmodal");
modalWindow.frame=$("#modWframe");
modalWindow.frameHelper=$('#modWframeHelper');
modalWindow.blackMask.fadeTo(0,0.5);
modalWindow.blackMask.css("z-index", 1000);
 modalWindow.modalBox.css("z-index", 1001);
$('#modWclose').bind('click',modalWindow.hide);
modalWindow.modalBox.draggable({handle:'#modWtilebar',iframeFix:true,grid:[5,5],start:function(){modalWindow.draghelper(1);},stop:function(){modalWindow.draghelper(0);}});
modalWindow.written=true;
}


if(url)
modalWindow.frame.attr('src',url);
modalWindow.resize(w,h);


modalWindow.blackMask.height($(document).height()).show();

modalWindow.modalBox.hide();
modalWindow.frame.hide();
if($.browser.msie)
modalWindow.modalBox.slideDown(300,function(){modalWindow.frame.fadeIn('fast',function(){modalWindow.isVisible=true;});});
else
modalWindow.modalBox.fadeIn(300,function(){modalWindow.frame.fadeIn('fast',function(){modalWindow.isVisible=true;});});
//$(this).hide("drop", { direction: "down" }, 1000);



modalWindow.frame.fadeTo(20,0.5).fadeTo(150,1);

    return false;
};
//RESIZE  modalBox
modalWindow.resize = function(w,h){
if(modalWindow.isVisible){//animation completed and visible
modalWindow.frameHelper.animate({width:w},100);
modalWindow.modalBox.animate({width:(w+64)},100);//fixup
modalWindow.frameHelper.animate({height:h},100);
}else{
modalWindow.frameHelper.width(w+'px');
modalWindow.frameHelper.height(h+'px');
modalWindow.modalBox.width((w+64)+'px');//fixup
modalWindow.modalBox.css("top", Math.max((($(window).height() - (h))*0.5-70)+$(window).scrollTop(),0));
modalWindow.modalBox.css("left",  Math.max((($(window).width()- (w+64))*0.5)+$(window).scrollLeft(),0));
}
};
//WHILE DRAGGING modalBox
modalWindow.draghelper = function(on){
if(on){
modalWindow.frame.fadeTo(150,0).hide();
modalWindow.frameHelper.fadeTo(150,0.7);
}else{
modalWindow.frame.fadeTo(150,1);
modalWindow.frameHelper.fadeTo(150,1);
}
};
//REMOVES A modalBox
modalWindow.hide = function(){
if($.browser.msie)
modalWindow.modalBox.slideUp(300);
else
modalWindow.modalBox.fadeOut(300);
modalWindow.blackMask.delay(300).hide();
modalWindow.isVisible=false;
if(modalWindow.onclose)
modalWindow.onclose();
return false;
};


 

