// JavaScript Document
function imglink(link) {
  var stdprops = "screenX=100,screenY=0,location=no,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,scrollbars=yes,alwaysRaised=yes,marginwidth=0,marginheight=0,"
  var picprops = stdprops+"toolbar=no";
  windowwidth = 500;
  windowheight = 450;
  newlink = link; 
  picpage=open(newlink, "gallery", "width=" + windowwidth + ",height=" + windowheight + "," + picprops);
  picpage.focus();
}

function ownOuterWidth() {
var x;
  if (window.outerWidth)
  {
	x = window.outerWidth;
  }
  else if (window.Width)
  {
	x = window.Width;
  }
  else
  {
	x = ownInnerWidth() + 25;
  }
  return x;
}

function ownOuterHeight() {
var y;
  if (self.outerHeight) // all except Explorer
  {
	y = self.outerHeight;
  }
  else if (self.Height)
	// Explorer 6 Strict Mode
  {
	y = self.Height;
  }
  else
  {
	y = ownInnerHeight() + 60;
  }
  return y;
}

function ownInnerWidth() {
var x;
  if (self.innerWidth) // all except Explorer
  {
	x = self.innerWidth;
  }
  else if (document.documentElement && document.documentElement.clientWidth)
	// Explorer 6 Strict Mode
  {
	x = document.documentElement.clientWidth;
  }
  else if (document.body) // other Explorers
  {
	x = document.body.clientWidth;
  }
  return x;
}

function ownInnerHeight() {
var y;
  if (self.innerHeight) // all except Explorer
  {
	y = self.innerHeight;
  }
  else if (document.documentElement && document.documentElement.clientHeight)
	// Explorer 6 Strict Mode
  {
	y = document.documentElement.clientHeight;
  }
  else if (document.body) // other Explorers
  {
	y = document.body.clientHeight;
  }
  return y;
}

function resizegallery(wInnerWidth, wInnerHeight) {
  sw = screen.availWidth;
  sh = screen.availHeight;
  wiw = ownInnerWidth();
  wih = ownInnerHeight();
  wow = ownOuterWidth();
  woh = ownOuterHeight();
  nwh = wInnerHeight+woh-wih;
  nww = wInnerWidth +wow-wiw;
  window.Height = nwh;
  window.Width  = nww;
  wt = (sh - woh) / 2;
  wl = (sw - wow) / 2;
  window.resizeTo(nww, nwh);
}

function confirmLink(theLink, theSqlQuery)
{
    // Confirmation is not required in the configuration file
    // or browser is Opera (crappy js implementation)
    //if (confirmMsg == '' || typeof(window.opera) != 'undefined') {
    //    return true;
    // }
    var confirmMsg = 'Bitte bestätigen';
    var is_confirmed = confirm(confirmMsg + ' :\n' + theSqlQuery);
    if (is_confirmed) {
    	if ( typeof(theLink.href) != 'undefined' ) {
            theLink.href += '&is_js_confirmed=1';
        } else if ( typeof(theLink.form) != 'undefined' ) {
            theLink.form.action += '?is_js_confirmed=1';
        }
    }

    return is_confirmed;
} // end of the 'confirmLink()' function

function tausche(liste, a, b)
{
  var temptext           = liste.options[a].text;
		var tempvalue          = liste.options[a].value; 
		liste.options[a].text  = liste.options[b].text;
		liste.options[a].value = liste.options[b].value;
		liste.options[b].text  = temptext;
		liste.options[b].value = tempvalue;
}

function stringComparison(a, b)	
{
	a = a.toLowerCase();
	a = a.replace(/ä/g,"a");
	a = a.replace(/ö/g,"o");
	a = a.replace(/ü/g,"u");
	a = a.replace(/ß/g,"s");

	b = b.toLowerCase();
	b = b.replace(/ä/g,"a");
	b = b.replace(/ö/g,"o");
	b = b.replace(/ü/g,"u");
	b = b.replace(/ß/g,"s");
	return(a==b)?0:(a>b)?1:-1;
}

function sortiere(liste)
{
		var getauscht = true;
		var i;
		var a, b;
		if (liste.options.length > 2)
  {
			 while (getauscht)
				{
						getauscht = false;
						for(i = 0; i < liste.options.length - 1; i++)
						{			
								a = liste.options[i].text;
								b = liste.options[i+1].text;
								if (stringComparison(a, b)>0)
								{
										tausche(liste, i, i+1);
										getauscht = true;
								}
						}
				}
		}
}

function MoveProg(srclist, destlist, progtext, addit)
{
  var no;
		var i;
  var pos;
 	for(i = srclist.options.length-1; i > -1; i--)
  {
 			if(srclist.options[i].selected)
    {  
				  no = new Option(srclist.options[i].text,srclist.options[i].value);
						pos = destlist.options.length;
      destlist.options[pos] = no;
						srclist.options[i] = null;
				}
		}
		sortiere(destlist);
  if (addit == 1)
  {
			 progtext.value = '';
		 	for(i = 0; i < destlist.options.length ; i++)
				{	 
				  if (i>0)	progtext.value = progtext.value + ',';
						progtext.value = progtext.value + destlist.options[i].value;
				}
		}
  if (addit == 0)
  {
			 progtext.value = '';
		 	for(i = 0; i < srclist.options.length ; i++)
				{	 
				  if (i>0)	progtext.value = progtext.value + ',';
						progtext.value = progtext.value + srclist.options[i].value;
				}
		}
}