﻿function GetRadWindow()
{
    var oWindow = null;
    if (window.radWindow) oWindow = window.radWindow;
    else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
    return oWindow;
}

function CloseRadWindow()
{
    GetRadWindow().Close();
}

function OpenEventDetailsWindow(eventID)
{
    radopen("EventDetails.aspx?eventID="+eventID, "EventDetailsWindow");
}

function OpenEventDetailsForViewWindow(eventID)
{
    radopen("EventDetailsForView.aspx?eventID="+eventID, "EventDetailsWindow");
}

function OpenExternalEventPageWindow(url, arg)
{
    var height = 500;
    var width = 800;
    var resizable=true;
    var top = (screen.availHeight - height) / 2;
    var left = (screen.availWidth - width) / 2;
    var date = new Date();
    window.open(url,"","Width="+width+"px,Height="+height+"px,resizable="+((resizable)?"yes":"no")+",top="+top+"px,left="+left+"px,status=no,scrollbars=yes");
    if(document.getElementById("TrackerButton")!=null && document.getElementById("TrackerTypeHidden")!=null)
    {        
        document.getElementById("TrackerTypeHidden").value = arg;
        document.getElementById("TrackerButton").click();
    }
}

function OpenWindow(url)
{
    
    var height = url.split("|")[2];
    var width = url.split("|")[1];
    url = url.split("|")[0];
    var resizable=true;
    var top = (screen.availHeight - height) / 2;
    var left = (screen.availWidth - width) / 2;
    var date = new Date();
    window.open(url,"","Width="+width+"px,Height="+height+"px,resizable="+((resizable)?"yes":"no")+",top="+top+"px,left="+left+"px,status=no,scrollbars=yes");
    
}

function CloseWindow()
{
    window.close();
}

function OpenMessegaLinkPageWindow(url, memberID, eventID, providerID)
{
    var height = 500;
    var width = 800;
    var resizable=true;
    var top = (screen.availHeight - height) / 2;
    var left = (screen.availWidth - width) / 2;
    var date = new Date();
    // Update the database...
    if(document.getElementById("TrackerButton")!=null && document.getElementById("TrackerTypeHidden")!=null)
    {        
        document.getElementById("TrackerTypeHidden").value = 4;
        document.getElementById("TrackerButton").click();
    }
    
    if(document.getElementById("TrackConventionEventButton")!=null && 
            document.getElementById("TrackConventionEventTypeHidden")!=null &&
            document.getElementById("TrackConventionEventIdHidden")!=null &&
            document.getElementById("TrackConventionEventProviderIdHidden")!=null)
    {        
        document.getElementById("TrackConventionEventTypeHidden").value = 4;
        document.getElementById("TrackConventionEventIdHidden").value = eventID;
        document.getElementById("TrackConventionEventProviderIdHidden").value = providerID;
        document.getElementById("TrackConventionEventButton").click();
    }
    
    window.open(url,"","Width="+width+"px,Height="+height+"px,resizable="+((resizable)?"yes":"no")+",top="+top+"px,left="+left+"px,status=no,scrollbars=yes");
}

function OpenSiteMessegeLinkPageWindow(url, messageID)
{
    var height = 500;
    var width = 800;
    var resizable=true;
    var top = (screen.availHeight - height) / 2;
    var left = (screen.availWidth - width) / 2;
    var date = new Date();
    if(document.getElementById("TrackMessageButton")!=null && document.getElementById("TrackMessageIdHidden")!=null)
    {        
        document.getElementById("TrackMessageIdHidden").value = messageID;
        document.getElementById("TrackMessageButton").click();
    }
    
    window.open(url,"","Width="+width+"px,Height="+height+"px,resizable="+((resizable)?"yes":"no")+",top="+top+"px,left="+left+"px,status=no,scrollbars=yes");
}


function OpenTermsAndCondition()
{
    radopen("SiteTerms.htm", "TermsAndConditionsWindow");
}

function OpenEventGridPrintDialog(id)
{
    radopen("PrintEventGridDialog.aspx?GridType="+id, "PrintEventGridWindow");
}

function BuildPrintData()
{
    if ((document.getElementById('PrintDataHiddenField') == null) ||
        (document.getElementById('PrintDataDiv') == null))
    {
        return false;    
    }
    
    var printContent = unescape(document.getElementById('PrintDataHiddenField').value);    
    document.getElementById('PrintDataDiv').innerHTML = printContent;
    
    if ((document.getElementById('EventGrid') == null) ||
        (document.getElementById('EventTable') == null))
    {
        return false;    
    }
    document.getElementById('EventGrid').style.height = "100%";
    document.getElementById('EventGrid').style.width = "598px";
    document.getElementById('EventGrid').style.overflow = "hidden";
    document.getElementById('EventTable').style.width = "600px";
   
}

