//bilder loeschen
function del_img(image_default,image,alt,fliesstext,caption) {

  eval ('document.' + image_default + '.src="/imperia/md/defaults/images/default5.jpg"');
	eval ('document.imperia.' + image + '.value=""');
	eval ('document.imperia.' + alt + '.value=""');
	if(fliesstext) eval ('document.imperia.' + fliesstext + '.value="ja"');
	if(caption) eval ('document.imperia.' + caption + '.value=""');
}


// gib die filesize beim download zurück
function size(filesize) {
var size=filesize;
var round_size_k = Math.round((size*10)/1024) / 10;
var round_size;
		if (round_size_k < 1024) {
	  	round_size = round_size_k+'&nbsp;KByte';
		} else {
  		round_size = Math.round((round_size_k*10)/1024) / 10;
 	 	round_size = round_size+'&nbsp;MByte';
		}

var down_time_s = Math.round(round_size_k / 5.5);
var down_time;
		if (down_time_s < 60) {
  			down_time = down_time_s+' sec';
		} else {
  			down_time = Math.round((down_time_s*10)/60) / 10;
  			down_time = down_time+' min';
		}
document.write(round_size + ' | ' + down_time + ' / 56k' );
return true;
}

// seite empfehlen
function sendpage(lng)
{
var str = location.href;

// session raus
var kurz = str.replace(/\/S[^\/]+/,'')

mail_str = "mailto:?subject= Schmalz VacuWorld: " + document.title;
//mail_str += "&body=" + escape( intro + document.title );
//mail_str += " " + escape( desc ) + " " + kurz;
	
        
	       if (lng =='de' || lng =='ch' || lng =='at' ) {
                mail_str += "&body=Schau dir diese Seite von Schmalz Vacuworld einmal an! Sie heißt: " + document.title;
                mail_str += ". Hier ist die Adresse: " + kurz; 
        }
        if (lng =='en') {
                mail_str += "&body=Look at this site! It calls: " + document.title;
                mail_str += ". Here is the Adresse: " + kurz; 
        }
        if (lng =='es') {
                mail_str += "&body=Mira esta página web de SCHMALZ VacuWorld! Se llama: " + document.title;
                mail_str += ". Aquí está la dirección: " + kurz; 
        }
			
				if (lng =='fr') {
                mail_str += "&body=Venez consulter la page Vacuworld de Schmalz! Elle s’appelle: " + document.title;
                mail_str += ". 	" +  kurz; 
        }
        if (lng =='it') {
                mail_str += "&body=Rileggere la pagina Schmalz Vacuworld! Il nome è: " + document.title;
                mail_str += ". 	" +  kurz; 
        }
				 if (lng =='nl') {
                mail_str += "&body=Bekijk eens deze pagina van Schmalz Vacuworld! Hij heet: " + document.title;
                mail_str += ". 	" +  kurz; 
        }
				
location.href = mail_str;

}


//bookmark setzen
function addbookmark() {
	bookmarkurl=self.location.href;
	bookmarktitle=document.title;
	if (document.all) {
		window.external.AddFavorite(bookmarkurl,bookmarktitle)
	} else alert("STRG + D drücken"); 
	
}



//zoom fenster öffnen
function show_zoom(pic,lng) {
	var ziel = "/js/zoom.html." +lng+ "?lng=" +lng+ "&bild=" +pic;
	var breite=600;
	var hoehe=590;
	var menuoffset=40;
	var	ho	=	screen.availHeight;
	var	br	=	screen.availWidth;
	var	left = Math.round((br-breite)/2);
	var	top = Math.round((ho-hoehe)/2);
	var params="width="+breite+",height="+hoehe+",left="+left+",top="+top+",resize=yes,menubar=yes,resizable=yes,scrollbars=1";
	
	zoomwindow=window.open(ziel,"ZoomWindow",params);
	//zoomwindow.moveTo(Math.round((br-breite)/2),Math.round((ho-hoehe)/2)-menuoffset);
	
}

