vars_sort = new Array('brand','color','sport','price','page');
minimum_size_before_read_vars = 3;
get_urlpath = function(){
	loc = this.location+'';
	host = this.location.protocol+'//'+this.location.host;
	ext = '.html';
	loc = loc.replace(host,'');
	loc = loc.replace(ext,'');
	return loc;
}

var tabs = new Array();
initTabs = function(){
	con = document.getElementById('home_highlights_left');
	if(!con)return;
	hrefs = con.getElementsByTagName('A');
	for(i=0; i<hrefs.length; i++){
		tabs.push(hrefs[i].id.substring(4));
		hrefs[i].onclick = function(){
			if(this.id.substring(4) == tabs[0]){ return false; }
		};
		hrefs[i].onmouseover = function(){
			for(i=0; i<tabs.length; i++){
				act = tabs[i] == this.id.substring(4) ? true : false;
				document.getElementById(tabs[i]).style.display = act ? 'block' : 'none';	
			}
			a = this.parentNode.getElementsByTagName('A');
			for(i=0; i<a.length; i++){ if(a[i].className.indexOf('active') > -1)a[i].className = a[i].className.replace('active',''); }
			this.className += ' active';
		};
		obj = document.getElementById(hrefs[0].id.substring(4));
		if(typeof obj == 'object')obj.onclick = function(){ try { location.href = document.getElementById('rel_'+this.id).href; } catch(e){}; };

	}
	
}

replace_var = function(loc, varname, varvalue){
	if(loc.indexOf(varname+'/') == -1){
		// add var
		if(varvalue != '')loc+='/'+varname+'/'+varvalue;
	} else {
		f = '/'+varname+'/';
		s = loc.indexOf(f);
		// checken of er nog een slash gevonden wordt,i.v.m. meerder vars
		nextslash = loc.substring(s+f.length).indexOf('/');
		if(nextslash == -1){
			// laatste var dus geheel replacen
			if(varvalue != ''){
				loc = loc.substring(0,s)+'/'+varname+'/'+varvalue;
			} else {
				loc = loc.substring(0,s);
			}
		} else {
			// nog een variable gevonden
			rep = loc.substring(s, s+f.length+nextslash);
			if(varvalue != ''){
				loc = loc.replace(rep, '/'+varname+'/'+varvalue);
			} else {
				loc = loc.replace(rep, '');
			}
		}
		//loc+='/'+varname+'/'+varvalue;
	}
	return loc;
}

reorder_url = function(loc){
	nstr = '';
	
	p = loc.split('/');
	minimum = 0;
	for(pc=0; pc<=minimum_size_before_read_vars; pc++){
		minimum+= p[pc].length + (pc>0 ? 1 : 0);
	}
	//minimum_size_before_read_vars
	for(i=0; i<vars_sort.length; i++){
		varname = vars_sort[i];
		if(loc.indexOf(varname+'/') > minimum){	
			f = '/'+varname+'/';
			s = loc.indexOf(f);
			// checken of er nog een slash gevonden wordt,i.v.m. meerder vars
			nextslash = loc.substring(s+f.length).indexOf('/');
			if(nextslash == -1){
				part = loc.substring(s);
				loc = loc.replace(part, '');
				nstr+= part;
			} else {
				part = loc.substring(s, nextslash+s+f.length);
				loc = loc.replace(part, '');
				nstr+= part;
			}
		
		}
	}	
	return loc+nstr;
}

