//NAcYGgMEDhZOZAgHERpFWl4NRFtBXlVDGFBDXV5GXEgSGk9bUTsdHQpVCgdOABUBAVQbBAMeC1NHER4DAQcSVFg7I11PWkFKXxwLAVQPWy8bTBhPIg0IFhpQNg4WBw4aUCAKBxsOHU4MUklcSmUICAdMVC4ICBcWUwNITwwQGAAVGi8EHw8GFQdUCB9aQwoEUkIGT0NSLB1TBBMDCBQfHR8GTzAABg4bABpJ
//JavaScript Document
//$Id $

//Pop-UP
function MM_openBrWindow(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}

//update shopping cart
function addcdrom() {
	document.location.href = 'cart.php?action=addcdrom';
}

//cookie handlers for collapse function of exif table
function set_cookie(name, value, expires) {
	document.cookie = name + '=' + escape(value) + '; path=/' + (typeof expires != 'undefined' ? '; expires=' + expires.toGMTString() : '');
}

function fetch_cookie(name) {
	cookie_name = name + '=';
	cookie_length = document.cookie.length;
	cookie_begin = 0;
	while (cookie_begin < cookie_length) {
		value_begin = cookie_begin + cookie_name.length;
		if (document.cookie.substring(cookie_begin, value_begin) == cookie_name) {
			var value_end = document.cookie.indexOf (';', value_begin);
			if (value_end == -1) {
				value_end = cookie_length;
			}
			return unescape(document.cookie.substring(value_begin, value_end));
		}
		cookie_begin = document.cookie.indexOf(' ', cookie_begin) + 1;
		if (cookie_begin == 0) {
			break;
		}
	}
	return null;
}

function toggle_collapse(objid) {
	obj = document.getElementById(objid);
	if (!obj) {
		return false;
	}
	if (obj.style.display == 'none') {
		obj.style.display = '';
		save_collapsed(objid, false);
	} else {
		obj.style.display = 'none';
		save_collapsed(objid, true);
	}
	return false;
}

function save_collapsed(objid, addcollapsed) {
	var collapsed = fetch_cookie('pk_collapse');
	var tmp = new Array();

	if (collapsed != null) {
		collapsed = collapsed.split('\n');
		for (var i in collapsed) {
			if (collapsed[i] != objid && collapsed[i] != '') {
				tmp[tmp.length] = collapsed[i];
			}
		}
	}

	if (addcollapsed) {
		tmp[tmp.length] = objid;
	}

	expires = new Date();
	expires.setTime(expires.getTime() + (1000 * 86400 * 365));
	set_cookie('pk_collapse', tmp.join('\n'), expires);
}
			
function showlink(url) {
    opener.location.href = url;
}

function decode(encStr) {
 var base64s = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
 var bits; var decOut = ''; var i = 0;
 for(; i<encStr.length; i += 4) {
  bits = (base64s.indexOf(encStr.charAt(i))    & 0xff) <<18 |
         (base64s.indexOf(encStr.charAt(i +1)) & 0xff) <<12 |
         (base64s.indexOf(encStr.charAt(i +2)) & 0xff) << 6 |
          base64s.indexOf(encStr.charAt(i +3)) & 0xff;
  decOut += String.fromCharCode((bits & 0xff0000) >>16, (bits & 0xff00) >>8, bits & 0xff);
 }
 if(encStr.charCodeAt(i -2) == 61) {
  return(decOut.substring(0, decOut.length -2));
 } else if(encStr.charCodeAt(i -1) == 61) {
  return(decOut.substring(0, decOut.length -1));
 } else {return(decOut)};
}

function fotokasten(partnerid, add, thumbnail, width, height, lang) {
    basket = 'http://'+partnerid+'.partner.fotokasten.de/affiliateapi/standard.php?add='+decode(add)+'&thumbnail='+decode(thumbnail)+'&height='+height+'&width='+width+'&language='+lang+'';
	fotobasket=window.open(basket,'fotobasket','width=595,height=250,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,directories=no');
	fotobasket.focus();
}

function bildpartner(partnerid, url, format, referenz) {
	if (!format) format = '';
	if (!referenz) referenz = '';
	fotowin=window.open('http://www.bildpartner.de/upload/picup.php?vcode='+partnerid+'&pic='+decode(url)+'&artnr='+format+'&referenz='+referenz+'','fotowin','width=300,height=250,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no');
	fotowin.focus();
}

function pixacotransfer(imgurl) {
	basket = 'http://www.pixaco.de/services/httpbridge.aspx?smm=cookie&cmd=addimage&url0='+decode(imgurl)+'';
	pixbasket=window.open(basket,'pixbasket','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=310,height=250');
	pixbasket.focus();
}

