function encode_utf8(rohtext) {
    // dient der Normalisierung des Zeilenumbruchs
    rohtext = rohtext.replace(/\r\n/g,"\n");
    var utftext = "";
    for(var n=0; n<rohtext.length; n++) {
        // ermitteln des Unicodes des  aktuellen Zeichens
        var c=rohtext.charCodeAt(n);
        // alle Zeichen von 0-127 => 1byte
        if (c<128)
            utftext += String.fromCharCode(c);
        // alle Zeichen von 127 bis 2047 => 2byte
        else if((c>127) && (c<2048)) {
            utftext += String.fromCharCode((c>>6)|192);
            utftext += String.fromCharCode((c&63)|128);}
        // alle Zeichen von 2048 bis 66536 => 3byte
        else {
            utftext += String.fromCharCode((c>>12)|224);
            utftext += String.fromCharCode(((c>>6)&63)|128);
            utftext += String.fromCharCode((c&63)|128);}
    }
    return utftext;
}

function writeDate(){

var month_long_german      = new Array("Januar", "Februar", "März", "April","Mai","Juni","Juli","August","September","Oktober","November","Dezember");
var weekday_long_german    = new Array("Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag");

var dateobj = new Date();

var day     = dateobj.getDate();
var weekday = dateobj.getDay();
var month   = dateobj.getMonth();
var year    = dateobj.getFullYear();

var datestring = weekday_long_german[weekday] + ", " + day + ". " + month_long_german[month] + " " + year;

document.write(datestring);
//document.write("Hello world");
//document.write(year);


}



function daysBetween(yr, mo, dy) {

var SECOND = 1000; // the number of milliseconds in a second
var MINUTE = SECOND * 60; // the number of milliseconds in a minute
var HOUR = MINUTE * 60; // the number of milliseconds in an hour
var DAY = HOUR * 24; // the number of milliseconds in a day
var WEEK = DAY * 7; // the number of milliseconds in a week

  var nDate = new Date(); // current date (local)
  var nTime = nDate.getTime(); // current time (UTC)
  var dTime = Date.UTC(yr, mo - 1, dy); // specified time (UTC)
  var bTime = Math.abs(nTime - dTime)  // time difference
  return Math.round(bTime / DAY);

}

// ### OPEN NEW WINDOW ###
var remote = null;
// javascript:detach('popup','http://',600,400)
function detach(n,u,w,h) {
remote = window.open(u, n, 'width=' + w + ',height=' + h +',resizable=yes,scrollbars=yes');
  if (remote != null) {
    if (remote.opener == null)
	remote.opener = self;
	window.name = 'scomnavbar';
	remote.location.href = u;
	}
}


//Macromediafunktionen

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

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.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

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

function gotoUrl(box) {

	val = box.options[box.selectedIndex].value;
	if(val==0){alert('Bitte Option waehlen !'); box.focus();return;}
	window.open (val,'_top');
	return true;
}


function gewinn(spiel,adresse,termin,antwort,formular) {
    if(!termin){termin=''}	
    if(!antwort){antwort=''}	
    if(!formular){formular='gewinnmail.html'}	

	url="http://www.salzburg.com/kundenbindung/"+formular+"?act="+spiel+"&adr="+adresse+"&termin="+termin+"&antwort="+antwort;
    window.open(url,'gewinnspiel','width=800,height=620,resizable=yes,scrollbars=yes');
}

function jugendtoto(spiel,adresse) {
    url="http://www.salzburg.com/kundenbindung/jugendtotomail.html?act="+spiel+"&adr="+adresse;
    window.open(url,'gewinnspiel','width=600,height=450,resizable=yes,scrollbars=yes');
}

function bestell(spiel,adresse,termin,antwort) {
    if(!termin){termin=''}
    if(!antwort){antwort=''}
    url="http://www.salzburg.com/kundenbindung/bestellmail.html?act="+spiel+"&adr="+adresse+"&termin="+termin+"&antwort="+antwort;
    window.open(url,'gewinnspiel','width=400,height=400,resizable=yes,scrollbars=yes');
}
		
function aquagewinn(spiel,adresse,termin,antwort) {
    if(!termin){termin=''}
    if(!antwort){antwort=''}
    url="http://www.salzburg.com/kundenbindung/aquamail.html?act="+spiel+"&adr="+adresse+"&termin="+termin+"&antwort="+antwort;
    window.open(url,'gewinnspiel','width=640, height=640,,resizable=yes,scrollbars=yes');
}

function skitag(spiel,adresse){
    url="http://www.salzburg.com/kundenbindung/skitagmail.html?act="+spiel+"&adr="+adresse;
    window.open(url,'gewinnspiel','width=600,height=450,resizable=yes,scrollbars=yes');
}

function gewinnabo(spiel,adresse) {

    url="http://www.salzburg.com/spiele/gewinnmail_abo1.html?act="+spiel+"&adr="+adresse;
    window.open(url,'gewinnspiel','width=400,height=400,resizable=yes,scrollbars=yes');
}


function gewinnfrage(spiel,adresse) {

    url="http://www.salzburg.com/spiele/gewinnfragemail.html?act="+spiel+"&adr="+adresse;
    window.open(url,'gewinnspiel','width=400,height=450,resizable=yes,scrollbars=yes');
}

function gewinnselect(spiel,adresse) {

    url="http://www.salzburg.com/spiele/gewinnselectmail.html?act="+spiel+"&adr="+adresse;
    window.open(url,'gewinnspiel','width=400,height=450,resizable=yes,scrollbars=yes');
}

