Ext.onReady(function() {
	//quicktips op de icoontjes
	Ext.QuickTips.init();
	
	Ext.select('img[name^=qtip]').on('mouseover', function()
	{
		if (this.name=='qtipsum')
			Ext.QuickTips.register({title: "Samenvatting", text: "<img src='/img/filesmall.png' style='padding-right: 3px; float: left' alt='samenvatting icoon' />Klik hier voor een complete samenvatting van de film, inclusief acteurs/regisseurs en de door Video-Palace klanten toegekende rating.<div style='clear: both'>&nbsp;</div>", target: this, autoHide:true});
		else if (this.name=='qtipspeaker')
			Ext.QuickTips.register({title: "Audio trailer", text: "<img src='/img/speakersmall.png' style='padding-right: 3px; float: left' alt='audio icoon' />Klik hier voor het beluisteren van de audiotrailer.<div style='clear: both'>&nbsp;</div>", target: this, autoHide:true});
		else if (this.name=='qtipstrip')
			Ext.QuickTips.register({title: "Video trailer", text: "<img src='/img/filmstripsmall.png' style='padding-right: 3px; float: left' alt='video icoon' />Bekijk de trailer van deze film.<div style='clear: both; width: 100%'>&nbsp;</div>", target: this, autoHide:true});
		else if (this.name=='qtipcart')
			Ext.QuickTips.register({title: "Boodschappenlijstje", text: "<img src='/img/shoppingcartsmall.png' style='padding-right: 3px; float: left' alt='winkelkarretje icoon' />Voeg deze film toe aan uw boodschappenmandje.<div style='clear: both'>&nbsp;</div>", target: this, autoHide:true});
		else if (this.name=='qtipwishlist')
			Ext.QuickTips.register({title: "Verlanglijstje", text: "<img src='/img/wishlist.png' style='padding-right: 3px; float: left' alt='verlanglijstje icoon' />Voeg deze film toe aan uw verlanglijstje en wordt op de hoogte gehouden van de beschikbaarheid ervan.<div style='clear: both'>&nbsp;</div>", target: this, autoHide:true});
		else if (this.name=='qtipdangercookie')
			Ext.QuickTips.register({title: "Opgelet", text: "<img src='/img/excl32.png' style='padding-right: 3px; float: left' alt='opgelet icoon' />U heeft ervoor gekozen permanent aangemeld te blijven, deze optie kan een gevaar betekenen indien u zich op een publieke computer bevindt.<div style='clear: both'>&nbsp;</div>", target: this, autoHide:true});
		else if (this.name=='qtipsettingswish')
			Ext.QuickTips.register({title: "Instellingen", text: "<img src='/img/tools32.png' style='padding-right: 3px; float: left' alt='opgelet icoon' />Verander uw instellingen en wordt op de hoogte gehouden wanneer een film op uw verlanglijstje beschikbaar wordt!<div style='clear: both'>&nbsp;</div>", target: this, autoHide:true});
		else if (this.name=='qtipsilverlight')
			Ext.QuickTips.register({title: "Silverlight", text: "<img src='/img/silverlight64.png' style='padding-right: 3px; float: left' alt='opgelet icoon' />Klik hier om Microsoft Silverlight te installeren (ongeveer 30 seconden) en geniet van een interactievere site.<div style='clear: both'>&nbsp;</div>", target: this, autoHide:true});
	});
	
	
	Ext.select('a[name^=filtertitel]').on('click', function()
	{
		var elements = Ext.select('a[name^=filtertitel]');
		
		for (var i = 0; i < elements.getCount(); i++)
		{
			//bold in ie, 700 in opera en ff
			if (elements.item(i).dom.id != this.id)
			{
				elements.item(i).setStyle("font-weight","normal");
				elements.item(i).setStyle("font-size","10");
			}
		}
		
		//bold in ie, 700 in opera en ff
		if (this.style.fontWeight == 'bold' || this.style.fontWeight == '700')
		{
			this.style.fontWeight = 'normal';
			this.style.fontSize = '10';
		}
		else
		{
			this.style.fontWeight = 'bold';
			this.style.fontSize = '12';
		}
	});
   
	Ext.select('input[name^=filterknop]').on('click', function()
	{
		var elements = Ext.select('a[name^=filtertitel]');
		
		var titelstring = "";
		for (var i = 0; i < elements.getCount(); i++)
		{
			//bold in ie, 700 in opera en ff
			if (elements.item(i).getStyle("font-weight") == "bold" || elements.item(i).getStyle("font-weight") == "700")
				titelstring = "/" + Char(65+i);
		}
		
		var genrestring = "";
		var selectel = Ext.get("genreselect");
		if (selectel.getValue(true)>-1) genrestring = "/" + selectel.getValue(false);
		
		window.location="/koopfilms/1"+titelstring+genrestring;
	});
	
	Ext.select('a[name^=adultlink]').on('click', function()
	{
		var linkel = Ext.get(this.id);
		Ext.Msg.show({
		   title:'Verder gaan',
		   msg: 'U heeft geklikt op een link die leidt tot pagina\'s met pornografische inhoud. Bent u ouder dan 18 en wilt u verder gaan?',
		   buttons: Ext.Msg.YESNO,
		   fn: function(btn, text)
		   {
			   if(btn=="yes") window.location = linkel.dom.href;
		   },
		   animEl: linkel.dom.id
		});
	});
});