function PrintPage()
{
    if ((document.getElementById('GridDiv') == null) ||
        (document.getElementById('PrintDataHiddenField') == null) ||
        (document.getElementById('PrintButton') == null))
    {
        return false;    
    }
        
    var printContent = document.getElementById('GridDiv').innerHTML;
    document.getElementById('PrintDataHiddenField').value = escape(printContent);        
    document.getElementById('PrintButton').click();
}

function OpenExhibitionGridPrintDialog(category, country, month, year, exhibitionSearchText)
{
    if(exhibitionSearchText=="--טקסט חופשי--")
        exhibitionSearchText="";
    radopen("PrintExhibitionGridDialog.aspx?category="+category+"&country="+country+"&month="+month+"&year="+year+"&exhibitionSearchText="+exhibitionSearchText, "PrintEventGridWindow");
}

function OpenCourseDetailsPrintDialog(id)
{
    radopen("PrintCourseDetailsDialog.aspx?id="+id, "PrintEventGridWindow");
}

function OpenEventDetailsPrintDialog(id, isPrivate)
{
    radopen("PrintEventDetailsDialog.aspx?id="+id+"&isPrivate="+isPrivate, "PrintEventGridWindow");
}

function OpenPrintExhibitionDetailsDialog(id)
{
    radopen("PrintExhibitionDetailsDialog.aspx?id="+id, "PrintEventGridWindow");
}

function OpenProviderEventDetailsWindow(eventID)
{
    radopen("ProviderEventDetails.aspx?eventID="+eventID, "ProviderEventDetailsWindow");
}

function OpenPrivateEventDetailsWindow(eventID)
{
    radopen("PrivateEventDetails.aspx?eventID="+eventID, "PrivateEventDetailsWindow");
}

function OpenSendMailWindow(eventID)
{
    radopen('SendMessageDialog.aspx?Type=EventRec&EventID=' + eventID, 'SendMessageWindow');
}

function OpenDailyEventsList(date)
{
    radopen("DailyEventsList.aspx?date="+date, "DailyEventsWindow");
}

function OpenProviderEntrance()
{
    radopen("ProviderEntranceDialog.aspx", "ProviderEntranceWindow");
}

function OpenRegistrationFieldsOfInterestDialog()
{
    document.getElementById("FlashDiv").innerHTML = "&nbsp;";
    radopen("RegistrationFieldsOfInterestDialog.aspx", "FieldsOfInterestWindow");
}

function OpenLoginDialog()
{
    radopen("LoginDialog.aspx", "LoginWindow");
}

function OpenTermsAndConditionsWindow()
{
    radopen("SiteTerms.htm", "TermsAndConditionsWindow");
    return false;
}

function OpenNotification(messageID, messageType)
{
    //messageType=1-->Incoming message
    //messageType=2-->Sent message
    radopen("NotificationDialog.aspx?messageID="+messageID+"&messageType="+messageType, "NotificationWindow");
}

function OpenMemberDialog(memberID)
{
    radopen("MemberProfileDialog.aspx?memberID="+memberID, "MemberProfileWindow");
}

function OpenEventRelatedMembersDialog(eventId)
{
    radopen("EventRelatedMembers.aspx?eventID="+eventId, "GroupsWindow");
}

function OpenAddToGroupDialog(memberID)
{
    radopen("AddContactToGroup.aspx?memberID="+memberID, "AddContactToGroupWindow");
}
function OpenAddNewGroupCompactDialog()
{
    radopen("AddNewGroupCompact.aspx", "AddNewGroupWindow");
}

function OpenSendMessageDialog(toMemberID)
{
    radopen("SendMessageDialog.aspx?MemberID="+toMemberID, "SendMessageWindow");
}
function CloseLoginWindow()
{
    try
    {
        var oWindow = GetRadWindow();        
        oWindow.Close();
        var oBrowserWnd = GetRadWindow().BrowserWindow
        oBrowserWnd.location.href = 'Events.aspx';        
    }
    catch(ex){}
}

function SetWindowSize(oWnd)  
{          
    oWnd.SetSize(oWnd.GetWidth(), parseInt(oWnd.Height));  
}

function OpenWindow(url)
{
    
    var height = url.split("|")[2];
    var width = url.split("|")[1];
    url = url.split("|")[0];
    var resizable=true;
    var top = (screen.availHeight - height) / 2;
    var left = (screen.availWidth - width) / 2;
    var date = new Date();
    window.open(url,"","Width="+width+"px,Height="+height+"px,resizable="+((resizable)?"yes":"no")+",top="+top+"px,left="+left+"px,status=no,scrollbars=yes");
    
}

function CloseWindow()
{
    window.close();
}
