//url="http://www.salzburg.com/"
/*
This file contains other functions and logic to perform
*/

/**************
artikel drucken
h.maier@conova.com  2007-02-26
*************/

function printArticle(){

	if(!document.getElementById('print1') || !document.getElementById('print1')){
		alert('Keine Druckausgabe verf?gbar');
		return false;
	}
	url = window.location.href;
	ArticleContent1 = document.getElementById('print1').innerHTML;
	ArticleContent2 = document.getElementById('print2').innerHTML;

	printWin = window.open('', 'printw','height=800,width=620,scrollbars=yes,resizable=yes');


    window.setTimeout(function () {
//	printWin.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">');
//	printWin.document.write('<?xml version="1.0" encoding="iso-8859-1"?>');
//	printWin.document.write('<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">');
	printWin.document.write('<html><head>');
	printWin.document.write('<title>SN - Artikel ausdrucken </title>');
	printWin.document.write('<link rel="stylesheet" href="http://www.salzburg.com/nwas/styles/default.css" type="text/css" />');
	printWin.document.write('<!--[if IE 6]><link rel="stylesheet" href="http://www.salzburg.com/nwas/styles/IE6default.css" type="text/css"><![endif]-->');
	printWin.document.write('</head><body onload="print();" style="padding:8px;"><div id="content">');

	printWin.document.write(ArticleContent1);	
	printWin.document.write('<span class="text">');

	printWin.document.write(ArticleContent2);	
	printWin.document.write('</span></div><div class="printfooter">');
	//printWin.document.write(url);
	printWin.document.write('</div>');
    
	printWin.document.write('</body></html>');

	printWin.document.close();

    },300);


}



/**************
function from old www.salzburg.com
h.maier@conova.com  2007-02-26
start
*************/


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 mail(msg,rechnung) {
   url="http://www.salzburg.com/kundenbindung/aboservice_testleseraktionen.html?act="+msg;
   if(rechnung){
   url+="&rechnung=1";
	}	
    window.open(url,'aktionen','width=620,height=600,resizable=yes,scrollbars=yes');

}

function testabo(msg,praemie,rechnung) {
   url="http://www.salzburg.com/kundenbindung/aboservice_testleseraktionen.html?act="+msg;
      if(praemie){
         url+="&praemie="+praemie;
         }
      if(rechnung){
         url+="&rechnung=1";
         }
     window.open(url,'aktionen','width=620,height=600,resizable=yes,scrollbars=yes');
     }


function vignette(msg,rechnung) {
   url="http://www.salzburg.com/kundenbindung/aboservice_testleseraktionen_vignette.html?act="+msg;
      if(rechnung){
         url+="&rechnung=1";
         }
     window.open(url,'aktionen','width=620,height=600,resizable=yes,scrollbars=yes');
     }

function xmas(msg,rechnung) {
   url="http://www.salzburg.com/kundenbindung/aboservice_weihnachtsabo.html?act="+msg;
         if(rechnung){
             url+="&rechnung=1";
         }
     window.open(url,'aktionen','width=620,height=600,resizable=yes,scrollbars=yes');
     }


function bestellung(aktion,adresse) {
   url="http://www.salzburg.com/kundenbindung/aboservice_wintertouren.html?act="+aktion+"&adr="+adresse;
      window.open(url,'aktionen','width=620,height=600,resizable=yes,scrollbars=yes');
  }

function tibidono(msg) {
   url="http://www.salzburg.com/abo/formular.php?act="+msg;
      window.open(url,'tibidono','width=620,height=600,resizable=yes,scrollbars=yes');
  }

function schenken(msg) {
   url="http://www.salzburg.com/kundenbindung/aboservice_aboschenken.html?act="+msg;
   window.open(url,'aktionen','width=620,height=600,resizable=yes,scrollbars=yes');
}

function abowerben(msg,rechnung) {
   url="http://www.salzburg.com/kundenbindung/aboservice_golfabo.html?act="+msg;
         if(rechnung){
             url+="&rechnung=1";
         }
     window.open(url,'aktionen','width=620,height=600,resizable=yes,scrollbars=yes');
     }

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=850,height=650,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=620,height=600,resizable=yes,scrollbars=yes');
}


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 setHP()
{
document.all.test.style.behavior='url(#default#Homepage)';
document.all.test.setHomepage('http://www.salzburg.com/');
}

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";
}

/**************
function from old www.salzburg.com
h.maier@conova.com  2007-02-26
start
*************/


function getArgs(sep){
  var args = new Object();
  var query = location.search.substring(1);
  if(!sep) sep = '&';
  var pairs = query.split(sep);
  for(var i = 0; i <pairs.length; i++) {
  	var pos = pairs[i].indexOf('=');
	if (pos == -1){
		args[pairs[i]]='';
		continue;
	}
	var argname = pairs[i].substring(0,pos);
	var value = pairs[i].substring(pos+1);
	args[argname] = unescape(value);
  }
  return args;
}



