﻿//These functions show and hide divs
function revealDiv(divtoshow) {
    document.getElementById(divtoshow).style.display = "";
}
function removeDiv(divtoshow) {
    document.getElementById(divtoshow).style.display = "none";
}
function showDiv(divtoshow) {
    document.getElementById(divtoshow).style.visibility = "visible";
}
function hideDiv(divtoshow) {
    document.getElementById(divtoshow).style.visibility = "hidden"; 
}

//This function opens a new window
function newWindow(url,title,width,height,scrollbars){
	var security, settings;
	var LeftPosition = (screen.width) ? (screen.width-450)/2 : 100;
	var TopPosition = (screen.height) ? (screen.height-250)/2 : 100;
	settings='width=' + width + ',height=' + height + ',top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=' + scrollbars + ',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
	security = window.open(url, title, settings);
}

//This function is being used as the A tag URL, 
//to include the CMC regExp indentification - when redirection is not relevant
function ignore(cmc_param) {}

//This function is being used as the A tag URL, 
//to include the CMC regExp indentification - when redirection is relevent
function loadURL (url, cmc_param, newWindow){
    if (newWindow) {
        window.open(url, "_blank");
    } else {
        window.location.href = url;
    }
}

//this function is being called when clicking the sort button
function goSort(ctrl) {
    var value = document.getElementById(ctrl).value;
    var baseURL = baseurlwithoutsort; 
    var url = baseURL + '&sort_option=' + value;
    window.location.href = url;
}

/*Setting the collapse\expand state of the filters.  
The function is called from each filter object but appears once in the search page*/
function SwitchStyle(imgObj, tblListID) {
    var tblList = document.getElementById(tblListID);
    if (tblList.style.display == 'none') {
        //img.td.tr.tbody.table.siblingTable = children table

        tblList.style.display = '';
        if (imgObj.value != 'nothing') {
            imgObj.alt = 'Collapse';
            imgObj.src = '../artwork/common/browse/filter_collapse.gif';
        }
    }
    else {
        //img.td.tr.tbody.table.siblingTable = children table
        tblList.style.display = 'none';
        if (imgObj.value != 'nothing') {
            imgObj.alt = 'Expand';
            imgObj.src = '../artwork/common/browse/filter_expand.gif';
        }
    }
}

/* Global settings */
var globals = {
    tracking: {
        useClicktracks: true
    }
};