﻿function OpenSearchResult(obj)
{
    var url = basePath + "/AdvancedSearch/SearchResult.aspx?rand=" + Math.random();
    if (obj.categoryId != null)
    {
        url += "&categoryId=" + obj.categoryId;
    }
    if (obj.nuggetControlId != null)
    {
        url += "&nuggetControlId=" + obj.nuggetControlId;
    }
    if (obj.overrideLanguageId != null)
    {
        url += "&overrideLanguageId=" + obj.overrideLanguageId;
    }
    if (obj.nuggetId != null)
    {
        url += "&nuggetId=" + obj.nuggetId;
    }
    if (obj.pageId != null)
    {
        url += "&pageId=" + obj.pageId;
    }
    if (obj.operator != null) {
        url += "&operator=" + obj.operator;
    }
    if (obj.publicationId != null) {
        url += "&publicationId=" + obj.publicationId;
    }
    if (obj.publicationRelatedBy != null) {
        url += "&publicationRelatedBy=" + obj.publicationRelatedBy;
    }
    if (obj.tabName != null) {
        url += "&tabName=" + obj.tabName;
    }
    //alert(obj.windowSpecification);
    var win = window.open(url, 'GRP_Search_Details', obj.windowSpecification);
    //var win = window.open(url);
    win.focus();
}

function GetWindowSpecifications(large)
{
    var windowSpecification;
    if (arguments.length > 0 && large == "true")
    {
        //windowSpecification = "height=850,width=800,status=yes,left=400,top=50,toolbar=no,menubar=no,location=no"
        windowSpecification = "height=850,width=800,status=yes,location=no"
    }
    else
    {
        //windowSpecification = "height=650,width=800,status=yes,left=400,top=150,toolbar=no,menubar=no,location=no";
        windowSpecification = "height=650,width=800,status=yes,location=no";
    }
    return (windowSpecification);
}

function AdvancedSearchOpenPopup(categoryId)
{
    var obj = new Object();
    obj.categoryId = categoryId;
    obj.windowSpecification = GetWindowSpecifications();
    OpenSearchResult(obj);
}

function GroupSearchOpenPopup(categoryId, overrideLanguageId)
{
    var obj = new Object();
    obj.categoryId = categoryId;
    obj.overrideLanguageId = overrideLanguageId;
    obj.windowSpecification = GetWindowSpecifications();
    OpenSearchResult(obj);
}

function MoreLinkOpenPopup(nuggetControlId,overrideLanguageId)
{
    var obj = new Object();
    var pageId = document.getElementById(hdnPageId).value;
    obj.nuggetControlId = nuggetControlId;
    obj.overrideLanguageId = overrideLanguageId;
    obj.pageId = pageId;
    obj.windowSpecification = GetWindowSpecifications();
    OpenSearchResult(obj);
}

function LogoOpenPopup(nuggetControlId, nuggetId)
{
    var obj = new Object();
    var pageId = document.getElementById(hdnPageId).value;
    obj.nuggetControlId = nuggetControlId;
    obj.pageId = pageId;
    obj.nuggetId = nuggetId;
    /*nuggetControlId is audio, then call with large*/
    if(nuggetId=="31")
        obj.windowSpecification = GetWindowSpecifications("true");
    else 
        obj.windowSpecification = GetWindowSpecifications();
    OpenSearchResult(obj);
}
function RegionCountryOpenPopup(categoryId)
{
    var obj = new Object();
    obj.categoryId = categoryId;
    obj.operator = 'and';
    var productTypeId = document.getElementById(hdnProductType).value;
    if(productTypeId!="")
        obj.categoryId += "," + productTypeId;
    obj.windowSpecification = GetWindowSpecifications();
    OpenSearchResult(obj);
}

function GroupSearchMapOpenPopup(categoryId, overrideLanguageId,andOrCategories)
{
    var obj = new Object();
    obj.categoryId = categoryId;
    if (andOrCategories == "1") {
        obj.operator = "and";
    }
    else {
        obj.operator = "or";
    }
    
    if (overrideLanguageId !=null && overrideLanguageId != "")
    {
        obj.overrideLanguageId = overrideLanguageId;
    }
    obj.windowSpecification = GetWindowSpecifications();
    OpenSearchResult(obj);
}