//produktfamilie fenster öffnen
function show_info(ziel,brei,hoe,menubar,warart) {
	var warart = warart;	
	var ziel = ziel;
	var hoehe;
	var breite;
	if (brei) {	breite = brei	} else {breite =620};
	if (hoe) {hoehe = hoe} else {hoehe=590};		
	if (menubar) {menubar = menubar } else {menubar="yes"};

	var menuoffset=40;
	var	ho	=	screen.availHeight;
	var	br	=	screen.availWidth;
	var	left = Math.round((br-breite)/2);
	var	top = Math.round((ho-hoehe)/2);
	
	var name = "ArtInfo" + warart 
	
	var params="width="+breite+",height="+hoehe+",left="+left+",top="+top+",resize=yes,menubar=" + menubar + ",resizable=yes,scrollbars=1";
	
	zoomwindow=window.open(ziel,name,params);
	//zoomwindow.moveTo(Math.round((br-breite)/2),Math.round((ho-hoehe)/2)-menuoffset);
	zoomwindow.focus();
	
}

function suche_start(suchstring, katsuche, websuche, lng) {
var auswahl = document.suchekurz.GROUP.options[document.suchekurz.GROUP.selectedIndex].value;

if (document.suchekurz.GROUP.options[document.suchekurz.GROUP.selectedIndex].value == "KAT") {
		document.suchekurz.action = katsuche;
	}	else {
		document.suchekurz.action = websuche;
	}
return true;
}

/*
function printpage(lng)
{
	var page = self.location.href;
	 	

	var sess = page.match( /\/S[^\/]+/ )
	if( sess ) {
		openprintwindow( page, sess[0], lng);
	} else {
		openprintwindow( page, '', lng );
	}
}
*/


function printpage(lng,host,url)
{
var page;

if(url) {	
		page = 'http://' + host + '/' + url;
	} else {
		page = self.location.href;
	}

	
	var sess = page.match( /\/S[^\/]+/ )
	if( sess ) {
		openprintwindow( page, sess[0], lng);
	} else {
		openprintwindow( page, '', lng );
	}
}

function printformpage(fname )
{
	if( document.forms[fname] && document.forms[fname].elements["notreally"] ) {
		document.forms[fname].elements["notreally"].value = 'yes';
		document.forms[fname].elements["notreally"].value = 'yes';
		document.forms[fname].submit();
	} else {
		alert( "No print version available for this page." );
	}
}


function openprintwindow(page, session, lng ) {
	var breite=600;
	var hoehe=590;

	if( session ) {
		window.open( session + "/np/pg/print?lng=" + lng + "&page=" + escape(page), "Print", "width="+breite+",height="+hoehe+" , resize=yes,menubar=yes,resizable=yes,scrollbars=1" );
	} else {
		window.open( "/np/pg/print?lng=" + lng + "&page=" + escape(page) , "Print", "width="+breite+",height="+hoehe+" , resize=yes,menubar=yes,resizable=yes,scrollbars=1" );
	}
}


function getFormData( formname ) {

	var formobj = document.forms[formname];

	var data = new Array();
	var t = '';
	for( var i = 0; i <formobj.elements.length; i++ ) {
		var elm = formobj.elements[i];


		var datarry;
		if( data[""+elm.name] ) {
			datarry = data[""+elm.name];
		} else {
			datarry = new Array();
			data[""+elm.name] = datarry;
		}

		var value = '';
		if( elm.options && elm.options.length) {
			value = elm.options[elm.options.selectedIndex].value;
		} else {
			value = elm.value;
		}

		t += 't: ' + elm.type + ', n: ' + elm.name + ', v: ' + value + "\n";	
		
		datarry[datarry.length] = value;	
	}

	alert( t );

	var txt = '';
	for( var name in data ) {
		txt += name + '<-->' + data[name] + "\n";
	}	
	alert( txt );
	return data;
}

function checkProspekt(field) {
	field.checked = true ;
}

//stripped den Printbereich raus
function stripPrintStuff( html ) {
	html = html.replace( /\n|\r/g, "" );
	html = html.replace(/^.*<!-- print start -->/, '');
	html = html.replace(/<!-- print end -->.*$/, '');
	
	return html;
}

// Alternative Drucksache ohne Request
function doJSPrint( session, lng, printform ) {
	var win = window.open( "/S" + session + "/np/pg/printjs?lng=" + lng + "&printform=" + printform );
}



//
// Bitte Dokumentieren woher der Code kommt...
//
// cookie construktor und functions