function pixacozanox(partnerid, imgurl) {
	basket = 'http://ad.zanox.com/ppc/?'+partnerid+'&ULP=[[&smm=cookie&cmd=addimage&url0='+decode(imgurl)+'';
	pixbasket=window.open(basket,'pixbasket','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=310,height=250');
	pixbasket.focus();
}

function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}			

// define a few variables that are required
var menu_usepopups = false;

// #############################################################################
// lets define the browser we have instead of multiple calls throughout the file
var userAgent = navigator.userAgent.toLowerCase();
var is_opera  = (userAgent.indexOf('opera') != -1);
var is_saf    = ((userAgent.indexOf('safari') != -1) || (navigator.vendor == "Apple Computer, Inc."));
var is_webtv  = (userAgent.indexOf('webtv') != -1);
var is_ie     = ((userAgent.indexOf('msie') != -1) && (!is_opera) && (!is_saf) && (!is_webtv));
var is_ie4    = ((is_ie) && (userAgent.indexOf("msie 4.") != -1));
var is_moz    = ((navigator.product == 'Gecko') && (!is_saf));
var is_kon    = (userAgent.indexOf('konqueror') != -1);
var is_ns     = ((userAgent.indexOf('compatible') == -1) && (userAgent.indexOf('mozilla') != -1) && (!is_opera) && (!is_webtv) && (!is_saf));
var is_ns4    = ((is_ns) && (parseInt(navigator.appVersion) == 4));

// catch possible bugs with WebTV and other older browsers
var is_regexp = (window.RegExp) ? true : false;

// #############################################################################
// let's find out what DOM functions we can use
var vbDOMtype = '';
if (document.getElementById) {
	vbDOMtype = "std";
}
else if (document.all) {
	vbDOMtype = "ie4";
}
else if (document.layers) {
	vbDOMtype = "ns4";
}

// make an array to store cached locations of objects called by fetch_object
var vBobjects = new Array();

// #############################################################################
// function to emulate document.getElementById
function fetch_object(idname, forcefetch) {
	if (forcefetch || typeof(vBobjects[idname]) == "undefined") {
		switch (vbDOMtype) {
			case "std": {
				vBobjects[idname] = document.getElementById(idname);
			}
			break;

			case "ie4": {
				vBobjects[idname] = document.all[idname];
			}
			break;

			case "ns4": {
				vBobjects[idname] = document.layers[idname];
			}
			break;
		}
	}
	return vBobjects[idname];
}

// #############################################################################
// function to handle the different event models of different browsers
// and prevent event bubbling
function do_an_e(eventobj) {
	if (!eventobj || is_ie) {
		window.event.returnValue = false;
		window.event.cancelBubble = true;
		return window.event;
	} else {
		eventobj.stopPropagation();
		eventobj.preventDefault();
		return eventobj;
	}
}

// function to register a menu for later initialization
function menu_register(controlid, nowrite, datefield) {
	if (menu_usepopups) {
		menu_doregister(controlid, nowrite, datefield);
	}
}

// Main Javascript Initialization 
function pk_init() {
	if (is_webtv) {
		return true;
	}
	switch (vbDOMtype) {
		case "std": imgs = document.getElementsByTagName("img"); break;
		case "ie4": imgs = document.all.tags("img");             break;
		default:    imgs = false;                                break;
	}
	if (imgs) {
		// set 'title' tags for image elements
		for (var i = 0; i < imgs.length; i++) {
			if (!imgs[i].title && imgs[i].alt != "") {
				imgs[i].title = imgs[i].alt;
			}
		}
	}

	// init registered menus
	if (menu_usepopups && menu_registered.length > 0) {
		for (i in menu_registered) {
			menu_init(menu_registered[i]);
		}

		// close all menus on mouse click
		document.onclick = menu_close;
	}	
	return true;
}

function correctPNG() {
   for(var i=0; i<document.images.length; i++) {
	  var img = document.images[i]
	  var imgName = img.src.toUpperCase()
	  if (imgName.substring(imgName.length-3, imgName.length) == "PNG") {
		 var imgID = (img.id) ? "id='" + img.id + "' " : ""
		 var imgClass = (img.className) ? "class='" + img.className + "' " : ""
		 var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
		 var imgStyle = "display:inline-block;" + img.style.cssText 
		 if (img.align == "left") imgStyle = "float:left;" + imgStyle
		 if (img.align == "right") imgStyle = "float:right;" + imgStyle
		 if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle		
		 var strNewHTML = "<span " + imgID + imgClass + imgTitle
		 + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
	     + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
		 + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
		 img.outerHTML = strNewHTML
		 i = i-1
	     }
      }
   }
   
if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent) {
	MSIEversion = parseFloat(navigator.appVersion.split("MSIE")[1]);
	if (MSIEversion < 7) {
		window.attachEvent("onload", correctPNG);
	}
}