﻿
function open_gallery(url) 
{
 params  = 'width='+screen.width;
 params += ', height='+screen.height;
 params += ', top=0, left=0'
 params += ', fullscreen=yes'
 params += ', directories=no';
 params += ', location=no';
 params += ', menubar=no';
 params += ', resizable=yes';
 params += ', scrollbars=yes';
 params += ', status=no';
 params += ', toolbar=no';

 newwin=window.open(url,'', params);
 if (window.focus) {newwin.focus()}
 return false;
}

// standart string replace functionality
function str_replace(haystack, needle, replacement) {
	var temp = haystack.split(needle);
	return temp.join(replacement);
}
 
// needle may be a regular expression
function str_replace_reg(haystack, needle, replacement) {
	var r = new RegExp(needle, 'g');
	return haystack.replace(r, replacement);
}

// Set the visibility of an object to visible
function show(obj) {
    var theObj = getObject(obj);
    if (theObj) {
        theObj.visibility = "visible";
    }
}
   
// Set the visibility of an object to hidden
function hide(obj) {
    var theObj = getObject(obj);
    if (theObj) {
        theObj.visibility = "hidden";
    }
}

function toggleDisplay(container_id) {
    var c = document.getElementById(container_id);
    if (c != null)
        if (c.style.display == "block")
        c.style.display = "none";
    else
        c.style.display = "block";

    return false;
}

function openWindow(anchor, options) {

    var args = '';

    if (typeof (options) == 'undefined') { var options = new Object(); }
    if (typeof (options.name) == 'undefined') { options.name = 'win' + Math.round(Math.random() * 100000); }

    if (typeof (options.height) != 'undefined' && typeof (options.fullscreen) == 'undefined') {
        args += "height=" + options.height + ",";
    }

    if (typeof (options.width) != 'undefined' && typeof (options.fullscreen) == 'undefined') {
        args += "width=" + options.width + ",";
    }

    if (typeof (options.fullscreen) != 'undefined') {
        args += "width=" + screen.availWidth + ",";
        args += "height=" + screen.availHeight + ",";
    }

    if (typeof (options.center) == 'undefined') {
        options.x = 0;
        options.y = 0;
        args += "screenx=" + options.x + ",";
        args += "screeny=" + options.y + ",";
        args += "left=" + options.x + ",";
        args += "top=" + options.y + ",";
    }

    if (typeof (options.center) != 'undefined' && typeof (options.fullscreen) == 'undefined') {
        options.y = Math.floor((screen.availHeight - (options.height || screen.height)) / 2) - (screen.height - screen.availHeight);
        options.x = Math.floor((screen.availWidth - (options.width || screen.width)) / 2) - (screen.width - screen.availWidth);
        args += "screenx=" + options.x + ",";
        args += "screeny=" + options.y + ",";
        args += "left=" + options.x + ",";
        args += "top=" + options.y + ",";
    }

    if (typeof (options.scrollbars) != 'undefined') { args += "scrollbars=1,"; }
    if (typeof (options.menubar) != 'undefined') { args += "menubar=1,"; }
    if (typeof (options.location) != 'undefined') { args += "location=1,"; }
    if (typeof (options.resizable) != 'undefined') { args += "resizable=1,"; }
    if (typeof (options.status) != 'undefined') { args += "status=0,"; }
    //alert(args);
    var win = window.open(anchor, options.name, args);
    win.focus();
    return false;
}

function RefreshParent() {
    window.opener.location = window.opener.location;  //forms[0].submit();
    self.close();
    return false;
}