function isString(str){ return typeof(str)=='string'&&isNaN(str); }
function isElement(e){ return e&&typeof(e)=='object'&&e.nodeType==1&&e.constructor==document.createElement(e.nodeName).constructor; }

function popup_ajax(file,width,onComplete){
 popup_html('<div style="text-align:center;padding:50px 0px 80px;"><img src="/gfx/loading.gif" /></div>',width);
 jQuery('#popupmsg').load(file,'',onComplete);
 //jQuery.get(file,data,function(data){ popup_html(data, width); });
 }

function popup_html(content,width){
 var width = (typeof(width)=='undefined' ? 600 : width );
 var innerhtml = '';
 
 if(isString(content)){ innerhtml = content; }
 else if(isElement(content)){ innerhtml = content.innerHTML; }
 
 //ONLY ONE POPUP ALLOWED AT A TIME
 if(document.getElementById('popup')){ popup_close(); }
 
 html = ''
 +'<div id="popup"><div id="popupbgnd" onclick="popup_close();"></div><table><tr><td>'
 +'<div id="popupmsg" style="width:'+width+'px;">'
// +'<div id="popupclose" onclick="popup_close();"></div>'
 +innerhtml
 +'</div></td></tr></table></div>';
 jQuery(document.body).append(html);
 
 jQuery('object').css({'visibility':'hidden'});
 
 if(jQuery.browser.msie && jQuery.browser.version.substr(0,1)<7){ jQuery(window).bind('scroll',ie6_adjustpopupposition); }
 }

function popup_close(){
 var e = document.getElementById('popup');
 e.parentNode.removeChild(e);
 jQuery('object').css({'visibility':'visible'});
 if(jQuery.browser.msie && jQuery.browser.version.substr(0,1)<7){ jQuery(window).unbind('scroll',ie6_adjustpopupposition); }
 }

function ie6_adjustpopupposition(event){
 if(!document.getElementById('popup')){ jQuery(window).unbind('scroll',ie6_adjustpopupposition); }
 else{ document.getElementById('popup').style.top = document.body.parentElement.scrollTop; }
 }


