﻿function LoadProductImageWindow(Url,Height,Width)
{
    newwindow=window.open(Url,'ProductPicture','height=' + Height + ',width=' + Width + ',top=200,left=400,resizable=1,scrollbars=1');
}

function fieldInfo(url) 
{
    newwindow=window.open(url,'name','height=200,width=300,top=200,left=400,resizable=1,scrollbars=1');
}

function subinfo(url) 
{
    newwindow=window.open(url,'name','height=200,width=300,top=200,left=400');
}

function SessionInfo(ID) 
{
    newwindow=window.open('/App/frmFieldInfo.aspx?SessionID=' + ID,'sessioninfo','height=200,width=300,top=200,left=400,resizable=1');
}

function SessionSubInfo(ID) 
{
    newwindow=window.open('/App/frmFieldInfo.aspx?SessionSubID=' + ID,'sessioninfo','height=200,width=300,top=200,left=400,resizable=1');
}

function popUp(URL) 
{
    newwindow = window.open(URL, 'AdminWindow','toolbar=1,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=950,height=600,left = 200,top = 262');
}

function setDisabledState(button, state)
{
    button.disabled = state;
}

var lastColorUsed;
function highlightBackColor(table, highlight)
{
    if (table.style.backgroundColor == "#FFCC66" )
    {
        table.style.backgroundColor = table.style.backgroundColor;
    }
    else
    {
          if (highlight)
          {
            lastColorUsed = table.style.backgroundColor;
            table.style.backgroundColor = '#EEEEEE';
          }
          else
          {
            table.style.backgroundColor = lastColorUsed;
          }
     }
}

function grayOut(vis, options)    
{   
    var optionsoptions = options || {};     
    var zindex = options.zindex || 50;    
    var opacity = options.opacity || 70;   
    var opaque = (opacity / 100);    
    var bgcolor = options.bgcolor || '#000000';    
    var dark=document.getElementById('darkenScreenObject');   
    if (!dark)    
    {   
         // The dark layer doesn't exist, it's never been created.  So we'll     
         // create it here and apply some basic styles.      
         var tbody = document.getElementsByTagName("body")[0];   
         var tnode = document.createElement('div');              
         tnode.style.position='absolute';   
         tnode.style.top='0px';   
         tnode.style.left='0px';      
         tnode.style.overflow='hidden';   
         tnode.style.display='none';   
         tnode.id='darkenScreenObject';   
         tbody.appendChild(tnode);                               
         dark=document.getElementById('darkenScreenObject');     
    }     
    if (vis)   
    {    
        var pageWidth='100%';    
        var pageHeight='100%';    
        dark.style.opacity=opaque;    
        dark.style.MozOpacity=opaque;          
        dark.style.filter='alpha(opacity='+opacity+')';    
        dark.style.zIndex=zindex;   
        dark.style.backgroundColor=bgcolor;    
        dark.style.width= pageWidth;     
        dark.style.height= pageHeight;    
        dark.style.display='block';     
    }   
    else   
    {      
        dark.style.display='none';    
    }   
}   

function dteCommence_CalendarRenderDay_OLS(oCalendar, oDay, oEvent){
    //Disable Days less than today.
    var pdate = new Date();
    pdate.setFullYear(oDay.year,oDay.month - 1, oDay.day);
    var now = new Date();

    if( pdate < now || pdate < oCalendar.MinDate || pdate > oCalendar.MaxDate ){
        oDay.element.disabled = true;
        oDay.element.style.cursor = "not-allowed";
        oDay.element.style.textDecoration = "line-through";
        oDay.element.title = "Tickets are not available for this date";
    }
    else {
        oDay.element.disabled = false;
        oDay.element.style.cursor = "hand";
        oDay.element.style.fontWeight = "bold";
        oDay.element.style.textDecoration = "none";
        oDay.element.title = "Your ticket will commence on this date";
    }
}

