var $j = jQuery.noConflict();

$j(document).ready(function() {
	
	$j(".moderne-meesters-overzicht li").hover(
	  function () {
	    $j(this).addClass("show");
	  },
	  function () {
	    $j(this).removeClass("show");
	  }
	);
	$j(".overzicht li").hover(
	  function () {
	    $j(this).addClass("show");
	  },
	  function () {
	    $j(this).removeClass("show");
	  }
	);
	
	// live concerten 2  ------------------ BEGIN 
	$j(".lc-interaction li").hover(
	  function () {
	    $j(this).addClass("show");
	  },
	  function () {
	    $j(this).removeClass("show");
	  }
	);
	// live concerten 2  ------------------ END 
	
	$j(function(){ // horizontal scroll on small thumbnails product detail
		$j("div.scrollable").scrollable();
	});
	
	$j(function() { //change large thumbnail on rollover on small thumbnails product detail
		   $j(".scrollable .items a").live("mouseover",function(){
		//$j(".scrollable .items a").live("mouseover",function(){
			$j(".details #image").attr('src',this.getAttribute("rel")); // change img src
			$j(".details .enlarge").attr('href',this.getAttribute("href")); // change a href
		});
	});
	
	$j(function() { // Avoid the browser following the link
		$j("div.scrollable .items a").click(function (){
			return false;
		});
	});
	
	$j(function() { // enlarge image notice on rollover on large thumbnail product detail
		$j(".details .enlarge").hover(function() {
			$j(".details .enlarge").css({'background-position' : '-75px -280px'});
		},function() { 
			$j(".details .enlarge").css({'background-position' : '0 0'});
		});
	});
	
	$j(function() { // lightbox
		$j('.details .enlarge').lightBox();
	});
	
	$j(function() { // add footer nav to lightbox
		$j(".more-views").clone().prependTo("#footer-nav");
	});
	
	$j(function() { // shoppingcart show and hide
		$j(".shoppingcart .header-expand").click(function () {			
			$j("#cart-sidebar").show();
			$j(".extra-links").show();
			$j(".shoppingcart-footer .longfooter").show();
			$j(".shoppingcart-footer .shortfooter").hide();
			$j(".shoppingcart-header").css({'background' : 'transparent url(/skin/frontend/default/vk/images/winkelwagen/winkelwagen_header.png) no-repeat 0 0'});
			$j(".shoppingcart-content").css({'background' : 'transparent url(/skin/frontend/default/vk/images/winkelwagen/winkelwagen_bg.png) repeat-y 0 0'});
			$j(".header-expand").css({'display' : 'none'});
		});
		
		$j(".shoppingcart .header-contract").click(function () {
			$j("#cart-sidebar").hide();
			$j(".extra-links").hide();
			$j(".shoppingcart-footer .longfooter").hide();
			$j(".shoppingcart-footer .shortfooter").show();
			$j(".shoppingcart-header").css({'background' : 'transparent url(/skin/frontend/default/vk/images/winkelwagen_header.png) no-repeat 0 0'});
			$j(".shoppingcart-content").css({'background' : 'transparent url(/skin/frontend/default/vk/images/winkelwagen_bg.png) repeat-y 0 0'});
			$j(".header-expand").css({'display' : 'block'});
		});
	});
	
	function externalLinks() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
	var anchor = anchors[i];
	if (anchor.getAttribute("href") &&
	anchor.getAttribute("rel") == "external")
	anchor.target = "_blank";
	}
	}
	window.onload = externalLinks;
	
	$j(function() { // hide video samples by default
		$j(".videoContainerBox").hide();
		$j("#containerBox_v1").show();
	});
	
	/*$j(function() { // show video sample
		$j(".video-fragment-option").click(function () {
			var hiddenVideoId = this.value;
			$j(".videoContainerBox").css({'display' : 'none'});
			$j("#containerBox_v"+hiddenVideoId).css({'display' : 'block'});
		});	
	});
	*/
	
	$j(function() { // mail a friend hide
		$j(".mail-a-friend-container").css({'display' : 'none'});
	});
	
	$j("#sendfriend-button").click(function(){
		openSendFriend();
	});
	
	$j(function() { // make rating
		$j("#product-review-table").html('<li class="rate1" ><input type="radio" value="1" id="Quality_1" name="ratings[1]"/><li class="rate2" ><input type="radio" value="2" id="Quality_2" name="ratings[1]"/><li class="rate3" ><input type="radio" value="3" id="Quality_3" name="ratings[1]"/><li class="rate4" ><input type="radio" value="4" id="Quality_4" name="ratings[1]"/><li class="rate5" ><input type="radio" value="5" id="Quality_5" name="ratings[1]"/></li><li id="rating-phrase"></li>');
	});

	$j(function() {
		var url = document.location.href;
		var parts = url.split("#");
		if (parts.length>1) {
			if (parts[parts.length-1] == "sendFriend") openSendFriend();
		}
	});

	$j("#product-review-table li").mouseout(function () {
		$j("#product-review-table li").each(function(counter){
			$j(this).removeClass('tempstar');			
		});
		$j("#rating-phrase").html("");
		$j(this).parent().removeClass('hover');
	});

	$j("#product-review-table li").mouseover(function () {
		var thisId = $j(this).attr('class').substr(4,1);
		$j(this).parent().addClass('hover');
		$j("#product-review-table li").each(function(counter){	
			var intIndex = counter+1;
			if (intIndex<=thisId) {
				$j(this).addClass('tempstar');
			} else {
				$j(this).removeClass('tempstar');			
			}
			if  (intIndex==thisId) {
				var ratingPhrase ="";
				if(thisId==1){
					var ratingPhrase ="slecht";
				} else if(thisId==2){
					var ratingPhrase ="matig";
				} else if(thisId==3){
					var ratingPhrase ="voldoende";
				} else if(thisId==4){
					var ratingPhrase ="goed";
				} else if(thisId==5){
					var ratingPhrase ="uitmuntend";
				}
				
				$j("#rating-phrase").html(ratingPhrase);
			}
		});	
	});
		
		
	$j(function() { // make rating
		$j("#product-review-table li").click(function () {
			var thisId = $j(this).attr('class').substr(4,1);

			// Nothing should happen when visitor clicks on the rating phrase
			if("rating-phrase"==$j(this).attr('id')){
				return false;
			}
						
			// if this has a class like rate1 and is greater or smaller then the star clicked on..
			$j("#product-review-table li").each(function(counter){
				var intIndex = counter+1;
				// first set the star to not selected
				$j(this).html('<input type="radio" value="'+intIndex+'" id="Quality_'+intIndex+'" name="ratings[1]" />');

				if (intIndex<=thisId) {
					$j(this).addClass('permstar');
				} else {
					$j(this).removeClass('permstar');			
				}
				
				var ratingPhrase ="";
				
				if(thisId==1){
					var ratingPhrase ="slecht";
				} else if(thisId==2){
					var ratingPhrase ="matig";
				} else if(thisId==3){
					var ratingPhrase ="voldoende";
				} else if(thisId==4){
					var ratingPhrase ="goed";
				} else if(thisId==5){
					var ratingPhrase ="uitmuntend";
				}
				$j("#rating-phrase").html(ratingPhrase);
					
			});
		
			// set one of the stars as selected
			$j(this).html('<input type="radio" value="'+thisId+'" id="Quality_'+thisId+'" name="ratings[1]" checked="checked"/>');
		});
	});

	$j('.play-audio-button').click(function() {
		var number = $j(this).attr('rel');
		var player = document.getElementById('ply'+number);
		player.sendEvent("PLAY","true");
	});
	
	
		