set_filter = function(obj){
	try {
		if(typeof(obj) == 'object'){
			loc = get_urlpath();
			loc = replace_var(loc, obj.name, obj.value);
			switch(obj.name){
				case 'page':
					break;
				default:
					loc = replace_var(loc, 'page', '');
			}
			loc = reorder_url(loc);
			this.location.href = this.location.protocol+'//'+this.location.host+loc+'.html';
		}
	} catch(e){ alert(e.description); };
}
var h_to;
set_product_img = function(obj){
	el = document.getElementById('image_color_'+obj.value);
	if(typeof el == 'object'){
		
		var ho = document.getElementById('product_detail_left');
		var im = el.getElementsByTagName('IMG');	
		var hi = ho.getElementsByTagName('IMG');	
		var fi = ho.getElementsByTagName('FORM')[0].getElementsByTagName('IMG');	
		var th = document.getElementById('product_detail_left_thumbs');
		maximg = im.length;
		disimg = 1;//hi.length - fi.length;
		for(i=0; i<maximg; i++){
			switch(i){
				case 0:
					//alert(hi[i].parentNode.href);
					im_path = im[i].src.split('/');
					im_base = im_path[im_path.length-1];
					ne_base = im_base.substring(2);
					im_path = im[i].src.replace(im_base, 'l_'+ne_base);
					
					img_path = hi[i].src.split('/');
					img_base = img_path[img_path.length-1];
					img_path = hi[i].src.replace(img_base, im_base.substring(2));
										
					hi[i].src = im_path;
					th.innerHTML = '';
					//th.style.display = 'none';
				//	th.style.display = 'none';
					document.getElementById('productimagelink').href = img_path.replace('/thumbs/', '/');
					document.getElementById('btn_zoom').href = img_path.replace('/thumbs/', '/');
					break;
				default:
					if(i >= disimg){
						my_path = im[i].src.replace('/thumbs/s_', '/');
						n_a = document.createElement('A');	
						n_a.href = my_path;
						n_a.rel = 'lightbox';
						
						n_im = document.createElement('IMG');	
						n_im.style.height = '57px';
						n_im.src = im[i].src;
						if(i == 2){
							n_a.className = 'center';	
						}
						n_im.onmouseover = function(){
							p = document.getElementById('productimagelink');
							p.style.background = '#ffffff url('+ this.src.replace('/thumbs/s_', '/thumbs/l_') +') center center no-repeat';
							p.getElementsByTagName('IMG')[0].style.visibility='hidden';
						};
						n_im.onmouseout = function(){
							p = document.getElementById('productimagelink');
							p.style.background = '#ffffff';
							p.getElementsByTagName('IMG')[0].style.visibility='visible';
						}
						n_a.appendChild(n_im);
						th.appendChild(n_a);
						th.style.display = 'block';
					}
					
			}

		}
			initLightbox();
	}
}

function toggleMoreInfo(id, col){

	if ( document.getElementById(id).style.display=='block' ) {
		document.getElementById(id).style.display='none';
	} else {
		if ( col == 2 || col == 3 || col == 6 || col == 7 ) {
			document.getElementById(id).style.left='auto';
			document.getElementById(id).style.right='20px';
		}
		document.getElementById(id).style.display='block';
	}
}

function hideMoreInfo(id){
	document.getElementById(id).style.display='none';
}

function price_to_int(str){
	try {
		str = str.replace(',', '.');
		str = str.replace(new RegExp(/[^0-9.]/g), '');
		return str;
	} catch(e){  };
}

