

function showModal() {

    var modalWidth=document.getElementById("dv_Modal").style.width;
    modalWidth = modalWidth.replace("px","");

    var myWidth = getScreenWidth();

    var margin = parseInt((myWidth-modalWidth)/2)
    document.getElementById("dv_Modal").style.marginLeft=margin+"px";
   
   // document.body.style.overflow="hidden";

    
    document.getElementById("fade").style.display='block';
    
    document.getElementById("dv_Modal").style.display='block';
    //Effect.Appear('dv_Modal',{ duration: 1, from:0.0, to: 1.0  });
}

function hideModalToURL(showID,eventID) {

  //  document.body.style.overflow="auto";

   window.location.href="tickets.aspx?showID=" +showID+"&eventID=" +eventID;
   //Effect.Fade("dv_Modal",{ duration: 0.3 });  
   //setTimeout("resetWindow()",200);
   //setTimeout("postHide_Scroll();",300);
}
function hideModal() {

  //  document.body.style.overflow="auto";

   window.location.href=window.location.href;
   //Effect.Fade("dv_Modal",{ duration: 0.3 });  
   //setTimeout("resetWindow()",200);
   //setTimeout("postHide_Scroll();",300);
}
function resetWindow() {
    document.getElementById('fade').style.display='none';
    document.getElementById('ifr_Modal').src = 'about:blank';
}
var myScreenPosY=0;

function setModalDimensions(height,width) {
    document.getElementById("dv_Modal").style.width  = width+"px";
    document.getElementById("dv_Modal").style.height = height+"px";
    document.getElementById("ifr_Modal").style.width = width+"px";
    document.getElementById("ifr_Modal").style.height= height+"px";
}

function preShow_Scroll() {
/*
    myScreenPosY = getPositionY();
    try {
    Effect.ScrollTo("fade",0,0);
    }catch (err){
    window.moveTo(0,0);
    }
    */
    setTimeout("showModal()",1000);
}
function postHide_Scroll() {
scrollDown();
   // Effect.ScrollTo('fade', { duration:0.5, offset:myScreenPosY });
}
function openAuthentication() {
    var width = 330;
    var height = 330;
    setModalDimensions(height, width);

    document.getElementById("ifr_Modal").src="/calendar/tixModal.aspx";
    preShow_Scroll();
}
function openWaitlistModal(showID, eventID) {
    var width = 330;
    var height = 330;
    setModalDimensions(height, width);

    document.getElementById("ifr_Modal").src = "/calendar/tixModal.aspx?showID=" + showID + "&eventID=" + eventID;
    preShow_Scroll();
}

function openTicketsModal(showID,eventID) {
    var width = 360;
    var height = 360;
    setModalDimensions(height, width);

    document.getElementById("ifr_Modal").src="/calendar/tixModal.aspx?showID=" + showID + "&eventID=" + eventID;
    preShow_Scroll();
}

function fireFBConnectModal(hash) {
    var width = 360;
    var height = 360;
    setModalDimensions(height, width);

    jQuery("#ifr_Modal").attr("src", "/myProfile/fbconnect.aspx?h="+hash);
    preShow_Scroll();
}
function getScreenWidth() {

    var myWidth = 0, myHeight = 0;
    if( typeof( window.innerWidth ) == 'number' ) {
        //Non-IE
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
    } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
    }
    return myWidth;
}
function getPositionY() {
    var top = document.body.scrollTop
          || window.pageYOffset 
          || (document.body.parentElement
              ? document.body.parentElement.scrollTop
              : 0
              );
    return top;
}
var scrolldelay=null;
function scrollDown() {
    
    distance = myScreenPosY;
    duration = 26;
    perStep = parseFloat(distance/duration);

    if (getPositionY() >=myScreenPosY) {
    
        clearTimeout(scrolldelay);
        return;
    }
   
    window.scrollBy(0,perStep); // horizontal and vertical scroll increments
	scrolldelay = setTimeout('scrollDown()',duration)
}
