var currentTabInfo = 1;

j(document).ready(function(){
 
 
    j('#tab'+currentTabInfo).css('background','url(/img/information/tab-bg.gif) repeat-x left -64px');
    j('#tab'+currentTabInfo+' a').css('color','white');
});

function overM1(bg, img) {
	document.getElementById(bg).style.background = "url(/img/m1/bg.gif) repeat-x left -30px";
	document.getElementById(img).style.background = "url(/img/m1/arr.gif) repeat-x left -11px";
}

function outM1(bg, img) {
	document.getElementById(bg).style.background = "url(/img/m1/bg.gif) repeat-x left top";
	document.getElementById(img).style.background = "url(/img/m1/arr.gif) repeat-x left top";
}

function overM1img(img, bg) {
	document.getElementById(bg).style.background = "url(/img/m1/bg.gif) repeat-x left -30px";
	document.getElementById(img).style.background = "url(/img/m1/arr.gif) repeat-x -11px top";
}

function outM1img(img, bg) {
	document.getElementById(bg).style.background = "url(/img/m1/bg.gif) repeat-x left top";
	document.getElementById(img).style.background = "url(/img/m1/arr.gif) repeat-x left top";
}

 // var currentTabInfo = 1;

function overInfo(id) {
	if (id != currentTabInfo) {
		document.getElementById('tab' + id).style.background = "url(/img/information/tab-bg.gif) repeat-x right -32px";
	}
}

function outInfo(id) {
	if (id != currentTabInfo) {
		document.getElementById('tab' + id).style.background = "url(/img/information/tab-bg.gif) repeat-x right top";
	}
}

function clickInfo(id) {
	if (id != currentTabInfo) {
		document.getElementById('tab' + currentTabInfo).className = "tab";
		document.getElementById('tab' + currentTabInfo).style.background = "url(/img/information/tab-bg.gif) repeat-x right top";
		document.getElementById('panel' + currentTabInfo).className = "panel";
		currentTabInfo = id;
		document.getElementById('tab' + id).className = "tab a";
		document.getElementById('tab' + id).style.background = "url(/img/information/tab-bg.gif) repeat-x left -64px";
		document.getElementById('panel' + id).className = "panel a";
	}
}

var currentTab = false;
function dropM2(id) {
	if (currentTab) {
		if (currentTab == id){
			document.getElementById(id).style.display = "none";
			currentTab = false;
		} else {
			document.getElementById(currentTab).style.display = "none";
			document.getElementById(id).style.display = "block";
			currentTab = id;
		}
	} else {
		document.getElementById(id).style.display = "block";
		currentTab = id;
	}
}
function send(form,item){
	j('#' + form).attr("action", "/"+item+".html");
	j('#' + form).submit();
}
function basket_item_manipulation(index)
{
	j(this).bind('click', function () {
		obj = j(this).nextAll('input');
		count = obj.val();
		if (count) count = parseInt(count);
		switch(this.className){
		case 'ad': minus_num(count); break;
		case 'au': plus_num(count); break;
		case 'del': del_item(); break;
		}
	});
}
function del_item(){
	obj.val(0);
	send("step","winkelwagen/amount");
}
function minus_num(count){
	if (count != '' && count > 0 ) {
		count --;
		obj.val(count);
	}
	else {
		obj.val(0);
	}
}
function plus_num(count){
	if (count != '' ) {
		count ++;
		obj.val(count);
	}
	else {
		obj.val(1);
	}	
}
j(document).ready(function(){
	j('#basket_item_list div.num div a').each(basket_item_manipulation);
});


 
//start live search
var typing = 0;

function getResults(query)
			{
			 		
				j.post('/livesearch/'+query+'.htm', function(data){
				
				j("#cont_r").empty().append(data);				
				});
  
			}

