var display_image=null;
function show_swf(img_name,img_source,window_width,window_height,img_width,img_height){
   if (display_image != null)
          if (!display_image.closed) display_image.close();
   display_image = window.open("","_blank","width=" + window_width + ",height=" + window_height + ",location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no");
   display_image.document.open("text/html");
   display_image.document.writeln("<html>");
   display_image.document.writeln("<head>");
   display_image.document.writeln("<title>" + img_name + "</title>");
   display_image.document.writeln("<link rel=\"stylesheet\" type=\"text/css\" href=\"/nudeartworks.css\">");
   display_image.document.writeln("<\/head>");
   display_image.document.writeln("<body style=\"background-image:none\;\" marginwidth=\"0\" marginheight=\"0\" topmargin=\"0\" leftmargin=\"0\" style=\"margin:0px;\">");
   display_image.document.writeln("<table><tr><td style=\"text-align:center\;\">");
   display_image.document.writeln("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width='"+img_width+"' height='"+img_height+"'>");
   display_image.document.writeln("<param name='movie' value='"+img_source+"'>");
   display_image.document.writeln("<param name='quality' value='high'>");
   display_image.document.writeln("<embed src='" + img_source + "' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='" + img_width + "' height='" + img_height + "'></embed>");
   display_image.document.writeln("</object>");
   display_image.document.writeln("<a href='javascript:close()'> Fenster schliessen<\/a><\/td><\/tr><\/table>");
   display_image.document.writeln("<\/body>");
   display_image.document.writeln("<\/html>");
   display_image.document.close();

        display_image.focus();
}
function show_image(img_name,img_source,img_width,img_height){
   if (display_image != null)
          if (!display_image.closed) display_image.close();
   display_image = window.open("","_blank","width=" + img_width + ",height=" + img_height + ",location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no");
   display_image.document.open("text/html");
   display_image.document.writeln("<html>");
   display_image.document.writeln("<head>");
   display_image.document.writeln("<title>" + img_name + "</title>");
   display_image.document.writeln("<\/head>");
   display_image.document.writeln("<body marginwidth=\"0\" marginheight=\"0\" topmargin=\"0\" leftmargin=\"0\" style=\"margin:0px;\">");
   display_image.document.writeln("<table style=\"background-image:url(" + img_source + ");\"><tr><td><a href='javascript:close()'> ");
   display_image.document.writeln("<img src=\"\/naw\/images\/unsichtbar.gif\" alt=\"" + img_name + "\" width=\"" + img_width + "\" height=\"" + img_height + "\" border=\"0\">");
   display_image.document.writeln("<\/a><\/td><\/tr><\/table>");
   display_image.document.writeln("<\/body>");
   display_image.document.writeln("<\/html>");
   display_image.document.close();

        display_image.focus();
}
function show_full_image(img_name,img_source,img_width,img_height){
   if (display_image != null)
          if (!display_image.closed) display_image.close();
   display_image = window.open("","_blank","fullscreen,scrollbars");
   display_image.document.open("text/html");
   display_image.document.writeln("<html>");
   display_image.document.writeln("<head>");
   display_image.document.writeln("<title>" + img_name + "</title>");
   display_image.document.writeln("<\/head>");
   display_image.document.writeln("<body style=\"margin:0px;text-align:center;\">");
   display_image.document.writeln("<table style=\"width:100%;margin:auto;vertical-align:middle;text-align:center;background-image:url(" + img_source + ");background-repeat:no-repeat;background-position:top center;\"><tr><td><a href='javascript:close()'> ");
   display_image.document.writeln("<img src=\"images\/unsichtbar.gif\" alt=\"" + img_name + "\" width=\"" + img_width + "\" height=\"" + img_height + "\" border=\"0\" title=\"Zum Schließen bitte auf das Bild klicken\">");
   display_image.document.writeln("<\/a><\/td><\/tr><\/table>");
   display_image.document.writeln("<\/body>");
   display_image.document.writeln("<\/html>");
   display_image.document.close();

        display_image.focus();
}
function fensterSchliessen(){
        if (display_image != null)
          if (!display_image.closed) display_image.close();
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_nbGroup(event, grpName) { //v6.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    nbArr = document[grpName];
    if (nbArr)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }
}

function ShowArtworkDetail(scriptUrl,scriptName,properties){
	window.open(scriptUrl,scriptName,properties);
}
function AddComment(scriptUrl,scriptName,properties){
	window.open(scriptUrl,scriptName,properties);
}
function popUp(theUrl,theName,props){
	window.open(theUrl,theName,props);
}

function displayImage(whichImage) {
  var objMainImage = eval('document.MainImage');
  var objNewImage = eval('image' + whichImage);
  objMainImage.src = objNewImage.src;
  objMainImage.width = objNewImage.width;
  objMainImage.height = objNewImage.height;
}

//
// Adds some text where the cursor is.
//
// Works in IE and Mozilla 1.3b+
// In other browsers, it simply adds the text at the end of the current text
//
function addText( input, insText )
{
	input.focus();
	if( input.createTextRange ) {
		document.selection.createRange().text += insText;
 	}
 	else if( input.setSelectionRange ) {
		var len = input.selectionEnd;
   		input.value = input.value.substr( 0, len ) + insText + input.value.substr( len );
   		input.setSelectionRange(len+insText.length,len+insText.length);
 	}
 	else {
	 	input.value += insText;
	}
}

//
// Wraps the current selection of a textbox around with the given 'v' parameter.
//
// Works in IE and Mozilla 1.3b+
// In other browsers, it simply adds an empty pair of tags at the end of the current
// text.
//
function wrapSelection(ta, v)
{
	if( document.selection ) {
		// for IE
		var str = document.selection.createRange().text;
		ta.focus();
		var sel = document.selection.createRange();
		sel.text = "<" + v + ">" + str + "</" + v + ">";
    }
	else {
		// browsers other than IE
		var s = ta;
		if( s.selectionEnd ) {
			// Mozilla 1.3b+
			var s1 = (s.value).substring(0,s.selectionStart)
			var s2 = (s.value).substring(s.selectionEnd,s.textLength)
			selection = (s.value).substring(s.selectionStart, s.selectionEnd)
			s.value = s1 + '<' + v + '>' + selection + '</' + v + '>' + s2
		}
		else {
			// everything else
			s.value += '<' + v + '></' + v + '>';
		}
	}

	return;
}

//
// Asks for a url and adds a link to the textbox, at the same point where the cursor is.
//
// Uses insertText to insert the text so it has the same limitations as insertText has
//
function insertLink(ta) {
	var s  = ta;
	var my_link = prompt('Enter URL:', 'http://')
	if (my_link != null) {
		addText(ta, my_link);
	}

	return;
}