
		$(window).ready(function(){
			var newwidth = $(document).width();
			
			var isiPad = navigator.userAgent.match(/iPad/i) != null;
			if(isiPad){
				$('#menuxz').width(newwidth+'px');
			}
		
			var hght  = parseInt($(document).height());
			var hght2 = parseInt($('#contentright').height());
			if(hght>hght2){
				if(thispage!='home'){
					$('#contentright').css('height',hght);
				}
			} 
			
			var hght  = parseInt($(window).height())/2;
			var wdth  = parseInt($(window).width())/2;
			$('#subpop').css("left",wdth - parseInt($('#subpop').width())/2 +"px");
			$('#subpop').css("top",hght -  parseInt($('#subpop').height())/2 +"px");
			$('#subpop').fadeIn();
		});

		function scrollIt(id,amt,item,max){
			$('#'+id).scrollTo({ top:0, left:amt},600);
			
			for(i=0;i<max;i++){
				$('#'+id+i).html('');
			}			
			$('#'+id+item).html("<img src='http://www.challenge.nl/img/_2011/bolletje-zwart.gif' border=0 style='border:none;margin:0;padding:0;'>");
		}

		Shadowbox.init();


/** SEARCH BOX **/		
		function doloadit2(val){
			if(val.length>3){
				/*
				$("#quickresults").css("opacity","0");
				$("#quickresults").height("auto");
				*/
				
				var html = $.ajax({
 			 		url: "/pages_new/ajaxparser.php?srch="+val,
  					async: false
 				}).responseText;
 				 				
 				$("#quickresults").html(html);
 				$("#quickresults").slideDown();

 				
 				/*
 				endheight=$("#quickresults").height();	
 				$("#quickresults").height(0);
 				$("#quickresults").animate({	 
 					height: endheight,
 					opacity: 1.00
 				}, 500, function() {});
				*/
 			} else {
				/* $("#quickresults").css("opacity","0"); */
				$("#quickresults").slideUp();
 			}
		}
		function docloseit(){
			$("#quickresults").animate({	 
 					height: 0,
 					opacity: 0.00
 				}, 500, function() {});
		}
		
		var lastsearch='';
		function doloadit3(val,type){
			if((val.length>3 && val!=lastsearch) || (type=='format' && val!=lastsearch)){
				var html = $.ajax({
 			 		url: "/pages_new/ajaxparser2.php?srch="+val+"&type="+type,
  					async: false
 				}).responseText;

 				lastsearch = val;
 				$("#searchresults").html(html);
 				if($("#searchresults").css("display")=='none'){
	 				$("#searchresults").slideDown();
	 			}
 			} 
		}		
		
		function doloadit4(val){
			var html = $.ajax({
 				url: "/pages_new/ajaxparser3.php?srch="+val,
  				async: false
 			}).responseText;

			$("#searchresults").css('display','none');
 			$("#searchresults").html(html);
	 		$("#searchresults").fadeIn();
		}		