j(document).ready(function(){
	
	j("#res").hide();
 	j("#searchstr").val('');			 
	
	j("#searchstr").focusin(function() {
	q = j("#searchstr").val();				 
	 
	
		 	 
	});
	
	j("#searchstr").live('focusout', function() {
		j("#res").fadeOut("fast");	
		typing = 0;
	 
		 
	});
	
	j("#searchstr").keypress(function() {
		if (typing == 0) 
		{
			typing = 1;
			
		}
		 else {
		 if ( j("#res").css('display') == 'none') {j("#res").fadeIn("fast");}
		 
		 }
	});
	
	j("#searchstr").keyup(function() {				
	if (typing == 1) 
	{			
		 			 
		query = j("#searchstr").val();
 
		if (query.length > 1){getResults(query);}				 
	}});	 
});

//end live search

//filter
var pmin = 0;
var pmax = 999999;
var ur = '';

function change_href(l,h)
{		
	if (l != -1) {pmin = l;}
	if (h != -1) {pmax = h;}
	if (pmax < pmin) 
	{
		a = pmax;
		pmax = pmin;
		pmin = a;
	}
	s = '?min='+pmin+'&max='+pmax;
	j('#price').attr('href',s); 	 
}

j(document).ready(function()
{
	j('#minprice').attr('value','');
	j('#maxprice').attr('value','')
	j('#minprice').click(function(){j('#minprice').attr('value','')});
	j('#maxprice').click(function(){j('#maxprice').attr('value','')});
	j('#minprice').keyup(function(event, s)
		{
			if( event.keyCode == 13  ){ window.location.href = ur+j('#price').attr('href');} else{
			if(j('#minprice').val().length >= 1){ change_href(j('#minprice').val(),-1); }}
		});

	j('#maxprice').keyup(function(event)
		{
			if( event.keyCode == 13  ){ window.location.href = ur+j('#price').attr('href');} else{
			if(j('#maxprice').val().length >= 1){ change_href(-1,j('#maxprice').val()); }}
		});
	j('#price').attr('href','');
	

});
 
//filter

function showImg(id){ j('.im').hide();j('#'+id).fadeIn("fast"); }
function closeImg(){ j('#layer').hide(); j('#splash').hide(); }
function imgclick(){
var ii = 0;
j('#layer').show();
j('#imgs img').each(function(i,data){
ht = (j(window).height()) - 178;
if(ht > 485){ht = 485;}
j('#imgs').css('height',ht);
w =  j(data).attr('width');
h =  j(data).attr('height');
wz = ht/(w); hz = ht/(h); zoom = 100;
if((w>485)||(h>485)){
if(wz > hz){
j(this).attr('height',Math.floor(hz*h));
j(this).attr('width',Math.floor(hz*w));
}else{
j(this).attr('height',Math.floor(wz*h));
j(this).attr('width',Math.floor(wz*w)); }}
if (ii == 0 ){j(this).show(); ii=1;}
});
j('#splash').show();
;}
//marks
function setmark(n){ j('.mark').css('background-image','url(/img/comments/lstar.gif)');
for(i = 1; i<=n; i++){ j('.mark[name='+i+']').css('background-image','url(/img/comments/hstar.gif)');}}

//compare
var checkedIds = "";
j(document).ready(function()
{
 j('.compcheck').click(function(){
 
 pid = j(this).attr('name');
 
 
 
 if ( j(this).attr('checked') ) 
 
 {	 	 
 
 j.get('/compare/'+pid+'.htm', function(data){		 
 
 j('#compr').replaceWith(data);	
 
 }); 
 
 } else {  
 
 j.get('/compare/'+pid+'.adhtm', function(data){ 	
 
 j('#compr').replaceWith(data);	
 
 }); 
 
 }
 
 });
    ids = checkedIds.replace(/^\s\s*/, '').replace(/\s\s*$/, '').split(' ');

    j('.compcheck').each(function(){
        if(checkedIds != ''){
            for(i = 0; i < ids.length; i++)
            {
                if(j(this).attr('name') == ids[i]) {
                j(this).attr('checked','checked');

                }
            }
        }
    });

});