// format der Speicherung:
// name=value; name2=value2; ...
// wobei value = "k1=v1&k2=v2..."

function CookieData(){
 
  this.put = function(key, value){
    this[key] = value;
  };
  
  this.get = function(name){
    if(this[name])
      return this[name];
    else
      return null;
  };
  
  this.contains = function( key ){
    return (typeof this[key] != undefined)?true:false;
  };
  
  this.join = function(){
    var tmp = "";
    var counter = 0;
    for(var i in this){
      if (typeof this[i] == "function" || typeof this[i] == "object") 
        continue;
      if(counter > 0) tmp += "&";
      tmp += escape(i) + ":" + escape(this[i]);
      counter++;
    }
    return tmp;
  }
  
  this.set = function(str){
    if(str.length == 0)
      return false;
    var arr = unescape(str).split("&");
    var datas = new Array();
    for(var i = 0; i < arr.length; i++){
      datas[i] = arr[i].split(":");
    }
    for(var i = 0; i < datas.length; i++){
      this.put(datas[i][0], datas[i][1]);
    }
    return true;
  }

  this.toString = function(){
    var ret = "{";
    for(p in this ){
      if (typeof this[p] == "function" || typeof this[p] == "object") continue;
      if(ret.length > 1)
        ret += ",";
      ret += p + ":" + this[p];
    }
    return ret + "}";
  }
  
  this.setData = function(cookies, cookieName){
    var a = cookies.split("; ");
    var val = "";
    for(var i = 0; i < a.length; i++){
      // name steht am Anfang des cookie-Strings
      if( a[i].search(cookieName) == 0 ){
        var paramString = a[i].substring(cookieName.length+1);
        this.set( paramString );
        return paramString;
      }
    }
    return false;
  }
}

// format der Speicherung:
// name=value; name2=value2; ...
// wobei value = "k1=v1&k2=v2..."

function Cookie(name, cookieTest){
  this.name = name;
  this.expires = new Date().getTime() + 24 * 60 * 60 * 1000;
  
	//alert(new Date().toGMTString())
	//alert(new Date().getTime())
		
	this.data = new CookieData();
  this.domain;
  this.path;
  this.paramString = this.data.setData(document.cookie, this.name);
  this.fromUser = this.paramString.length > 0 ? true : false;
  this.enabled = false;
  
  if(typeof cookieTest != "undefined" && cookieTest == true)
    this.test();
}

Cookie.prototype.getName = function(){
  return this.name;
}
Cookie.prototype.setExpires = function(timestamp){
  this.expires = timestamp;
}
Cookie.prototype.setPath = function(path){
  this.path = path;
}
Cookie.prototype.setDomain = function(domain){
  this.domain = domain;
}
Cookie.prototype.setValue = function(key, value){
  this.data.put(key, value);
}
Cookie.prototype.getValue = function(name){
  return this.data.get(name);
}
Cookie.prototype.getParamString = function(){
  return this.paramString;
}
Cookie.prototype.send = function(){
  document.cookie = this.name +"=" + this.data.join() +
                    "; expires=" + new Date(this.expires).toGMTString() +
                    (this.path ? "; path=" + this.path : "") +
                    (this.domain ? "; domain=" + this.domain : "");

}
Cookie.prototype.test = function(){
  if(this.fromUser == true) return true;
  var now = new Date().getTime();
  document.cookie = "cookieEnabled="+now + 
                    "; expires=" + new Date(now + 5000).toGMTString() +
                    "; path=/";
  var re = new RegExp("cookieEnabled="+now, "g");
  this.enabled = re.test(document.cookie);
}

Cookie.prototype.remove = function(){
  this.expires = new Date().getTime();
  this.data = new CookieData();
  this.send();
}

var meldung = '';
function PreisPopup(url,frm,warart,meldung) { 
		
	var menge = eval("document." +frm + "." + warart + ".value");
	
	var c = Math.round((Math.random(10)*100000))
	var art = warart + c;
		
	if(!menge || isNaN(menge) ) {
			alert(meldung)	
			eval("document." +frm + "." + warart + ".focus()");
		}else { 
		url = url + "&menge=" + menge
		show_info(url,620,320,"no",art)
	}
}