function dteCommence_CalendarRenderDay_DDS(oCalendar, oDay, oEvent){
    //Disable Days less than today.
    var pdate = new Date();
    pdate.setFullYear(oDay.year,oDay.month - 1, oDay.day);
    var now = new Date();

    if( pdate < now || pdate < oCalendar.MinDate || pdate > oCalendar.MaxDate || oDay.day == 29 || oDay.day == 30 || oDay.day == 31 ){
        oDay.element.disabled = true;
        oDay.element.style.cursor = "not-allowed";
        oDay.element.style.textDecoration = "line-through";
        oDay.element.title = "Tickets are not available for this date";
    }
    else {
        oDay.element.disabled = false;
        oDay.element.style.cursor = "hand";
        oDay.element.style.fontWeight = "bold";
        oDay.element.style.textDecoration = "none";
        oDay.element.title = "Your ticket will commence on this date";
    }
}

function dteCommence_CalendarRenderDay_TermPlus(oCalendar, oDay, oEvent){
    //Disable Days less than today.
    var pdate = new Date();
    pdate.setFullYear(oDay.year,oDay.month - 1, oDay.day);
    var now = new Date();

    if( pdate < now || pdate < oCalendar.MinDate || pdate > oCalendar.MaxDate || oDay.day != 1 ){
        oDay.element.disabled = true;
        oDay.element.style.cursor = "not-allowed";
        oDay.element.style.textDecoration = "line-through";
        oDay.element.title = "Tickets are not available for this date";
    }
    else {
        oDay.element.disabled = false;
        oDay.element.style.cursor = "hand";
        oDay.element.style.fontWeight = "bold";
        oDay.element.style.textDecoration = "none";
        oDay.element.title = "Your ticket will commence on this date";
    }
}

function InvalidDateEntered(oDateChooser,oDate,oEvent){
    //oDateChooser.editor.useLastGoodValue = false;
    oDateChooser.editor.date=null;
    //oDateChooser.editor.good=null;
    oEvent.cancel = true;
    oEvent.cancelPostBack = true;
    oDateChooser.setValue(null);
}

// AddressFinder Functions
function HideAddressList( _controlID )
{
    var AddressList = document.getElementById(_controlID);
    if(AddressList)
    {
        AddressList.style.display = "none";
    }
}

var CheckOut_Window;
function SingleWindow(_url)
{
    CheckOut_Window = window.open(_url,'CheckOut_Window','width=650,height=650,scrollbars=1');
    CheckOut_Window.focus();
}

function clickButton(e, buttonid)
{ 
      var bt = document.getElementById(buttonid); 
      if (typeof bt == 'object')
      { 
            if(navigator.appName.indexOf("Netscape")>(-1))
            { 
                  if (e.keyCode == 13)
                  { 
                        bt.click(); 
                        return false; 
                  } 
            } 
            if (navigator.appName.indexOf("Microsoft Internet Explorer")>(-1))
            { 
                  if (event.keyCode == 13)
                  { 
                        bt.click(); 
                        return false; 
                  } 
            } 
      } 
}

function enableLaunch(toggle)
{
   var ctrl = window.opener.document.getElementById('ctl00_MainContent_btnRelaunch');
   if(ctrl){
        ctrl.disabled = !toggle;
   }
}

function AsyncRequest(URL){
    var request = false; 
    if (window.XMLHttpRequest) { 
        request = new XMLHttpRequest(); 
    }
    else if (window.ActiveXObject) { 
        try { 
            request = new ActiveXObject("Msxml2.XMLHTTP"); 
        } 
        catch (e){ 
            try{ 
                request = new ActiveXObject("Microsoft.XMLHTTP"); 
            }
            catch (e){} 
        } 
    } 
    request.open("GET", URL, true);
    request.send(null);
    alert(request.statusText);
}

// Required to make RadioButtons work in Repeaters. ASP.NET bug!
function SetUniqueRadioButton(nameregex, current)
{
   re = new RegExp(nameregex);
   for(i = 0; i < document.forms[0].elements.length; i++)
   {
      elm = document.forms[0].elements[i]
      if (elm.type == 'radio')
      {
         if (re.test(elm.name))
         {
            elm.checked = false;
         }
      }
   }
   current.checked = true;
}

// Extend jQuery to add function that centers an element in the visible screen
jQuery.fn.center = function() { this.css("position", "fixed"); this.css("top", ($(window).height() - parseInt($(this).css('height'))) / 2 + "px"); this.css("left", ($(window).width() - parseInt($(this).css('width'))) / 2 + "px"); return $(this); };



 


