/*
	collapse items
*/

function bestelForm_collapseAfronden(){
	// Rond bestelling af
	if(!document.getElementById('shoppingCartForm')) return false;
	if(!document.getElementById('orderInformationWrapper')) return false;

	var formWrapper = document.getElementById('orderInformationWrapper');
	var rondAfLink = document.getElementById('completeOrder');

	formWrapper.style.display = 'none';	
	if (document.location.href.split('#').length == 2) {
		// from hash
		document.getElementById(document.location.href.split('#')[1]).style.display = 'block';
	}
	
	rondAfLink.onclick = function(){
		if(formWrapper.style.display == 'none'){
			formWrapper.style.display = 'block';
		} else {
			formWrapper.style.display = 'none';
		}
	}
}


function bestelForm_collapseLogin(){
	if(!document.getElementById('customerLogIn')) return false;
	if(document.getElementById('customerLogIn').parentNode.id != 'loginWrapper') return false;
	
	// ik heb een online account
	var inloggenDiv = document.getElementById('customerLogIn');
	var inloggenH4 = document.getElementById('customerLogIn').parentNode.getElementsByTagName('h4')[0];
	inloggenDiv.style.display = 'none';
	inloggenH4.style.cursor = 'pointer';

	inloggenH4.onclick = function(){
		if(inloggenDiv.style.display == 'none'){
			inloggenDiv.style.display = 'block';
		} else {
			inloggenDiv.style.display = 'none';
		}
	}
}

function bestelForm_collapseFactuurAdres(){
	if(!document.getElementById('personalInformationWrapper')) return false;
	if(!document.getElementById('customerInformation')) return false;
	
	// ik heb geen online account
	var geenAccountDiv = document.getElementById('personalInformationWrapper');
	var geenAccountH4 = document.getElementById('customerInformation').getElementsByTagName('h4')[0];
	geenAccountDiv.style.display = 'none';
	geenAccountH4.style.cursor = 'pointer';
	
	geenAccountH4.onclick = function(){
		if(geenAccountDiv.style.display == 'none'){
			geenAccountDiv.style.display = 'block';
		} else {
			geenAccountDiv.style.display = 'none';
		}
	}
}

function bestelForm_collapseOptionalAccountCreation(){
	if(!document.getElementById('optionalAccountCreationWrapper')) return false;
	
	var aanmakenDiv = document.getElementById('optionalAccountCreationWrapper').getElementsByTagName('div')[0];
	var aanmakenH4 = document.getElementById('optionalAccountCreationWrapper').getElementsByTagName('h4')[0];
	aanmakenDiv.style.display = 'none';
	aanmakenH4.style.cursor = 'pointer';
	
	// Account aanmaken? (optioneel)
	aanmakenH4.onclick = function(){
		if(aanmakenDiv.style.display == 'none'){
			aanmakenDiv.style.display = 'block';
		} else {
			aanmakenDiv.style.display = 'none';
		}
	}
}


function bestelForm_collapseChecked(){
	if(!document.getElementById('newsLetter')) return false;
	if(!document.getElementById('newsLetterOptions')) return false;
	
	// checkbox
	var checkbox = document.getElementById('newsLetter');
	var wrapper = document.getElementById('newsLetterOptions');
	wrapper.style.display = 'none';

	if(checkbox.checked == true) wrapper.style.display = 'block';
	
	checkbox.onclick = function(){
		if(checkbox.checked == true){
			wrapper.style.display = 'block';
		} else {
			wrapper.style.display = 'none';
		}
	}

	// radiobuttons
	var radios = new Array();
	radios.push(document.getElementById('birthCard'));
	radios.push(document.getElementById('weddingCard'));
	radios.push(document.getElementById('otherCard'));

	var dateDiv1 = radios[0].parentNode.getElementsByTagName('ul')[0];
	var dateDiv2 = radios[1].parentNode.getElementsByTagName('ul')[0];
	dateDiv1.style.display = 'none';
	dateDiv2.style.display = 'none';

	if(radios[0].checked == true){
		dateDiv1.style.display = 'block';
		dateDiv2.style.display = 'none';
	} else if(radios[1].checked == true){
		dateDiv1.style.display = 'none';
		dateDiv2.style.display = 'block';
	} else {
		dateDiv1.style.display = 'none';
		dateDiv2.style.display = 'none';
	}

	for (var i=0; i < radios.length; i++) {
		radios[i].onclick = function(){
			if(radios[0].checked == true){
				dateDiv1.style.display = 'block';
				dateDiv2.style.display = 'none';
			} else if(radios[1].checked == true){
				dateDiv1.style.display = 'none';
				dateDiv2.style.display = 'block';
			} else {
				dateDiv1.style.display = 'none';
				dateDiv2.style.display = 'none';
			}
		}
	}
}

