/*
 * $Id: common.js 216 2009-10-16 14:17:34Z joris $
 */
function newWindow(mypage,myname,w,h,features) {
	if(screen.width){
		var winl = (screen.width-w)/2;
		var wint = (screen.height-h)/2;
	}
	else{winl = 0;wint =0;}
	if (winl < 0) winl = 0;
	if (wint < 0) wint = 0;

	var settings = 'height=' + h + ',';
	settings += 'width=' + w + ',';
	settings += 'top=' + wint + ',';
	settings += 'left=' + winl + ',';
	settings += features;
	win = window.open(mypage,myname,settings);
	win.window.focus();
}

$(function() {
	var searchField = $('input#headerSearch');

	if (searchField.length > 0) {
		wipeTextOnFocus(searchField, 'Zoek in de website');
	}

	var ss = new SlideShow();
	ss.addSlides($('div.bannerContainer div.banner'));
	ss.start();

//	$('div.processedContent div.block div.contentHomeText').each(function() {
//		addLink(this);
//	});

//	$('div.processedContent div.block div.contentHomeTextText').each(function() {
//		addLink(this);
//	});

//	$('div.processedContent div.block').each(function() {
//		addLinkImageText(this);
//	});

//	$('div.section div.block div.contentHomeText').each(function() {
//		addLink(this);
//	});

//	$('div.section div.block div.contentHomeTextText').each(function() {
//		addLink(this);
//	});

//	$('div.section div.block').each(function() {
//		addLinkImageText(this);
//	});

});

function wipeTextOnFocus(input, defaultValue) {
	var clone = input.clone();

	clone.attr('name', '');
	clone.attr('id', '');
	clone.attr('value', defaultValue);
	clone.css('display', 'none');

	var blur = function(e) {
		if (input.val() == '') {
			clone.css('display', '');
			input.css('display', 'none');
		}
	};
	blur();

	var focus = function(e) {
		clone.css('display', 'none');
		input.css('display', '');
		input.focus();
	};


   input.blur(blur);
   clone.focus(focus);

   clone.insertBefore(input);
}



function copyAddress(frm) {
	var elems = new Array('adres', 'huisnummer', 'postcode', 'plaats', 'land');
	while (elem = elems.pop()) {
		var element  = 'shop[' + elem + ']';
		var element2 = 'shop[' + elem + '2]';
		frm.elements[element2].value = frm.elements[element].value;
	}
}
