$(document).ready(function() {
    $("h1 .big").each(function(index){
    	var text = $(this).html();
    	$(this).html('<img src="/img/header.php?c=h1big&t=' + text + '" alt="' + text + '" />')
    });
    
    $("h1 .small").each(function(index){
    	var text = $(this).html();
    	$(this).html('<img src="/img/header.php?c=h1small&t=' + text + '" alt="' + text + '" />')
    });
        
    
    $("h2 .big").each(function(index){
    	var text = $(this).html();
    	$(this).html('<img src="/img/header.php?c=h2big&t=' + text + '" alt="' + text + '" />')
    });
    
    $("h2 .small").each(function(index){
    	var text = $(this).html();
    	$(this).html('<img src="/img/header.php?c=h2small&t=' + text + '" alt="' + text + '" />')
    });    
    
    $("h4 .big").each(function(index){
    	var text = $(this).html();
    	$(this).html('<img src="/img/header.php?c=h3bigaction&t=' + text + '" alt="' + text + '" />')
    });
    
    $("h4 .small").each(function(index){
    	var text = $(this).html();
    	$(this).html('<img src="/img/header.php?c=h3smallaction&t=' + text + '" alt="' + text + '" />')
    });     
    
    $("h3 .big").each(function(index){
    	var text = $(this).html();
    	$(this).html('<img src="/img/header.php?c=menubig&t=' + text + '" alt="' + text + '" />')
    });
    
    $("h3 .small").each(function(index){
    	var text = $(this).html();
    	$(this).html('<img src="/img/header.php?c=menusmall&t=' + text + '" alt="' + text + '" />')
    });    
    
    $("#menu a .big").each(function(index){
    	var text = $(this).html();
    	$(this).html('<img src="/img/header.php?c=menubig&t=' + text + '" alt="' + text + '" />')
    });
    
    $("#menu a .small").each(function(index){
    	var text = $(this).html();
    	$(this).html('<img src="/img/header.php?c=menusmall&t=' + text + '" alt="' + text + '" />')
    });   
    
    $("#brand_id").change(function() {
    	if ($(this).val() != '') {
    		document.location.href = '/merken/' + $(this).val() + '/1/';
    	}
    });
    
    $("#selector select").change(function() {
    	var loc = String(document.location);
    	var str = loc.split('/');
    	
    	if (querySt('q') != '' && querySt('q') != undefined) {
    		var qs = '?q=' + querySt('q');
    		str[4] = 'resultaten';
    	}
    	else {
    		var qs = '';
    	}
    	if ($(this).val() != '') {
    		document.location.href = '/' + str[3] + '/' + str[4] + '/1/' + $(this).attr('name') + '/' + $(this).val() + '/' + qs;
    	}  
    	else {
    		document.location.href = '/' + str[3] + '/' + str[4] + '/1/'+ qs;
    	}
    });

    $("#theme-list img").each(function() {
    	if ($(this).attr('vspace') != '') {
    		$(this).css({margin: '0px ' + $(this).attr('vspace') + 'px'})
    	}
    });
	
	$('#slider-box').cycle({
		timeout:       4000, 
	    speed:   1000, 
	    timeout: 5000, 
	    pause:   1,
	    before:  onBefore
	});
	
	var qText = 'product zoeken';
	
	$('#query').focus(function() {
		if ($(this).val() == qText) {
			$(this).val(''); 
		}
	});
	
	$('#query').blur(function() {
		if ($(this).val() == '') {
			$(this).val(qText); 
		}
	});	
    
});
function onBefore() {
	$('#frame0').attr('href', $(this).attr('rel'));
	if ($('#frame0').attr('href') == '' || $('#frame0').attr('href') == undefined) {
		$('#frame0').css('cursor: default');
	}
	else {
		$('#frame0').css('cursor: pointer');
	}
}
function querySt(ji) {
	hu = window.location.search.substring(1);
	gy = hu.split("&");
		for (i=0;i<gy.length;i++) {
		ft = gy[i].split("=");
		if (ft[0] == ji) {
			return ft[1];
		}
	}
}