// button voor aantal producten aanpassen in winkelwagen
	$j(".count input").keypress(function (){
		
		$j(".count button").css({'display' : 'none'});	

		$j(this).siblings().css({
			'background' : 'transparent url(/skin/frontend/default/vk/images/btn-aanpassen.gif) center center no-repeat',
			'width':'77px',
			'height':'21px',
			'display':'block',
			'margin':'18px 0 0 8px',
			'clear':'left'
		});
	});
	
		
});
function loadVideo(index,value){
	var hiddenVideoId = index + 1;
	$j(".videoContainerBox").hide();
	$j("#containerBox_v"+hiddenVideoId).show();
}

function openSendFriend() {
	$j(".mail-a-friend-container").css({'display' : 'block'});
	$j(".product-specs-container").css({'display' : 'none'});
	$j(".reviewform-container").css({'display' : 'none'});
	
	$j("#sendfriend-button").css({
		'background' : '#f0eae2 url(/skin/frontend/default/vk/images/detail_page_mail_active.png) repeat-x scroll left top',
		'border-left':'1px solid #CFCFCF',
		'border-right':'1px solid #CFCFCF'
	});			
	$j("#sendfriend-button a").css({
		'text-decoration':'none',
		'cursor':'default',
		'color':'black'
	});
	
	$j("#reviews-button").css({
		'background' : 'transparent url(/skin/frontend/default/vk/images/detail_page_inactive_left.png) repeat-x scroll left bottom',
		'border-left':'none',
		'border-right':'none'
	});
	$j("#reviews-button a").css({
		'text-decoration':'underline',
		'color':'#003399'
	});
	
	$j("#product-info-button").css({
		'background' : 'transparent url(/skin/frontend/default/vk/images/detail_page_inactive_left.png) repeat-x scroll left bottom',
		'border-left':'none',
		'border-right':'none',
		'cursor':'pointer'
	});
	$j("#product-info-button a").css({'text-decoration':'underline',
		'color':'#003399',
		'cursor':'pointer'
	});
	
	var myAttr = $j("#product-info-button a").attr("href")+"#sendFriend";
	window.location = myAttr;
	
	return false;
}
function showpage(b){
	if(b == 1)
	{
		$j('.breadcrumb').html("<a title=\"Ga naar Home-pagina\" href=\"http://vk-new.hidev.nl/\">Home</a> → <a href=\"http://vk-new.hidev.nl/moderne-meesters.html\" class=\"last-crumb\">De 20 beroemdste architecten</a>");
		$j("#front").show();
		$j("#page").hide();
	}
	else
	{
		$j('.breadcrumb').html("<a title=\"Ga naar Home-pagina\" href=\"http://vk-new.hidev.nl/\">Home</a> → <a href=\"#\" onclick=\"showpage(1); return false;\">De 20 beroemdste architecten</a> → <a href=\"#\" return false;\" class=\"last-crumb\">Complete collectie</a>");
		$j("#front").hide();
		$j("#page").show();
		// document.getElementById('front').style.display = 'none';
		// document.getElementById('page').style.display = 'block';
	}
}

function ticketbox(source) {
	document.getElementById('display').innerHTML = '<div id="overflow"></div>'+
	'<div id="displaybox"><div id="displayborder"><span id="icon-close" onclick="hidelayer()"></span>'+
	'<iframe name="Volkskrant_ticketshop" src="'+source+'" width="500" height="480" frameborder="0" allowtransparency="true">'+
	'</div></div>';
	document.getElementById('display').style.display = 'block';
	new Effect.ScrollTo('display');
}
function hidelayer() {
	document.getElementById('display').innerHTML = '';
	document.getElementById('display').style.display = 'none';
}