function bestelForm_collapseAnderAdres(){
	if(!document.getElementById('addressSameAsAccount')) return false;
	if(!document.getElementById('newSendAddress')) return false;
	if(!document.getElementById('newAddress')) return false;
	
	var radios_2 = new Array();
	radios_2.push(document.getElementById('addressSameAsAccount'));
	radios_2.push(document.getElementById('newSendAddress'));

	var otherAddress = document.getElementById('newAddress');
	otherAddress.style.display = 'none';
	if(radios_2[1].checked == true) otherAddress.style.display = 'table';

	for (var i=0; i < radios_2.length; i++) {
		radios_2[i].onchange = function(){
			if(radios_2[0].checked == true){
				otherAddress.style.display = 'none';
			} else if (radios_2[1].checked == true){
				otherAddress.style.display = 'table';
			} else {
				otherAddress.style.display = 'none';
			}
			this.blur();
		}
		radios_2[i].onclick = function(){
			this.blur(); 'none';
		}
	}
}


 /*
  etiketten
*/

initSlider = function(){
	$('#chooseLabel').addClass('jsOn');
	$('#labelChooserWrapper').show();
	$('.helpMessage').show();
	
	createButton('buttonPrevious', 'previous', 'buttonPreviousWrapper');
	createButton('buttonNext', 'next', 'buttonNextWrapper');
	
	$('#labelList li').click(handleLabelClick);
	
	// display/hide elements
	$('#labelList').show();
	$('#labelList').children().hide();
	$('#labelList li:first-child').show();
	$('#labelWrapper img').hide();
	$('#labelWrapper li').hide();


	$('#chooseFont ul li label').click(function(e){
		$(e.currentTarget).children('input').attr('checked', 'checked');
	});


}

createButton = function(id, text, el){
	var button = $('<button type="button"></button>');
	button.html('<span>' + text + '</span>');
	button.attr('id', id);
	button.attr('class', 'sliderButton');
	button.click(handleButtonClick);
	
	$('#' + el).append(button);
}

handleButtonClick = function(){
	var el = this;
	var prevEl,nextEl;
	
	switch(el.id){
		case 'buttonPrevious':
			prevEl = $('#labelList li:visible').prev().attr('id') ? $('#labelList li:visible').prev() : $('#labelList li:last');
			$('#labelList li:visible').hide();
			prevEl.show();
			break;
			
		case 'buttonNext':
			nextEl = $('#labelList li:visible').next().attr('id') ? $('#labelList li:visible').next() : $('#labelList li:first');
			$('#labelList li:visible').hide();
			nextEl.show();
			break;
	}
	
	this.blur();
}

handleLabelClick = function(){
	var el = this;
	var labelID = el.id.replace('li-', '');
	
	$('#labelWrapper li').hide();
	$('#selectedLabel' + labelID).show();
	$('#label-' + labelID).attr('checked', 'checked');

	this.blur();
} /*
  link from cardeditor
*/
flash_editor_handleRegistrationLink = function(){
	var pathname = window.location.pathname;
	window.open('/nl/mijn-account/inloggen/?card='+pathname, '_self');
}

initializeRegistrationLinkFromEditor = function(){
  var documentItemID = 141;
  var documentItem = ( document.getElementById('di' + documentItemID ) );

  if( !documentItem ) return;

  var anchor = documentItem.getElementsByTagName('a');

  if( anchor.length == 0 ) return;

  anchor = anchor[0];

  anchor.setAttribute( 'href', anchor.getAttribute( 'href' ) + window.location.search );
} /*
  handleSubmit
*/

handleSubmit = function(){
  window.location = '?betaalkaart';
}

