var ww = "";

function imagePopup(url, caption, dimensions)
{
  var dim = dimensions.split(" x ");
  //var dim = dimensions.match(/\d*/g);
  //alert(dim[0]+":"+dim[1]);
  //alert(dimensions + ":_____"+w+"-"+h);
  //imagefolder = "http://163.165.201.254:92/images/pr-images/";
  var tplUrl  = "/idcplg?IdcService=SS_GET_PAGE&nodeId=368&imageUrl="
              //+ imagefolder
              + url
              +"&imageCaption="+caption;
  openWinCenter(tplUrl, dim[0], dim[1], 'IMG', '');
}


function openWindow(url, w, h, winName, winDescr, centered)
{
	//winDescr = dependent=
	if(!winName){
		winName = '';
	}
	if(!winDescr){
		winDescr = '';
	}
	else{
		winDescr = ',' + winDescr;
	}
	var availX = screen.availWidth;
	var availY = screen.availHeight;
	if(availX < w) w = availX;
	if(availY < h) h = availX;
	var x = Math.round((availX - w)/ 2);
	var y = 20;//Math.round((availY - h) / 2);
	if(centered)
	  winDescr = 'left=' + x + ',top=' + y + ',width=' + w + ',height=' + h + winDescr;
	else
	  winDescr = 'left=' + 0 + ',top=' + 0 + ',width=' + w + ',height=' + h + winDescr;

	ww = open (url, winName, winDescr);
	ww.focus();
	return ww;
}
function openWindowNormal(url, w, h, winName, winDescr)
{
  openWindow(url, w, h, winName, winDescr, false);
}


function openWinCenter(url, w, h, winName, winDescr)
{
  openWindow(url, w, h, winName, winDescr, true);
}

function getCleartime()
{
    var zeit = new Date();
    var ms = zeit.getTime();
    ms = prompt("Millisekunden:",ms);
    zeit.setTime(ms);

    day   = addZero(zeit.getDate());
    month = addZero(zeit.getMonth()+1);
    year  = (zeit.getFullYear());

    hour= addZero(zeit.getHours());
    min = addZero(zeit.getMinutes());
    sec = addZero(zeit.getSeconds());
    alert(day+"."+month+"."+year+" "+hour+":"+min+":"+sec);
}

function addZero(val )
{
    return val < 10 ? ("0"+val):val;
}

function hide(id)
{
  hideElement(document.getElementById(id));
}

function show(id)
{
  showElement(document.getElementById(id));
}

function hideElement(elt)
{
    elt.style.visibility = "hidden";
    elt.style.display    = "none";
}

function showElement(elt)
{
    elt.style.visibility = "visible";
    //elt.style.display    = "inline";
    elt.style.display    = "block";
}

function openWinFullResolution(url)
{
  winDescr  = "scrollbars=1,resizable=1,toolbar=1";
  openWindow(url, 800, 600, 'Full', winDescr, true);
}

function printPrintButton()
{
  document.write("<img src=\"/images/printer.gif\" width=\"12\" height=\"12\" alt=\"Print\" border=\"0\" />&nbsp;"
                +"<a class=\"footer\" href=\"#\" onclick=\"window.print();return false;\">"
                +"Print</a>");
}

/*function booker()
{
  if(location.href.indexOf("localhost")!=-1)	return;
   book1 = "left5.html";
   book2= location.pathname;
   thisID = 500;
   thisLEVEL = 0;
   thisPARENT_NEXT = 0;
   thisPARENT_OVERNEXT = 0;
   book3= "a="+thisID+"&b="+thisLEVEL+"&c="+thisPARENT_NEXT+"&d="+thisPARENT_OVERNEXT+"&e=0";
   book= "/en/index.html?area=" + book1 + "&body=" + book2 + "&" + book3;
   if (parent.frames.length == 0) location.replace(book);
}*/

function getMSGIcon(satNo)
{
    var icon = (satNo > 7 ? "Msg_shd.jpg":"mfg.jpg");
    var linkMet = "<a href='/en/"+(satNo > 7 ? "area4/topic1.html":"mtp")+"' target='_parent'>";
    document.write("<table class='XMetIcon'><tr><td align='center'>"
    + linkMet
    +"<img src=\"../../../images/"
    + icon
    + "\" border=0 height=40></a></td></tr><tr><td class=\"XMetIcon\" id='XMetIcon"+satNo+"'>MET-"+satNo+"</td></tr></table> ");
}

function getNewTag(expiredays, currentDay, currentMonth, currentYear)
{
  printTags(expiredays, currentDay, currentMonth, currentYear, "icon_new_by.gif");
}

function getUpdateTag(expiredays, currentDay, currentMonth, currentYear)
{
  printTags(expiredays, currentDay, currentMonth, currentYear, "updated.gif");
}

function printTags(expiredays, currentDay, currentMonth, currentYear, grafic, asreturn)
{
  //Considered not new after x days
  var newPeriodDays = expiredays;
  //Set Date of Publish
  var publication = new Date();
  publication.setFullYear (currentYear);// (volles Jahr setzen)
  publication.setMonth    ((-1) + currentMonth);//    (Month starts with 0!! )
  publication.setDate     (currentDay);//     (Monatstag setzen)
  publication.setHours    (00);//    (Stunden der Uhrzeit setzen)
  publication.setMinutes  (00);//  (Minuten der Uhrzeit setzen)
  publication.setSeconds  (0);// (Sekunden der Uhrzeit setzen)

  var pastWindowDate = new Date(new Date().getTime()-(1000*60*60*24*newPeriodDays));
  //document.write("<br>Time-Line: "+pastWindowDate);
  var mouseoverText = "Updated: "+publication.getDate()+"/"+(publication.getMonth()+1)+"/"+(publication.getFullYear());
  if(publication.getTime() > pastWindowDate.getTime())
  {
    var str = "<img src='/images/"+grafic+"' alt='"+mouseoverText+"' border=0 title='"+mouseoverText+"'>";
    if(!asreturn) document.write(str);
    return str;
 	}
  return "";
}