function format_price(str){
	try {
		str += '';
		if(str.indexOf('.') > -1){
			str = Math.round(str*100)/100;
			str += '';
			p = str.split('.');
			val = p[0]; cent=p[1];
			while(cent.length < 2){cent+='0';}
		} else {
			val = str;
			cent = '00';
		}
		return '&euro; '+val+','+cent;
	} catch(e){  };
}
var combiprices = new Array();
_obj = function(id){
	obj = document.getElementById(id);
	if(!obj){}else{
		if(typeof(obj) == 'object' && obj.tagName){
			objs = 'TABLE THEAD TBODY TFOOT TR TD DIV FORM SPAN INPUT SELECT STRONG LABEL';
			if(objs.indexOf(obj.tagName) > -1){
				return obj;	
			}
		}
	}
//	alert(id +' niet gevonden');
	return new Object();
}
copts = sopts = false;
function rebuild_stack(type,i,art){
	try {
	if(!art){ art=false; } else { article = art; }
	s = _obj('size_'+i).value;
	c = _obj('color_'+i).value;
	switch(type){
		case 'color':
			sf = new RegExp(article+'([a-z0-9]+)-'+s.substring(0,6), 'gi');
			if(!copts){ //copts = _obj('color_'+i).options;
				copts = new Array();
				for(x=0; x<_obj('color_'+i).options.length; x++){
					copts.push(new Array(_obj('color_'+i).options[x].value, _obj('color_'+i).options[x].text));
	
				}
			}
			// hide color options
			skip = '';
			numoptions = 0;
			_obj('color_'+i).length = numoptions;
			if(_obj('size_'+i).options[0].value == ''){
				//_obj('color_'+i).options[numoptions] = new Option("--leeg--", "");
				//numoptions++;
			}
			for(j=0; j<combiprices.length; j++){
				if(combiprices[j].id.match(sf)){
					c = combiprices[j].id.substring(article.length);
					c = c.substring(0, c.indexOf('-'));
					for(x=0; x<copts.length; x++){
						if(copts[x][0] == c && skip.indexOf('-'+c+'-') == -1){ 
							_obj('color_'+i).options[numoptions] = new Option(copts[x][1], copts[x][0]);
							skip+='-'+c+'-';
							numoptions++;
						}
					}
				}
			}
			return true;
			break;
		/*
		case 'size':
			sf = new RegExp(article+c+'-([a-z0-9]+)', 'gi');
			if(!sopts){ //copts = _obj('color_'+i).options;
				sopts = new Array();
				for(x=0; x<_obj('size_'+i).options.length; x++){
					sopts.push(new Array(_obj('size_'+i).options[x].value, _obj('size_'+i).options[x].text));
				}
			}
			// hide size options
			skip = '';
			numoptions = 0;
			_obj('size_'+i).length = numoptions;
			for(j=0; j<combiprices.length; j++){
				if(combiprices[j].id.match(sf)){
					c = combiprices[j].id.substring(combiprices[j].id.indexOf('-')+1);
					for(x=0; x<sopts.length; x++){
						if(sopts[x][0] == c && skip.indexOf('-'+c+'-') == -1){ 
							_obj('size_'+i).options[numoptions] = new Option(sopts[x][1], sopts[x][0]);
							skip+='-'+c+'-';
							numoptions++;
						}
					}
					
				}
			}
			break;*/
	}
	return false;
	} catch(e){ alert(e.description); }
}
function calc_price(i, art, field){
	if(typeof i == 'object')i = i.id.substring(i.id.indexOf('_')+1)*1;
	if(!field){} else {	rebuild_stack('color',i,art); }
	try {
		if(!art){ art=false; } else { article = art; }

		s = _obj('size_'+i).value;
		c = _obj('color_'+i).value;
		a = _obj('amount_'+i).value;
		if(price_to_int(a) == ''){  _obj('amount_'+i).value = '1'; a= 1; }
		found = false;
		for(j=0; j<combiprices.length; j++){
			if(combiprices[j].id == article+c+'-'+s.substring(0,6)){
				pp = combiprices[j].pr;
				ppf = price_to_int(combiprices[j].pr);
				ppk = ppf.replace('.',',');
				ppp = format_price(ppf);
				pt = a > 0 ? ppf*a : 0;
				ptk = format_price(pt);
				found = true;
				_obj('pricetxt_'+i).innerHTML = ppp;
				_obj('totaltxt_'+i).innerHTML = ptk;
				_obj('label_'+i).value = article+'##'+c+'-'+s.substring(0,6);
				_obj('pricetxt_'+i).innerHTML = ppp;
				_obj('price_'+i).value = ppf;
				j=combiprices.length;
			}
		}
		if(!found){
			_obj('totaltxt_'+i).innerHTML = '';
			_obj('totalprice_'+i).value = '';
			_obj('label_'+i).value = '';
			_obj('pricetxt_'+i).innerHTML = '';
			_obj('price_'+i).value = '';
			//alert(i+'. combinatie '+	article+c+'-'+s.substring(0,6) + ' bestaat niet');
		}
		t = _obj('total_price');
		if(t.tagName && t.tagName == 'TD'){
			tot = 0;
			table = _obj('cart');
			tbody = table.getElementsByTagName('TBODY')[0];
			trs =  tbody.getElementsByTagName('TR');
			for(x=0; x<trs.length; x++){
				if(trs[x].id.length > 0){
					//price_to_int(combiprices[j].pr)
					p = _obj('totaltxt_'+trs[x].id);
					if(!p){}else{p = price_to_int(p.innerHTML);
					tot = tot + (p*1);
					}
				}
			}
			t.innerHTML = format_price(tot);
		}
		if(i > 1){
			if(s != '' && c != ''){
				hold = document.getElementById('table_dynamic');
				trs = hold.getElementsByTagName('TR');
				if(trs.length == i){
					clone = trs[i-1].cloneNode(true);
					elms = new Array('SELECT','INPUT','STRONG');
					for(z=0; z<elms.length; z++){
						csel = clone.getElementsByTagName(elms[z]);
						for(j=0; j<csel.length; j++){
							if(csel[j].id != ''){
								parts = csel[j].id.split('_');
								csel[j].id = parts[0]+'_'+(i+1);
								switch(elms[z]){
									case 'INPUT':
										//csel[j].value = '';
										if(csel[j].type == 'hidden' && String(csel[j].name).indexOf('color') > -1){
											//csel[j].type = 'text';
										} else {
											csel[j].value = '';	
										}
										break;
									case 'STRONG':
										csel[j].innerHTML = '';
										break;
								}
							}
						}
					}
					hold.appendChild(clone);
				} 
			}
		}
	} catch(e){ 
		//alert(e.description); 
	};
}