showAjaxLoader= function(message){
  jQuery('body').css('cursor', 'wait');
  jQuery('<div id="ajaxLoader"><img src="/img/ajaxLoader.gif" /><div class="message">'+message+'</div></div>').appendTo( jQuery('body'));
}

hideAjaxLoader= function(){
  jQuery('body').css('cursor', '');
  jQuery('#ajaxLoader').remove();
} /*
  general functions
*/
function getCookie(name){
	var aCookie = document.cookie.split("; ");
	
	for (var i=0; i < aCookie.length; i++){
		var aCrumb = aCookie[i].split("=");
		if (name == aCrumb[0]){
			return unescape(aCrumb[1]);
		}
	}
	
	return null;
}


/*
  XMLHttpRequest
*/
if (!window.XMLHttpRequest) {
	window.XMLHttpRequest = function() {
		var types = [
			'Microsoft.XMLHTTP',
			'MSXML2.XMLHTTP.5.0',
			'MSXML2.XMLHTTP.4.0',
			'MSXML2.XMLHTTP.3.0',
			'MSXML2.XMLHTTP'
		];

		for (var i = 0; i < types.length; i++) {
			try{
				return new ActiveXObject(types[i]);
			} catch(e) {}
		}
	
		return false; // XMLHttpRequest not supported
	}
}			


/*
  getElementsByClassName	
*/
document.getElementsByClassName = function (needle){
    var s = [document.documentElement || document.body], i = 0, r = [], l = 0, e;
    var re = new RegExp('(^|\\s)' + needle + '(\\s|$)');

    do{
        e = s[i];

        while (e){
            if (e.nodeType == 1){
                if (e.className && re.test(e.className)) r[l++] = e;

                s[i++] = e.firstChild;
            }

            e = e.nextSibling;
        }
    }
	
    while (i--);

    return r;
}


/*
  findPos
*/
function findPos(obj){
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft;
		curtop = obj.offsetTop;
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		}
	}
	return [curleft,curtop];
}


/*
  popups
*/
var aPopups = new Array();
var aModalPopups = new Array();

window.onfocus = function(){
	if(aModalPopups.length != 0){
		aModalPopups[0].focus();
	}
}


var sDefaultFeatures = 'channelmode=0, fullscreen=0, location=0, menubar=0, resizable=0, scrollbars=0, status=0, titlebar=0, toolbar=0';

// create popup
function createPopup(sURL, name, sFeatures, iWidth, iHeight){
	var iLeft	= (screen.availWidth - iWidth) / 2;
	var iTop	= (screen.availHeight - iHeight) / 2;
	
	return window.open(sURL, name, sFeatures + ', width=' + iWidth + ', height=' + iHeight + ', left=' + iLeft + ', top=' + iTop);
}
 /*
  handleBodyLoad
*/

function handleBodyLoad(){
       handleImageFader();

	initTables();

	initInputFocus('qSmallSearch', 'Zoeken');
	initInputFocus('q', 'Zoeken...');
	initInputFocus('newsletterSubscriptionEmailaddress', 'E-mailadres...');

	initInputFocus('invoiceMobilePhoneNumber', 'Mobiel');
	initInputFocus('invoicePhoneNumber', 'Tel thuis');

        /* account aanmaken */
	initInputFocus('mobilePhoneNumber', 'Mobiel');
	initInputFocus('phoneNumber', 'Tel thuis');

	markLinks();
	initMainNav();

	showCardTabs();
	bestelForm_collapseAfronden();
	bestelForm_collapseLogin();
	bestelForm_collapseFactuurAdres();
	bestelForm_collapseOptionalAccountCreation();
	bestelForm_collapseChecked();
	bestelForm_collapseAnderAdres();

  initializeLabelForm();
initializeRegistrationLinkFromEditor();
}


 function handleImageFader(){
	$(".imageFader").each( function(){
		$(this).find("ul").fader({
			'speed': 1000, 	
			'timeout': 4000
		});
	});
} /*
  initFader
*/
  