/** MISC STUFF **/
		function rowcolor(item,color){
			document.getElementById(item).style.backgroundColor=color;
		}
		function swappic(name,newpic){
			document.images[name].src=newpic;
		}
	
		function swapimg(name, newnr){
			newname="img2/"+name+newnr+".gif";
			document.images[name].src=newname;
		}
		function getpage(urrol){
			document.location.href=urrol;
		}
		function disco_light(target){
			document.getElementById(target).style.backgroundColor="#cccccc";
		}
		function disco_dark(target,color){
			document.getElementById(target).style.backgroundColor=color;
		}
		function disco_getpage(nr){
			document.location.href="<?php echo $INDEX; ?>?id="+nr;
		}
		function bookmarksite(title, url){
			if (document.all)
				window.external.AddFavorite(url, title);
			else if (window.sidebar)
				window.sidebar.addPanel(title, url, "")
		}
		function settitle(titel){
			document.title='Challenge Records Int. - '+titel;
		}

		function showlist(ding){
			document.getElementById('tracklist').style.display='none';
			document.getElementById('description').style.display='none';
			document.getElementById('quotes').style.display='none';
			document.getElementById('news').style.display='none';
			document.getElementById(ding).style.display='';
		}
		function showlist2(ding){
			document.getElementById('biography').style.display='none';
			document.getElementById('discography').style.display='none';
			document.getElementById('news').style.display='none';
			document.getElementById('video').style.display='none';
			document.getElementById(ding).style.display='';
		}

		function textlist(){
			document.getElementById('textlist').style.display=''; document.getElementById('piclist').style.display='none';
		}
		function piclist(){
			document.getElementById('textlist').style.display='none'; document.getElementById('piclist').style.display='';
		}

		function getIt(actioni, item, repage){
			document.forms.shopform.actioni.value=actioni;
			document.forms.shopform.item.value=item;
			document.forms.shopform.repage.value=repage;
			if(actioni!=""){
				document.forms.shopform.reload.value="yes";
			}
			document.forms.shopform.submit();
		}	
		
		function dropdownrun(group,veld){
			x = document.quicksearch.elements[veld].selectedIndex;
			y= document.quicksearch.elements[veld].options[x].value;
			
			if (y == ""){
			} else {
				type="group";
				if(group=="artists"){	type="id";	}
				document.location.href="http://www.challenge.nl/"+group+"/"+y;
			}
		}
		
		searchstatus='closed';
		
		function openSearch(){
			if(searchstatus=='open'){
				closeSearch();
			} else {
				a=document.getElementById('searchbar').style.height;
				a=a.replace("px","");
				if(a=="" || a==0){ a=1; }
				a=parseInt(a);
				if(a<93){
					a=a*1.5;
					a=Math.round(a);
					document.getElementById('searchbar').style.height=a+'px';
					setTimeout("openSearch()",50);
				} else {
					document.getElementById('searchbar').style.height='93px';
					searchstatus="open";
				}
			}
		}
		
		function closeSearch(){
			document.getElementById('quickresults').style.display='none';
			a=document.getElementById('searchbar').style.height;
			a=a.replace("px","");
			if(a==""){ a=75; }
			a=parseInt(a);
			if(a>1){
				a=a/1.5;
				a=Math.round(a);
				document.getElementById('searchbar').style.height=a+'px';
				setTimeout("closeSearch()",50);
			} else {
				document.getElementById('searchbar').style.height='0px';
				searchstatus='closed';
			}
		}		
		
		function shippingpopup() {
			day = new Date();
			id = day.getTime();
			eval("page" + id + " = window.open('http://www.challenge.nl/pages_new/shippingpopup.php', '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=400,height=300,left = 690,top = 475');");
		}		
		
		function showSearchOption(ding){
			if($("#searchoptions").css("display")=='none'){
			 	$("#searchoptions").fadeIn();				
			}
		 	$("#searchresults").css("display","none"); 				
			for(i=0;i<8;i++){
				$('#option'+i).css("display","none");
			}
			$('#option'+ding).fadeIn();
		}	
		
		
		function notify(val){
			document.forms['notifyform'].albumserial.value = val;
			var top = $("html").scrollTop();
			$('#notify').css('top',top);
			$('#notify').fadeIn();
		}
		
		function closenotify(){
			document.forms['notifyform'].albumserial.value = '';
			$('#notify').fadeOut();
		}		
		
		function validateNotify(){
			var albumserial = document.forms['notifyform'].albumserial.value;
			var email = document.forms['notifyform'].email.value;
			var html = $.ajax({
 				url: "/pages_new/notify.php?albumserial="+albumserial+"&email="+email,
  				async: false
 			}).responseText;
			
			if( html.substr(0,5)=="error" ){
				html = html.substr(5);
				$('#notifytxt').html(html);
			} else {
				$('#notifyfulltxt').html(html);
			}
		}
		
		function showDiv(id){
			if($('#'+id).css('display')=='none'){
				$('#'+id).slideDown();
			} else {
				$('#'+id).slideUp();
			}
		
		}

	    function validateEmail(elementValue){  
       		var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;  
       		return emailPattern.test(elementValue);  
     	}  
     
		function submitSubscription(){
			error='';
			a=document.forms['subscribepopup'];

			a1=a.news_jazz.checked;
			a2=a.news_klassiek.checked;
			a3=a.news_pop.checked;
			a4=a.sn_email.value;
	
			if(a1=='' && a2=='' && a3==''){
				error += 'Please pick a genre. ';
			}

			if(validateEmail(a4)==false){
				error += 'Please use a valid email address. ';
			}
	
			if(error==''){
				var html = $.ajax({
 			 		url: "/pages_new/subscribe-popup.php?a1="+a1+"&a2="+a2+"&a3="+a3+"&a4="+a4,
  					async: false
 				}).responseText;
 				
 				$('#subpop').html(html);
 				
			} else {
				alert(error);
			}			
		
		}