function send_activation(name, str){
	try {
		f = document.forms[name];
		if(typeof f == 'object'){
			f.send_activation.value = str;
			f.submit();
		}
		return false;
	} catch(e){ 
		return false;
	}
}

function submit_form(name){
try {
	f = document.forms[name];
	if(typeof f == 'object')f.submit();
	return false;
} catch(e){ 
	alert(e.description); 
	return false;
	}
}

function submit_cart(type, other_vars){
	tl = String(window.location.href);
	s = tl.substring(( tl.indexOf('https') == -1 ? 7 : 8 ));
	p = s.split('/');
	prefix = ( p[1] == 'shop' ? '/'+p[1]: '/'+p[1]+'/'+p[2]);
	f = document.forms['cart'];
	if(!type){ calc_price(1);
	} else {
		switch(type){
			case 'check_amount':
				inp = f.getElementsByTagName('INPUT');
				ok = true;
				for(i=0; i<inp.length; i++){
					if(inp[i].id.substring(0,7) == 'amount_'){
						if(!check_errors_onkeypress(inp[i], 'IS_NUMERIC', true, true))ok=false;
					}
				}
				if(!ok)return false;
				break;
			case 'recalculate':
				f.action = prefix+'/cart/update.html';
				break;
						case 'adddiscount':
				inp = f.getElementsByTagName('INPUT');
				ok = true;
				for(i=0; i<inp.length; i++){
					if(inp[i].name != 'discountcode'){
						if(inp[i].type != 'hidden')inp[i].disabled = 'disabled';
					}
				}
				f.action = prefix+'/cart/adddiscount.html';
				break;
			case 'removediscount':
				inp = f.getElementsByTagName('INPUT');
				ok = true;
				for(i=0; i<inp.length; i++){
					if(inp[i].name != 'discountcode'){
						//inp[i].disabled = 'disabled';
					}
				}
				document.getElementById('othervar').value = other_vars;
				//f.discountcode.value = other_vars;
				f.action = prefix+'/cart/removediscount.html';
				break;

			case 'order':
				f.action = prefix+'/order.html';
				break;
			case 'delete_and_recalculate':
				if(!other_vars)other_vars=false;
				else {
					inp = f.getElementsByTagName('INPUT');
					for(i=0; i<inp.length; i++){
						if(inp[i].type == 'text'){
							if(inp[i].name.indexOf(other_vars) > -1){
								inp[i].value = 0;
								f.action = prefix+'/cart/update.html';
							} else {
								//inp[i].value = 'skip';
								inp[i].disabled = true;
							}
						}
					}
				
				}
				break;
			case 'shipping':
				f = document.forms[type];
				break;
		}
	}
	if(typeof f == 'object')f.submit();
	return false;
}