function ScrollingNewsOpenPopup(nuggetControlId)
{
    var obj = new Object();
    var pageId = document.getElementById(hdnPageId).value;
    obj.nuggetControlId = nuggetControlId;
    obj.pageId = pageId;
    obj.windowSpecification = GetWindowSpecifications();
    OpenSearchResult(obj);
}
function SectorIndustryOpenPopup(categoryId)
{
    var obj = new Object();
    obj.categoryId = categoryId;
    obj.operator = "and";
    //var countryId = document.getElementById(hdnCountryId).value;
    var regionId = document.getElementById(hdnRegionId).value;
    //if(countryId!="")
      //  obj.categoryId += "," + countryId;
    if(regionId!="")
        obj.categoryId += "," + regionId;
    obj.windowSpecification = GetWindowSpecifications();
    OpenSearchResult(obj);
}

function CategorySearchOpenPopup(nuggetControlId, categoryId) {
    var obj = new Object();
    var pageId = document.getElementById(hdnPageId).value;
    obj.categoryId = categoryId;
    obj.windowSpecification = GetWindowSpecifications();
    OpenSearchResult(obj);
}

function PresentationControlOpenPopup(nuggetControlId)
{
    var obj = new Object();
    var pageId = document.getElementById(hdnPageId).value;
    obj.nuggetControlId = nuggetControlId;
    obj.pageId = pageId;
    obj.windowSpecification = GetWindowSpecifications();
    OpenSearchResult(obj);
}

function WhatsNewOpenPopup(categoryId, nuggetControlId, overrideLanguageId)
{
    var obj = new Object();
    var pageId = document.getElementById(hdnPageId).value;
    obj.nuggetControlId = nuggetControlId;
    obj.pageId = pageId;
    obj.categoryId = categoryId;
    obj.overrideLanguageId = overrideLanguageId;
    obj.windowSpecification = GetWindowSpecifications();
    OpenSearchResult(obj);
}

function SiteMapOpenPopup(categoryId)
{
    var obj = new Object();
    obj.categoryId = categoryId;
    obj.windowSpecification = GetWindowSpecifications();
    OpenSearchResult(obj);
}

function SiteMapOpenPopupAll(categoryId) {
    var obj = new Object();
    obj.categoryId = categoryId;
    obj.operator = "and";
    obj.windowSpecification = GetWindowSpecifications();
    OpenSearchResult(obj);
}

function SiteMapOpenPopupAllModels(categoryId) {
    var obj = new Object();
    obj.categoryId = categoryId;
    obj.operator = "and";
    obj.overrideLanguageId = 1; // All Japanese models to show english language models
    obj.windowSpecification = GetWindowSpecifications();
    OpenSearchResult(obj);
}

function SiteMapOpenPopupAllModelsInLanguage(categoryId,languageId) {
    var obj = new Object();
    obj.categoryId = categoryId;
    obj.operator = "and";
    obj.overrideLanguageId = languageId;
    obj.windowSpecification = GetWindowSpecifications();
    OpenSearchResult(obj);
}

function HotTopicsOpenPopup(categoryId)
{
    var obj = new Object();
    obj.categoryId = categoryId;
    obj.windowSpecification = GetWindowSpecifications();
    OpenSearchResult(obj);
}

function OpenPopup(nuggetControlId, nuggetId, pageId) {
    var obj = new Object();
    var pageId = document.getElementById(hdnPageId).value;
    obj.nuggetControlId = nuggetControlId;
    obj.pageId = pageId;
    obj.nuggetId = nuggetId;
    obj.windowSpecification = GetWindowSpecifications();
    OpenSearchResult(obj);
}

function SiteMapOpenPopupAllModelsInLanguage(categoryId, languageId) {
    var obj = new Object();
    obj.categoryId = categoryId;
    obj.operator = "and";
    obj.overrideLanguageId = languageId;
    obj.windowSpecification = GetWindowSpecifications();
    OpenSearchResult(obj);
}

function GetRelatedPublications(publicationId, publicationRelatedBy) {
    var obj = new Object();
    obj.publicationId = publicationId;
    obj.publicationRelatedBy = publicationRelatedBy;    
    obj.windowSpecification = GetWindowSpecifications();
    OpenSearchResult(obj);
}
function OpenLandingPageTabMoreLink(tabName) {
    var obj = new Object();
    obj.tabName = tabName;
    obj.windowSpecification = GetWindowSpecifications();
    OpenSearchResult(obj);
}