function horoskop(msg) {
   url="http://windu.t-online.at/astrosalzburg/"+msg;
    window.open(url,'horoskop','width=620,height=570,resizable=no,scrollbars=no');

}

function openSlideWin() {
    window.open('http://www.apa.at/apagrafik/olympia/slideset.htm','slidewin','width=330,height=530,left=20,top=20,scrolling=no,resize=yes, status=no')
}


function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' muss eine Email Addresse beinhalten.\n';
      } else if (test!='R') {
        if (isNaN(val)) errors+='- '+nm+' muss eine Nummer beinhalten.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' ist ein Mussfeld.\n'; }
  }

 if (errors) alert('Folgende Fehler sind aufgetreten:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function initAbo() {

        var _href;
        var _pos;
        var _val;
        _href = parent.location.href;
        _pos=_href.indexOf("?");

   if (_pos > 0 )
     {
         if (_href.substring(_pos+1)=='subscribe') {
            document.mail.newsalert[0].checked=true;
                 } 
		 else if (_href.substring(_pos+1)=='delete'){
            document.mail.newsalert[1].checked=true;
                 }
		 else if (_href.substring(_pos+1)=='recommend'){
            document.mail.newsalert[2].checked=true;
                 }
 		 else if (_href.substring(_pos+1)=='weeksubscribe'){
            document.weekly.news[0].checked=true;
                 }
		 else if (_href.substring(_pos+1)=='weekdelete'){
            document.weekly.news[1].checked=true;
                 }

      }
}

function zoom(url,titel){


mypic=new Image();
mypic.src = url;


if(mypic.width == 0){mypic.width=600};
if(mypic.height == 0){mypic.height=350};

pic = eval( "open('','pic', 'width=" + mypic.width +  " height=" +  mypic.height + " resizable')" );


pic.document.write('<title>',titel ,'</title> <body onLoad="window.focus();" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"><img onClick="window.close()" src="', url, '">');

pic.document.close();

}

function goGeiz(param){
var url="http://www.salzburg.com/nwas/service/geizhals.html?url=http://geizhals.salzburg.com/?such=" + param;
document.location.href = url;
}

function openPowerwinning()
{
	var pid=null;
	var tmp01=unescape(document.location.href); //unescape necessary for netscape

	if((tmp01 != null)&&(tmp01 != 'undefined')&&(tmp01 != ''))
	{
		if(tmp01.indexOf('?') != -1)
		{
			var tmp02=tmp01.split('?');
			if(tmp02[1].indexOf('pid=') != -1)
			{
				tmp02=tmp02[1].split('=');
				if(tmp02[1] != '')
				{
					if(tmp02[1].indexOf('&') != -1) // more than one parameter
					{
						tmp02=tmp02[1].split('&');
						pid=tmp02[0];
					}
					else pid=tmp02[1];

					if((pid!=null)&&(pid!=''))
						parent.powerwinning.location.href="http://premiumpromotions.salzburg.com/index_ap.jsp?quelle=sana&pid="+pid;
					else parent.powerwinning.location.href="http://premiumpromotions.salzburg.com/index_ap.jsp?quelle=sana";
				}
				else parent.powerwinning.location.href="http://premiumpromotions.salzburg.com/index_ap.jsp?quelle=sana";
			}
			else parent.powerwinning.location.href="http://premiumpromotions.salzburg.com/index_ap.jsp?quelle=sana";
		}
		else parent.powerwinning.location.href="http://premiumpromotions.salzburg.com/index_ap.jsp?quelle=sana";
	}
	else parent.powerwinning.location.href="http://premiumpromotions.salzburg.com/index_ap.jsp?quelle=sana";
}








/* Greybox Redux
 * Required: http://jquery.com/
 * Written by: John Resig
 * Based on code by: 4mir Salihefendic (http://amix.dk)
 * License: LGPL (read more in LGPL.txt)
 */

var GB_DONE = false;
var GB_HEIGHT = 400;
var GB_WIDTH = 400;

function GB_show(caption, url, height, width) {
	window.scrollTo(0,0);
	GB_HEIGHT = height || 400;
  GB_WIDTH = width || 400;
  if(!GB_DONE) {
    jQuery(document.body)
      .append("<div id='GB_overlay'></div><div id='GB_window'><div id='GB_caption'></div>"
        + "<img src='http://www.salzburg.com/nwas/styles/GB-close.gif' alt='Fenster schlie&szlig;en'/></div>");
    jQuery("#GB_window img").click(GB_hide);
    jQuery("#GB_overlay").click(GB_hide);
    jQuery(window).resize(GB_position);
    GB_DONE = true;
  }

  jQuery("#GB_frame").remove();
  jQuery("#GB_window").append("<iframe id='GB_frame' src='"+url+"'></iframe>");

  jQuery("#GB_caption").html(caption);
  jQuery("#GB_overlay").show();
  GB_position();

  if(GB_ANIMATION)
    jQuery("#GB_window").slideDown("slow");
  else
    jQuery("#GB_window").show();
}

function GB_hide() {
  jQuery("#GB_window,#GB_overlay").hide();
}

function GB_position() {
  var de = document.documentElement;
  var w = self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
  jQuery("#GB_window").css({width:GB_WIDTH+"px",height:GB_HEIGHT+"px",
    left: ((w - GB_WIDTH)/2)+"px" });
  jQuery("#GB_frame").css("height",GB_HEIGHT - 32 +"px");
}