check_shipping = function(obj){
	if(!obj)obj=false;
	if(typeof(obj) == 'boolean'){
		// checken of er een waarde geselecteerd is
		ta = document.getElementsByClassName('TAKEAWAY');
		for(i=0; i<ta.length; i++){
			if(ta[i].checked){
				obj = ta[i];	
			}
		}
	}
	if(typeof(obj) == 'object'){
		hide = obj.className.indexOf('TAKEAWAY') > -1 ? true : false;
		document.getElementById('display_shippingaddress').style.display = !hide ? 'block' : 'none';	
		if(!hide){
			//alert(document.getElementById('btn_shippingaddress').className);
			document.getElementById('btn_shippingaddress').className = 	document.getElementById('btn_shippingaddress').className.replace('disabled','');
			//alert(document.getElementById('btn_shippingaddress').className);
		} else {
			if(document.getElementById('btn_shippingaddress').className.indexOf('disabled') == -1)document.getElementById('btn_shippingaddress').className+= ' disabled';
		}
		document.getElementById('btn_shippingaddress').onclick = function(){
			if(this.className.indexOf('disabled') != -1)return false;
		};
	}
}

function switchFormTab(id){

	var tabs = document.getElementsByClassName('formtab');
	if ( tabs.length > 0 ) {
		for ( var i=0;i<tabs.length;i++ ) {
				tabs[i].style.display='none';
		}
	}
	if ( id ) {
		document.getElementById(id).style.display='block';
	}
}

function switchAdvancedElements(classe, hide, label){
	if(!hide)hide=false;
	if ( classe ) {
		obj = document.getElementsByClassName(classe);
		for(i=0; i<obj.length; i++){
			if(label && obj[i].className.indexOf('lab_organisationname') > -1){
				obj[i].innerHTML = label+'*';	
			}
			obj[i].style.display=!hide ? 'block' : 'none';
		}
	}
}

document.getElementsByClassName = function (needle)
{
    var s = [document.documentElement || document.body], i = 0, r = [], l = 0, e;
    var re = new RegExp('(^|\\s)' + needle + '(\\s|$)');

    do
    {
        e = s[i];

        while (e)
        {
            if (e.nodeType == 1)
            {
                if (e.className && re.test(e.className)) r[l++] = e;

                s[i++] = e.firstChild;
            }

            e = e.nextSibling;
        }
    }
    while (i--);

    return r;
}

set_address = function(str){
	try {
		p = str.split('###');
		f = document.forms['address'];
		if(typeof(f) == 'object'){
			f.check_id.value = p[0];
			sp = p[1].split(' ');
			nr = sp[sp.length-1];
			f.street.value = p[1].substring(0, p[1].length-nr.length);
			f.streetnumber.value = nr;
			f.zipcode.value = p[3];
			f.city.value = p[4];
			f.country.value = p[5];
		}
	} catch(e){
		alert(e.desciption);	
	}
}

select_address = function(){
	a = document.getElementById('address_select');
	if(typeof(a) == 'object'){
		d = document.getElementsByTagName('DIV');
		for(i=0; i<	d.length; i++){
			if(d[i].className.indexOf('c_grey') > -1 && d[i].getElementsByTagName('INPUT')[0].name == 'address'){
				d[i].onmouseover = function(){
					this.style.background='orange';
					this.style.cursor = 'pointer';
				}
				d[i].onmouseout = function(){
					if(!this.getElementsByTagName('INPUT')[0].checked)this.style.background='#ebeaeb';
				}
				d[i].onclick = function(){
					par =  document.getElementById('address_select');
					//d = par.parentNode.getElementsByTagName('DIV');
					for(i=0; i<	d.length; i++){
						if(d[i].className.indexOf('c_grey') > -1){
							if(d[i].getElementsByTagName('INPUT')[0].checked){
								d[i].style.background='#ebeaeb';
								d[i].getElementsByTagName('INPUT')[0].checked = false;
							}
						}
					}
					this.getElementsByTagName('INPUT')[0].checked = true;
					document.forms['address'].check_id.value = 'N';	
				}
			};
		}
		f = document.forms['address'];
		if(typeof(f) == 'object'){
			//alert('object');
			inp = f.getElementsByTagName('INPUT');	
			//alert(inp.length);
			for(i=0; i<inp.length; i++){
				inp[i].onkeypress = inp[i].onfocus = function(){
					this.form.check_id.value = 'Y';	
				}
			/*	inp[i].onfocus = function(){
					alert(this);
					alert(this.form.check_id);
					this*.form.check_id.value = 'Y';	
				}*/
			}
		}
	}
}

