/*************************
  Coppermine Photo Gallery
  ************************
  Copyright (c) 2003-2008 Dev Team
  v1.1 originally written by Gregory DEMAR

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License version 3
  as published by the Free Software Foundation.

  ********************************************
  Coppermine version: 1.4.19
  $HeadURL: https://coppermine.svn.sourceforge.net/svnroot/coppermine/trunk/cpg1.4.x/scripts.js $
  $Revision: 4392 $
  $Author: gaugau $
  $Date: 2008-04-16 09:25:35 +0200 (Mi, 16 Apr 2008) $
**********************************************/

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function writeCookie(name, data, noDays){
  var cookieStr = name + "="+ data
  if (writeCookie.arguments.length > 2){
    cookieStr += "; expires=" + getCookieExpireDate(noDays)
    }
  document.cookie = cookieStr
}

function readCookie(cookieName){
   var searchName = cookieName + "="
   var cookies = document.cookie
   var start = cookies.indexOf(cookieName)
   if (start == -1){ // cookie not found
     return ""
     }
   start += searchName.length //start of the cookie data
   var end = cookies.indexOf(";", start)
   if (end == -1){
     end = cookies.length
     }
   return cookies.substring(start, end)
}

function blocking(nr, cookie, vis_state)
{
        if (document.layers)
        {
                current = (document.layers[nr].display == 'none') ? vis_state : 'none';
                if (cookie != '')
                        writeCookie(nr, current);
                document.layers[nr].display = current;
        }
        else if (document.all)
        {
                current = (document.all[nr].style.display == 'none') ? vis_state : 'none';
                if (cookie != '')
                        writeCookie(nr, current);
                document.all[nr].style.display = current;
        }
        else if (document.getElementById)
        {
                display = (document.getElementById(nr).style.display == 'none') ? vis_state : 'none';
                if (cookie != '')
                        writeCookie(nr, display);
                document.getElementById(nr).style.display = display;
        }
}


function adjust_popup()
{
        var w, h, fixedW, fixedH, diffW, diffH;
        if (document.documentElement && document.body.clientHeight==0) {     // Catches IE6 and FF in DOCMODE
//                fixedW = document.documentElement.clientWidth;
//                fixedH = document.documentElement.clientHeight;
                fixedW = screen.width;
                fixedH = screen.height;
                window.resizeTo(fixedW, fixedH);
                diffW = fixedW - document.documentElement.clientWidth;
                diffH = fixedH - document.documentElement.clientHeight;
                w = fixedW + diffW + 16; // Vert Scrollbar Always On in DOCMODE.
                h = fixedH + diffH;
                if (w >= screen.availWidth) h += 16;
        } else if (document.all) {
                fixedW = document.body.clientWidth;
                fixedH = document.body.clientHeight;
                window.resizeTo(fixedW, fixedH);
                diffW = fixedW - document.body.clientWidth;
                diffH = fixedH - document.body.clientHeight;
                w = fixedW + diffW;
                h = fixedH + diffH;
                if (h >= screen.availHeight) w += 16;
                if (w >= screen.availWidth)  h += 16;
        } else {
                fixedW = window.innerWidth;
                fixedH = window.innerHeight;
                window.resizeTo(fixedW, fixedH);
                diffW = fixedW - window.innerWidth;
                diffH = fixedH - window.innerHeight;
                w = fixedW + diffW;
                h = fixedH + diffH;
                if (w >= screen.availWidth)  h += 16;
                if (h >= screen.availHeight) w += 16;
        }
        w = Math.min(w,screen.availWidth);
        h = Math.min(h,screen.availHeight);
        window.resizeTo(w,h);
        window.moveTo((screen.availWidth-w)/2, (screen.availHeight-h)/2);
}

function show_section(e) {
    if (document.getElementById(e).style.display == 'none') {
        document.getElementById(e).style.display = 'block';
    } else {
        document.getElementById(e).style.display = 'none';
    }
}


function expand()
{
        var Nodes = document.getElementsByTagName("table")
        var max = Nodes.length
        for(var i = 0;i < max;i++) {
                var nodeObj = Nodes.item(i)
                var str = nodeObj.id
                if (str.match("section")) {
                        nodeObj.style.display = 'block';
                }
        }
}

function hideall()
{
        var Nodes = document.getElementsByTagName("table")
        var max = Nodes.length
        for(var i = 0;i < max;i++) {
                var nodeObj = Nodes.item(i)
                var str = nodeObj.id
                if (str.match("section")) {
                        nodeObj.style.display = 'none';
                }
        }
}

function obj_ref(object)
{
	if (document.getElementById)
	{
		return document.getElementById(object);
	}
	else if (document.all)
	{
		return eval('document.all.' + object);
	}
	else
	{
		return false;
	}
}

function obj_toggle(object1, cstat)
{
//alert(object1);
	var object1 = obj_ref(object1);
	if( !object1.style )
	{
		return false;
	}
	if( !cstat )
	{
		return false;
	}

	if ( cstat == '0' )
	{
		object1.style.display = 'none';
		return false;
	}

	if ( cstat == '1' )
	{
		object1.style.display = '';
		return false;
	}

	if( object1.style.display == 'none' )
	{
		object1.style.display = '';

	}
	else
	{
		object1.style.display = 'none';
	}
}


<!-- ----------------- ZeroClipBoard script --------------------- -->
var clip = null;
		
function $(id) { return document.getElementById(id); }

function init() {

	clip = new ZeroClipboard.Client();
	clip.setHandCursor( true );
			
//	clip.addEventListener('load', function (client) {
//		debugstr("Flash movie loaded and ready.");
//	});
			
	clip.addEventListener('mouseOver', function (client) {
	// update the text on mouse over
		clip.setText( $('message').value );
	});
			
//	clip.addEventListener('complete', function (client, text) {
//		debugstr("Copied text to clipboard: " + text );
//	});
	clip.addEventListener('complete', function (client, text) {
		debugstr("Code copié en mémoire !");
	});
			
	clip.glue( 'd_clip_button', 'd_clip_container' );
}
		
function debugstr(msg) {
	var p = document.createElement('span');
	p.innerHTML = msg;
	$('d_debug').appendChild(p);

	var Nx=navigator.appName; var Vd=navigator.vendor;
	if (Nx=="Microsoft Internet Explorer") {
		document.all.d_clip_container.style.visibility = "hidden";
		document.all.d_clip_container.style.width = "0px";
		document.all.d_clip_container.innerHTML = "";
		return false;
	}
	if (Nx=="Opera") {
		var cObject = document.getElementsByName("d_clip_container");
		cObject(0).hidden = true;
		return false;
	}
	if (Nx=="Netscape") {
		if (Vd=="") { // Mozilla
			document.getElementById('d_clip_container').hidden = true;
			document.getElementById('d_clip_container').width = "0px";
		} else {	// NS 4 ou 6
			document.all.d_clip_container.style.visibility = "hidden";
			document.all.d_clip_container.style.width = "0px";
			document.all.d_clip_container.innerHTML = "";
		}
		return false;
	}
}

//alert("ok");