function initFader(){

	// hide for old browsers
	if(!document.getElementById || !document.createElement || !document.getElementById('albumFader')) return;

	//var li = document.getElementById('listContainer').getElementsByTagName('a');

	window.fadeTime = 3200;

	window.anchors = new Array();
	window.current = 0;
	window.pause = false;
	window.loaded = -1;
	window.loading = true;

	// set opacity to 0 for all images, except the first image 
	anchors = document.getElementById('albumFader').getElementsByTagName('img');

	// get the rest of the images that are loaded in the listBanners pagelet
	//window.alternateImgs = document.getElementById('listContainer').getElementsByTagName('a');
	window.alternateImgs = faderImgList;
	window.totalImages = window.alternateImgs.length + anchors.length;

	anchors[0].style.display = 'block';
	anchors[0].xOpacity = .99;
	anchors[0].onload = function(){

		window.loaded = 0;
		 // if there are more images availbale fade them in
		if(window.alternateImgs.length) addImage(window.alternateImgs[0]);

		setTimeout(fadeBanners, fadeTime);
	}
}

function fadeBanners(){

	if(window.loading){
		setTimeout(fadeBanners, fadeTime);
		return;
	}

	cOpacity = anchors[current].xOpacity;
	nIndex = anchors[current+1]?current+1:0;
	nOpacity = anchors[nIndex].xOpacity;
	cOpacity -= .05;
	nOpacity += .05;

	anchors[nIndex].style.display = 'block';
	anchors[current].xOpacity = cOpacity;
	anchors[nIndex].xOpacity = nOpacity;

	setOpacity(anchors[current]); 
	setOpacity(anchors[nIndex]);

	if(cOpacity<=0){
		anchors[current].style.display = 'none';
		current = nIndex;

		if(window.alternateImgs.length > window.loaded){
			window.loading=true;
			addImage(window.alternateImgs[window.loaded]);
		}

		setTimeout(fadeBanners,fadeTime);
	}else{
		setTimeout(fadeBanners,50);
	}

	function setOpacity(obj){
		if(obj.xOpacity>.99){
			obj.xOpacity = .99;
			return;
		}

		obj.style.opacity = obj.xOpacity;
		obj.style.MozOpacity = obj.xOpacity;
		obj.style.filter = 'alpha(opacity=' + (obj.xOpacity*100) + ')';
	}
}

function addImage(imgSrc){

	var newImage = document.createElement('img');
	newImage.src = imgSrc;
	newImage.xOpacity = 0;

	document.getElementById('albumFader').appendChild(newImage);
	newImage.style.display = 'none';

	newImage.onload = function(){
		window.loading = false;
		window.anchors = document.getElementById('albumFader').getElementsByTagName('img');
	}

	window.loaded++;
}

 /*
  initGlossary (initGlossary2008)
*/

function initGlossary(){
	if(!document.getElementsByClassName('glossaryNav').length) return false;
	var navs = document.getElementsByClassName('glossaryNav');

	for (var i=0; i < navs.length; i++) {
		var navCharLinks = navs[i].getElementsByTagName('span');
		var thisID = navs[i].getAttribute('id');
		var thisChar = thisID.replace('glossaryNav-','');
		
		for (var j=0; j < navCharLinks.length; j++) {
			
			if (navCharLinks[j].className != 'deactivated') {
				
				navCharLinks[j].onclick= function() {
					window.open('#glossaryNav-'+this.innerHTML, '_self');
				};
				/* mark current */
	
				if(navCharLinks[j].innerHTML == thisChar) {
					navCharLinks[j].className= 'active';
				}
			}
		}
	}
}

function initGlossary2008(){}

 	initializeLabelForm = function(){
		
		if( !document.getElementById('chooseLabel') ) return false;
		if( !document.getElementById('chooseLabel').getElementsByTagName('ul') ) return false;
		
		var labelDiv = document.getElementById('chooseLabel');
		var labels = labelDiv.getElementsByTagName('ul')[0].getElementsByTagName('li');
		
		for( var i = 0; i < labels.length ; i++){
			labels[i].className += ' clickable';
			labels[i].onclick = selectLabel;
		}
		
	}
	
	selectLabel = function(e){
		var labels = document.getElementById('chooseLabel').getElementsByTagName('ul')[0].getElementsByTagName('li');
		
		for( var i = 0; i < labels.length ; i++)
			labels[i].className = labels[i].className.replace(' active', '');
				
		this.className += ' active';
	} /*
initInputFocus
*/
function initInputFocus(elemId, elemValue){
	if(!document.getElementById(elemId)) return false;
	var elem = document.getElementById(elemId);
	
       if(elem.value.length == 0) elem.value = elemValue;

	elem.onfocus = function(){
		if(this.value == elemValue){
			this.value = '';
		}
		this.select();
	}
	
	elem.onblur = function(){
		if(this.value == ''){
			this.value = elemValue;
		}
	}
}