function Char(Value) 
{
	var vHexCode = "0123456789ABCDEF"
	var hex = "" + vHexCode.charAt((Value - (Value % 16))/16) + vHexCode.charAt(Value % 16)
	return unescape("%"+hex)
}

function callPagingLink(linknode)
{
	var str = linknode.name;
	var getvars = str.substring(9).split(':');
	var urlreq = linknode.href.split('?');
	
	Ext.Ajax.request ({
		url: getvars[1] + '.php?' + urlreq[1],
		method: 'GET',
		success: function(response) 
		{
			document.getElementById(getvars[0]).innerHTML = response.responseText;
		},
		failure: function()
		{
			Ext.Msg.alert('Ajax fout', 'De data kon niet opgehaald worden!');
		}
	});
}

function callSoundRefresh(queryvars)
{
	Ext.Ajax.request ({
		url: '/soundtrailer.php?' + queryvars,
		method: 'GET',
		success: function(response) 
		{
			Ext.get("multimediadiv").dom.innerHTML = response.responseText;
		},
		failure: function()
		{
			Ext.Msg.alert('Ajax fout', 'De data kon niet opgehaald worden!');
		}
	});
}

function callCartRefresh(queryvars,withslideout)
{
	temp = false;
	if (withslideout == undefined) withslideout = false;
	Ext.Ajax.request ({
		url: '/shoppingcart.php?' + queryvars,
		method: 'GET',
		success: function(response) 
		{
			if(withslideout) Ext.get("shopcarticon").slideOut();
			Ext.get("divshopcartcontent").fadeOut({
				callback: function()
				{
					document.getElementById("shoppingcart").innerHTML = response.responseText;
					Ext.get("divshopcartcontent").fadeIn(
					{
						useDisplay: true,
						afterCls: 'divshopcartcontent'
					});
				},
				useDisplay: true				
			});
			temp = true;
		},
		failure: function()
		{
			Ext.Msg.alert('Ajax fout', 'De data kon niet opgehaald worden!');
		}
	});
	return temp;
}

function openWishListPopup(selectie, refnr)
{
	var wishlistp = new Ext.Window({
		title: 'Toevoegen aan verlanglijstje',
		width: 690,
		height: 450
	});
	Ext.Ajax.request ({
		url: '/wishlistpopup.php?selectie=' + selectie + '&refnr=' + refnr,
		method: 'GET',
		success: function(response) 
		{
			wishlistp.html = response.responseText;
			wishlistp.show();
		},
		failure: function()
		{
			Ext.Msg.alert('Ajax fout', 'De data kon niet opgehaald worden!');
		}
	});
}