value_is_valid = function(value, type){
	while(value.substr(0, 1) == ' ')value = value.substring(1);
	if(type.indexOf('|EMPTY') > -1){
		type = type.substring(0, type.indexOf('|EMPTY'));
		if(value == '')return true;
	}
	switch(type){
		case 'NOT_EMPTY':
			if(value.length > 0)return true;
			break;
		case 'IS_COUNTRYCODE':
			reg = new RegExp(/[A-Z]{2}/i);
			if(value.match(reg) && value.length == 2)return true;
			break;
		case 'IS_DATE':
			reg = new RegExp(/[0-9]{2}-[0-9]{2}-[0-9]{4}/gi);
			if(value.match(reg) && value.length == 10)return true;
			break;
		case 'IS_URL':
			reg = new RegExp(/(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/gi);
			if(value.match(reg))return true;
			break;
		case 'IS_NUMERIC':
			reg = new RegExp(/^[0-9]*$/);
			if(value.match(reg))return true;
			break;
		case 'IS_EMAIL':
			reg = new RegExp(/^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/);
			if(value.match(reg))return true;
			break;
		case 'IS_PHONENUMBER':
			f = new Array('-',' ','(',')','+');
			for(i=0; i<f.length; i++){
				value = value.replace(f[i], '');
			}
			reg = new RegExp(/^\d{10,15}/g);
			if(value.match(reg) && value.length < 16)return true;
			break;
		default:
			if(type.substring(0,1) == '[' && type.substring(type.length-1) == ']'){
				type = type.substring(1, type.length-1);
				switch(type.substring(0,7)){
					case '!STRING': return type.substring(7) == value ? false : true; break;
					case 'REGEXP:': 
						try {
							regexp = '[^'+type.substring(7)+']';
							reg = new RegExp(regexp, 'gi');
							if(!value.match(reg))return true;
						} catch(e){}
						break;
				}
			}
	}
	return false;
}

check_errors_onkeypress = function(obj, type, skip_classname, check_now){
	if(!skip_classname)skip_classname=false;
	if(!check_now)check_now=false;
	//value_is_valid(this.value, this.rel) == false
	if(typeof(obj) == 'object'){
		if(!skip_classname)obj.className += ' fielderror';
		obj.rel = type;
		obj.onkeypress = obj.onkeyup = obj.onkeydown = obj.onblur = function(){
			try {
				if(this.className.indexOf('fielderror') > -1 && value_is_valid(this.value, this.rel)){
					this.className = this.className.replace('fielderror','');
					l = document.getElementById('rel_'+this.id);
					if(typeof l == 'object'){
						l.className = l.className.replace('labelerror','');
					}
				} 
				else if(this.className.indexOf('fielderror') == -1 && value_is_valid(this.value, this.rel) == false){
					this.className += ' fielderror';
					l = document.getElementById('rel_'+this.id);
					if(typeof l == 'object'){
						l.className += ' labelerror';
					}
				}
			} catch(e){}
		}
		// checken voor label
		if(obj.id){
			labels = obj.parentNode.getElementsByTagName('LABEL');
			if(labels.length == 0)labels = obj.parentNode.parentNode.getElementsByTagName('LABEL');
			for(x=0; x<labels.length; x++){
				f = labels[x].getAttribute('for');
				if(!f){
					f = labels[x].attributes["for"].value;
				}
				if(f == obj.id){
					 if(!skip_classname)labels[x].className += ' labelerror';
					 labels[x].id = 'rel_'+obj.id;
				}
				
			}
		}
	}
	if(check_now){
		valid = value_is_valid(obj.value, obj.rel);
		if(!valid)obj.className += ' fielderror';
		return valid;
	}
};
showFormErrors = function(form, fieldstr){
	f = document.forms[form];
	if(typeof(f) == 'object' && fieldstr.length > 0){
		fields = fieldstr.split(',');
		fe = f.getElementsByTagName('*');
		for(i=0; i<fe.length; i++){
			if(fe[i].name){
				for(j=0; j<fields.length; j++){
					parts = fields[j].split('::');
					if(fe[i].name == parts[0]){
						check_errors_onkeypress(fe[i], parts[1]);
					} 
				}
			}
		}
	}
};

function get_nextsibling(n){
	x=n.nextSibling;
	while (x.nodeType!=1){
	  x=x.nextSibling;
	}
	return x;
}

checkRelatedElement = function(_this){
	try {
		c = _this.className+'';
		m = c.match(/rel_([a-z_0-9]+)/gi);
		m = m+'';
		v = c.match(/val_([a-z_0-9]+)/gi);
		v = v+'';
		ma = _this.value == v.substring(4) ? true : false;
		obj = document.getElementById(m.substring(4));
		obj.style.display = !ma ? 'block' : 'none';
		if(obj.id){
			par = obj.parentNode;
			labels = par.getElementsByTagName('LABEL');
			if(labels.length == 0){
				par = obj.parentNode.parentNode;
				labels = par.getElementsByTagName('LABEL');
			}
			br = par.getElementsByTagName('BR');
			for(x=0; x<labels.length; x++){
				f = labels[x].getAttribute('for');
				if(!f){
					f = labels[x].attributes["for"].value;
				}
				if(f == obj.id){
					 labels[x].style.display = !ma ? 'block' : 'none';
					 labels[x].id = 'rel_'+obj.id;
				}				
			}
			if(get_nextsibling(obj).tagName == 'BR'){
				 get_nextsibling(obj).style.display = !ma ? 'block' : 'none';
			}
		}	
	} catch(e){};
}
checkFormRelations = function(form){
	r = document.getElementsByClassName('related');
	for(i=0; i<r.length; i++){
		r[i].onchange = function(){
			checkRelatedElement(this);
		}
		checkRelatedElement(r[i]);
	}
	
}
var defaultval, _startimg;
init = function(){ 
	try {
		// initTabs
		initTabs();
		q =  document.getElementById('q');
		if(q && typeof(q) == 'object' && typeof(q.value) == 'string'){
			defaultval = q.value;
			q.onfocus = function(){
				if(this.value ==defaultval)this.value='';
			};
		}
		// check op #ucz
		l = this.location+'';
		f = '';
		if(l.indexOf('ucz=') > -1){ 
			f = l.match(/ucz=[0-9]*-[0-9A-Z ]*/gi); 
			f = f + '';
			f = f.replace(/ucz=/g,'');
			if(f != ''){ f = f + '';
				// prijs / product tabel bijwerken
				s1 = document.getElementById('size_1');
				c1 = document.getElementById('color_1');
				if(typeof(s1) == 'object' && typeof(c1) == 'object'){
					s1.value = f.substring(f.indexOf('-')+1);
					c1.value = f.substring(0,f.indexOf('-'));
					calc_price(1);
				}
			}
		}
		se = document.getElementById('sel_color');
		if(!se)return;
		if(typeof(se) == 'object'){
			
			if(f != ''){
				f = f + '';
				f = f.match(/[0-9]*/);
				for(j=0; j<se.options.length; j++){
					if(se.options[j].value == f){
						_startimg = j;
						j = se.options.length;
					}
				}
			}
			
			se.selectedIndex = _startimg;
			set_product_img(se);	
			
		}
	} catch (e){ alert(e.description); }
}

show_sizetable = function(obj, type){
	if(!type)return false;
	if(type == 'over'){
		if(!document.getElementById('sizetable')){
			d = document.createElement('DIV');
			d.id = 'sizetable';
		//	d.style.background = '#ffffff url('+obj.href+') no-repeat';
			
			im = document.createElement('IMG');
			im.src = obj.href;
			d.appendChild(im);
			
			obj.appendChild(d);
		} else {
			document.getElementById('sizetable').style.background = '#ffffff url('+obj.href+') no-repeat';
			document.getElementById('sizetable').style.display = 'block';	
		}
	} else if(type == 'out'){
		document.getElementById('sizetable').style.display = 'none';	
	}
}

_convert = function(inp){
	s = l = ''; for(i=0;i<inp.length;i=i+3){ s+= (inp.substring(i, i+3));i=i+3; }
	for(i=0;i<s.length;i=i+3){ if((s.substring(i, 3+i)*1/3) != ''){ l+= String.fromCharCode((s.substring(i, 3+i)*1/3)); } }
	document.write(l);
};