/*
initPasswordFocus
*/
function initPasswordFocus(elemId, elemValue){
	if(!document.getElementById(elemId)) return false;
	var elem = document.getElementById(elemId);
	
	elem.value = '';
	elem.style.display = 'none';
	
	var fauxPw = document.createElement('input');
	fauxPw.id = 'Faux'+elemId;
	fauxPw.value = elemValue;
	fauxPw.style.display = 'block';
	elem.parentNode.insertBefore(fauxPw,elem);
	
	fauxPw.onfocus = function(){
		this.blur();
		this.style.display = 'none';
		elem.style.display = 'block';
		elem.focus();
		elem.select();
	}


	elem.onfocus = function(){
		this.select();
	}
	
	elem.onblur = function(){
		if(this.value == ''){
			this.style.display = 'none';
			document.getElementById('Faux'+elemId).style.display = 'block';
			document.getElementById('Faux'+elemId).value = elemValue;
		}
	}
}




 /*
  main-nav menus delay
*/
function initMainNav() {

	//build public node array
	window.navNodes = new Array();
	
	var mainNavNodes = document.getElementById('main-nav').getElementsByTagName('li');
	for (i = 0; i < mainNavNodes.length; i++) {
		window.navNodes.push(mainNavNodes[i]);
	}
	//window.navNodes.push(document.getElementById('toolbar').getElementsByTagName('li')[0]);

	for (i = 0; i < window.navNodes.length; i++) {
		// init out
		window.navNodes[i].className += ' out';
		
		// over
		window.navNodes[i].onmouseover = function(){
			// close others
			blockingElements('hide');

			for (j = 0; j < window.navNodes.length; j++) {
				if (window.navNodes[j] != this) {
					window.navNodes[j].className = window.navNodes[j].className.replace(' wait', ' out');
				}
			}

			this.className = this.className.replace(' wait', ' hover');
			this.className = this.className.replace(' out', ' hover');
			
			if(this.t){
				clearTimeout(this.t);
			}
		}
	
		// out
		window.navNodes[i].onmouseout = function(){
			this.className = this.className.replace(' hover', ' wait');
			
			var _this = this;				
			this.t = setTimeout(function(){
				if(_this.className.match('wait')){
					_this.className = _this.className.replace(' wait', ' out');
					blockingElements('show');
				} 

			}, 600);
		}
	}
}


function blockingElements(visibity){

	var elements = ['noElementsToHide']; // add elementID's to hide here

	if(visibity == 'show'){
		visibity = 'visible';
	} else {
		visibity = 'hidden';
	}
	for (i = 0; i < elements.length; i++) {
		if(document.getElementById(elements[i])){
			document.getElementById(elements[i]).style.visibility = visibity;
		}
	}
}
 /*
	initPopop
*/

