image1 = new Image();
image1.src = "img/lineup/3ko-h.png";
image2 = new Image();
image2.src = "img/lineup/burn-h.png";
image3 = new Image();
image3.src = "img/lineup/sadhu-h.png";
image4 = new Image();
image4.src = "img/lineup/tripple-h.png";

function in_array (needle, haystack, argStrict) {
    var key = '', strict = !!argStrict; 
    if (strict) {
        for (key in haystack) {
            if (haystack[key] === needle) {
                return true;            }
        }
    } else {
        for (key in haystack) {
            if (haystack[key] == needle) {
            	return true;
            }
        }
    }
     return false;
}

function  getget(params, name) {
  var i = params.indexOf(name + '=');
  if (i == -1) {
    return false;
  }
  var r = params.substr(i + name.length + 1, params.length - i - name.length - 1);
  i = r.indexOf('&');
  if (i != -1) {
    r = r.substr(0, i);
  }
  return r.replace(/\+/g, ' ');
}


function getFlashMovieObject(movieName)
{
  if (window.document[movieName]) 
  {
      return window.document[movieName];
  }
  if (navigator.appName.indexOf("Microsoft Internet")==-1)
  {
    if (document.embeds && document.embeds[movieName])
      return document.embeds[movieName]; 
  }
  else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
  {
    return document.getElementById(movieName);
  }
}

function ShowHeader(){
	makePOSTRequest("line-up", "load.php", "function=showheader");
}

function ShowTracks(offset){
	makePOSTRequest("latest_tracks", "load.php", "function=showtracks&offset="+offset);
}

function SwitchToArtist(artist_name)
{
	//alert(artist_name);
	if(artist_name){
	if( in_array (artist_name, Artists)){
      var flashMovie=getFlashMovieObject("kabaal-header");
      flashMovie.SetVariable("/:sel", artist_name);
      }
    }
}


function Page(page,params){
	if (params){
	 var artist_id = getget(params, "artist");
	  if (artist_id){
		SwitchToArtist(Artists[artist_id]);
	  } 
	  var product_id = getget(params, "product");
	  if(product_id){
	  	var artist_name = Products[product_id];
	  	SwitchToArtist(artist_name);
	  } 
	}
	makePOSTRequest("content", "load.php", "function=page&page="+page+"&"+params);
	makePOSTRequest2("menu", "load.php", "function=menu&page="+page);
}

function Play(id){
	makePOSTRequest("player", "load.php", "function=player&id="+id);
	if(id!='random'){
	makePOSTRequest2("playinfo", "load.php", "function=playinfo&id="+id);
	}
}

function Stop(){
	makePOSTRequest("player", "load.php", "function=player&id=stop");
	makePOSTRequest2("playinfo", "load.php", "function=playinfo&id=stop");
}

function openYouTube(id){
	slideup("nfo_"+id);
	slidedown("div_"+id);
	makePOSTRequest("player", "load.php", "function=player&id=stop");
	makePOSTRequest2("playinfo", "load.php", "function=playinfo&id=stop");
	makePOSTRequest3("div_"+id, "youtube.php", "id="+id);
}
function closeYouTube(id){
	slidedown("nfo_"+id);
	slideup("div_"+id);
	makePOSTRequest3("div_"+id, "youtube.php", "id=none");
}

function Album(){
	var album = document.albumselect.album.value;
	frames['album'].location.href = 'gallery.php?album='+album;
}
function Minus(product_id){
	makePOSTRequest("content", "load.php", "function=page&page=shop&minus="+product_id);
}
function Plus(product_id){
	makePOSTRequest("content", "load.php", "function=page&page=shop&plus="+product_id);
}
function ATC(product_id){
	makePOSTRequest("content", "load.php", "function=page&page=shop&addtocart="+product_id);
}
function DFC(product_id){
	makePOSTRequest("content", "load.php", "function=page&page=shop&delfromcart="+product_id);
}
/* shout */
function Jump(id){
 if (id!='nill'){
   document.location='index.php?page=shout&target=' + id;
   }
 }
 
 
 function Shout(){
 	var err=0;
 	var target = document.forms.shoutfrm.target.value;
 	var name = document.forms.shoutfrm.name.value;
 	if(name==''){
 		alert('Vul aub je naam in!');
        err=1;
 	}
 	var shout = document.forms.shoutfrm.shout.value;
 	if(shout==''){
 		alert('Je moet natuurlijk wel iets zeggen...');
 		err=1;
 	}
 	var auth_code = document.forms.shoutfrm.auth_code.value;
 	if(auth_code==''){
 		alert('Vul aub de verificatiecode in.');
 		err=1;
 	}
 	if(err==0){
 	    makePOSTRequest("content", "load.php", "function=page&page=shout&target="+target+"&name="+name+"&shout="+shout+"&auth_code="+auth_code);	
 	}
 	
 }