function initPopop(popupButton, popupDiv){
	if(!document.getElementById(popupButton)) return false;
	if(!document.getElementById(popupDiv)) return false;
	
	var bttn = document.getElementById(popupButton)
	var popup = document.getElementById(popupDiv)
	popup.className = 'popupOff';
	
	var popHeader = document.createElement('div');
	popHeader.className = 'popupHeader';

	var popClose = document.createElement('a');
	popClose.innerHTML = '<em>Close</em>';
	popClose.href = '#';
	popClose.className = 'popupclose';
	popClose.onclick = function(){
		this.parentNode.parentNode.className = 'popupOff';
		return false;
	}

	popHeader.appendChild(popClose);
	popup.insertBefore(popHeader, popup.firstChild);
	
	bttn.onclick = function(){
		var appName = navigator.appName;
		if(appName == 'Microsoft Internet Explorer'){
			var navVersion = navigator.appVersion.split(";");
			navVersion = navVersion[1].replace('MSIE ', '');
			if(navVersion <= 6.0){
				//IE6
				popup.style.top = '300px';
			} else {
				//IE7+
			}
		} else {
			// != IE
		}
	

		var activePopups = document.getElementsByClassName('popupOn');
		for(var i = 0; i < activePopups.length; i++){
			if(activePopups[i].id != popup.id) activePopups[i].className = 'popupOff';
		}
		if(popup.className == 'popupOff'){
			popup.className = 'popupOn';
		} else {
			popup.className = 'popupOff';
		}
	}
}

 /*
	initTables
*/
function initTables(){
	var rows = document.getElementsByTagName('tr');

	for(var i = 0; i< rows.length; i++){

		//zebra
		if((i % 2) == 0){
			rows[i].className += ' odd';
		}else{
			rows[i].className += ' even';
		}

		//onmouseover highlight row
	/*	rows[i].onmouseover = function(){
			this.className += ' hover';
		}

		rows[i].onmouseout = function(){
			this.className = this.className.replace(' hover', '');
		} */

		//onclick mark row
	/*	var cells = rows[i].cells;
		for(var j = 0; j< cells.length; j++){
			cells[j].onmousedown = function(){
				if(this.parentNode.className.match('markrow')){
					this.parentNode.className = this.parentNode.className.replace(' markrow', '');
				} else {
					this.parentNode.className += ' markrow';
				}
			}
		} */
	}
}

 /*
markLinks
*/
function markLinks(){
	var links = document.getElementsByTagName('a');
	var link, mark;
	
	for(var i = 0; i < links.length; i++){
		link = links[i];
		if(link.getElementsByTagName('img').length == 0){
                        if(link.getAttribute('href') != null) {
			if(link.getAttribute('href').indexOf('mailto:') != -1){
				link.className += ' external mail';
				link.target = '_blank';
				mark = document.createElement('img');
				mark.src = '/data/link-icons/email.png';
				link.appendChild(mark , (link.firstChild));
			}
                        }
		}
		
		if(link.getElementsByTagName('img').length == 0){
			if(link.getAttribute('rel') == 'ext' || link.getAttribute('rel') == 'external'){
	
				link.className += ' external';
				link.target = '_blank';


				hrefEnd = link.getAttribute('href').substring(link.getAttribute('href').length-4);

				if(hrefEnd == '.pdf'){
					mark = document.createElement('img');
					mark.src = '/data/link-icons/pdf.png';
					link.className += ' pdf';
					link.insertBefore(mark , (link.firstChild));
					link.onclick = handleDownloadClick;
					
				}else if(hrefEnd == '.xls'){
					mark = document.createElement('img');
					mark.src = '/data/link-icons/xls.png';
					link.className += ' xls';
					link.insertBefore(mark , (link.firstChild));
					link.onclick = handleDownloadClick;

				}else if(hrefEnd == '.doc'){					
					mark = document.createElement('img');
					mark.src = '/data/link-icons/doc.png';
					link.className += ' pdf';
					link.insertBefore(mark , (link.firstChild));
					link.onclick = handleDownloadClick;
	
				}else if(hrefEnd == '.ppt'){
					mark = document.createElement('img');
					mark.src = '/data/link-icons/ppt.png';
					link.className += ' pdf';
					link.insertBefore(mark , (link.firstChild));
					link.onclick = handleDownloadClick;
					
				}else{
					mark = document.createElement('img');
					mark.src = '/data/link-icons/external.png';
					link.appendChild(mark);
					link.onclick = handleExternalSiteClick;
				}
			}
		}
	}
	
	/*links = document.getElementById('content').getElementsByTagName('a');
	
	for(var i = 0; i < links.length; i++){
		if(links[i].getAttribute('href')){
			oHref = document.createElement('span');
			oHref.className = 'print';
			oHref.appendChild((document.createTextNode(' [' + links[i].href + ']')));
			
			links[i].appendChild(oHref);
		}
	}*/

	mark = null;
	href = null;
	link = null;
	links = null;


}

function handleDownloadClick(){
	if(typeof pageTracker._trackPageview == 'function'){
		pageTracker._trackPageview(this.href);
	}
}

function handleExternalSiteClick(){
	if(typeof pageTracker._trackPageview == 'function'){
		pageTracker._trackPageview('/externalSites/' + this.href);
	}
}

  	

/*
  pagepeel
*/
function pagePeelEntity(){
	this.small = document.createElement('div');
		this.small.id = 'smallpagePeelEntityWrapper';
	
	this.large = document.createElement('div');
		this.large.id = 'largepagePeelEntityWrapper';
	
	document.body.appendChild(this.small);
	document.body.appendChild(this.large);
}

pagePeelEntity.prototype.init = function(){
	var _this = pagePeel;
	
	
	// set positions
	_this.small.style.position = 'absolute';
	_this.small.style.right = '0px';
	_this.small.style.top = '0px';
	_this.small.style.zIndex = 999;
	
		
	_this.small.style.display = 'block';
	_this.small.style.width = '100px';
	_this.small.style.height = '100px';
	
	// set positions
	_this.large.style.position = 'absolute';
	_this.large.style.right = '0px';
	_this.large.style.top = '-1000px';
	_this.large.style.zIndex = 999;
	
	_this.large.style.display = 'block';
	_this.large.style.width = '780px';
	_this.large.style.height = '600px';
	
	
	// append flash objects
	var so;
	so = new SWFObject('/scripts/small.swf?image=' + this.smallImage, 'small', '100', '100', '6', '#ffffff');
		so.addParam('wmode', 'transparent');
		so.addParam('salign', 'T');
		so.addParam('menu', 'false');
		so.addParam('quality', 'high');
		so.write('smallpagePeelEntityWrapper');	
	
		so = new SWFObject('/scripts/large.swf?image=' + this.largeImage + '&link=' + this.link , 'large', '780', '600', '6', '#ffffff');
		so.addParam('wmode', 'transparent');		
		so.addParam('salign', 'T');
		so.addParam('menu', 'false');
		so.addParam('quality', 'high');
		so.write('largepagePeelEntityWrapper');	
	
}

pagePeelEntity.prototype.setLink = function(link){ this.link = link; }
pagePeelEntity.prototype.setSmallImage = function(image){ this.smallImage = image; }
pagePeelEntity.prototype.setLargeImage = function(image){ this.largeImage = image; }

pagePeelEntity.prototype.open = function(){
	var _this = pagePeel;
	
	_this.small.style.top = '-1000px';
	_this.large.style.top = '0px';
}

pagePeelEntity.prototype.close = function(){
	var _this = pagePeel;
	
	_this.small.style.top = '0px';
	_this.large.style.top = '-1000px';
}
 /**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;

 /*
	showCardTabs
*/

function showCardTabs(){
	if(!document.getElementsByClassName('tab').length) return false;
	if(!document.getElementById('showTabs')) return false;

	var links = document.getElementsByClassName('tabnavigation')[0].getElementsByTagName('a');
	var tabs = document.getElementsByClassName('tab');
	
	for (var i=0; i < tabs.length; i++){
		tabs[i].style.display = 'none';
		links[i].parentNode.id = 'link-'+links[i].href.split('#')[1];
		links[i].parentNode.className = '';
	}

	// if no tab is open
	if (document.location.href.split('#').length == 2) {
		// from hash
		document.getElementById(document.location.href.split('#')[1]).style.display = 'block';
		document.getElementById('link-'+document.location.href.split('#')[1]).className = 'active';
	}else{
		// no hash & first tab
		tabs[0].style.display = 'block';
		links[0].parentNode.className = 'active';
	}

	for (var i=0; i < links.length; i++){
		links[i].onclick = function(){
			var tab = this.href.split('#')[1];
			
			// add tab to address bar
			document.location.href = document.location.href.split('#')[0] + '#' + tab;
			
			var links = document.getElementsByClassName('tabnavigation')[0].getElementsByTagName('a');
			var tabs = document.getElementsByClassName('tab');
			
			for (var i=0; i < tabs.length; i++){
				tabs[i].style.display = 'none';
				links[i].parentNode.className = '';
			}
			
			this.parentNode.className = 'active';
			document.getElementById(tab).style.display = 'block';
			
			return false;
		}
	}
}


