 
 
 
 function filter(fId,sid) {
 	
 	/* product overview filter */
 
	// show table header
	if($('table_header').style.display == "none" && cTHead != false) {
		new Effect.Parallel([
		  new Effect.Appear('table_header'), new Effect.BlindDown('table_header')
		], { duration: 0.5 });
	}

	if(fId != cId && cMov == false) {
		
		cMov = true;
		setTimeout("cMov = false;",550);
		
		// all products stored in filter 0
		var all_prods = filter_items[0][1];
		
		for (f=cStart; f<filter_items.length; f++) {
		
			link_id = filter_items[f][0];
			link_prods = filter_items[f][1];
			link_div = "fl_"+link_id;

			// change filter navigation highlight
			if(link_id == fId) {

				$(link_div).className='filteritem_a_bg';

				// change prododuct div visibilities
				for (p=0; p<all_prods.length; p++) {

					all_prod_id = all_prods[p];
					all_prod_id=all_prod_id.split("-");
					prod_id = all_prod_id[0];
					//prod_id = all_prods[p];
					prod_div = "p_"+prod_id;
					special_div = "sp_"+prod_id;
					prod_active = false;
					prod_special = false;
					
					//product is active and is special?
					for (lp=0; lp<link_prods.length; lp++) {
						link_id = link_prods[lp];
						link_id=link_id.split("-");
						if(link_id[0] == prod_id) {
							prod_active = true;
							if(link_id[1] == 1)
								prod_special = true;
						}
					}

					// alert(prod_div);
					if(prod_active == true) {
						if($(prod_div).style.display == "none") {
							new Effect.Parallel([
							  new Effect.Appear(prod_div), new Effect.BlindDown(prod_div)
							], { duration: 0.4, afterFinish: function() { 
									update_png();
                                 } 
                            }); 
						}
						//  shows/hides special product label
						if(prod_special == true) {
							if($(special_div).style.display == "none") {
								new Effect.Appear(special_div, { duration: 0.5 });
							}
						} else {
							new Effect.Fade(special_div, { duration: 0.5 });
						}
					} else {
						new Effect.Parallel([
						  new Effect.Fade(prod_div), new Effect.BlindUp(prod_div)
						], { duration: 0.5 });
						new Effect.Fade(special_div, { duration: 0.5 });
					}
					
				}
				
				// Effect.ScrollTo('modules');
				
				new Ajax.Request(s_root+'ext/setcat.php', {
					method: 'post',
					parameters: { fid: fId } ,
					onSuccess: function(transport) {
					}
				});

			} else {
				$(link_div).className='filteritem_bg';
			}

		}
		
	}

 }
 
 
 
 function swapTabClean(fId) {
 	
	if(fId != tId) {
		for (f=1; f<=tab_items.length; f++) {
			link_div = "tabnav_"+f;
			tab_div = "tab"+f;
			if(f == fId) {
				$(link_div).className='tabitem_a_bg';
				$(tab_div).style.display = "";
			} else {
				$(link_div).className='tabitem_bg';
				$(tab_div).style.display = "none";
			}
		}
	}

 }
 
 
 function swapTab(fId) {
 	
	if(fId != tId && tMov == false) {
		
		tId = fId;
		tMov = true;
		setTimeout("tMov = false;",550);
	
		for (f=0; f<tab_items.length; f++) {
		
			tab_id = tab_items[f];
			link_div = "tabnav_"+tab_id;
			tab_div = "tab"+tab_id;

			// change filter navigation highlight
			if(tab_id == fId) {

				$(link_div).className='tabitem_a_bg';

				if($(tab_div).style.display == "none") {
					/*
					new Effect.Parallel([
					  new Effect.Appear(tab_div), new Effect.BlindDown(tab_div)
					], { duration: 2.5 });
					*/
					new Effect.BlindDown(tab_div, { duration: 0.5 , afterFinish: function() { 
																								//if(tGal == fId) { 
																									loadGal(fId); 
																									//tGal=0;
																								//}
																								} });
					
				}

			} else {

				$(link_div).className='tabitem_bg';
				
				/*
				new Effect.Parallel([
				  new Effect.Fade(tab_div), new Effect.BlindUp(tab_div)
				], { duration: 0.5 });
				*/
				new Effect.BlindUp(tab_div, { duration: 0.5 });

			}

		}
		
	}

 }
 
 
 
 function openmoreinfo(fId) {
 	
	$("more_o_"+fId).style.display='none';
	$("more_c_"+fId).style.display='';

	new Effect.BlindDown("more_"+fId, { duration: 0.3 });

 }
 
 function closemoreinfo(fId) {
 	
	$("more_o_"+fId).style.display='';
	$("more_c_"+fId).style.display='none';

	new Effect.BlindUp("more_"+fId, { duration: 0.3 });

 }
 
 
 
 function toggle_billing_address() {
 	
	if($('BillingAddressFlag').checked) {
		new Effect.BlindUp("form_billing", { duration: 0.3 });
	} else {
		new Effect.BlindDown("form_billing", { duration: 0.3 });
	}
	
 }

 function toggle_shipping_address() {
 	
	if($('ShippingAddressFlag').checked) {
		new Effect.BlindUp("form_shipping", { duration: 0.3 });
	} else {
		new Effect.BlindDown("form_shipping", { duration: 0.3 });
	}
	
 }
 
 
 
 
 function updateConf(prod,fid,ptype,pos) {

	// updates configurator on product page

	var f = document.forms['order_'+fid+'_form'];
	// var err = false;
	oprod = f.prod_id.value;
	pid = f.c_pid.value;
	// alert(prod+","+fid);
	
	url=configurator_url+"?t=update";

	new Ajax.Request(url, {
		method: 'post',
		// parameters: $('conf_'+fid+'_form').serialize(true),
		parameters: { cprod: prod, oprod: oprod, mid: fid, c_pid: pid, ptype: ptype, pos: pos},
		onCreate: function() {
			divh = document.getElementById('conf_'+fid).offsetHeight+20;
			//new Effect.Fade('conf_'+fid,{ duration: 0.2, queue: 'end' });
			divbefore = document.getElementById('conf_'+fid).innerHTML;
			
			//document.getElementById('conf_'+fid).innerHTML = " <div class='loading' style='height:"+divh+"px'>&nbsp;</div>";
			document.getElementById('conf_'+fid).innerHTML = " <div style='position:relative'><div class='loading' style='height:"+divh+"px'>&nbsp;</div><div class='loading_old'>"+divbefore+"</div></div>";

		} ,
		onSuccess: function(transport) {
			// $('conf_'+fid).style.display = 'none';
			document.getElementById('conf_'+fid).innerHTML = transport.responseText;
			//new Effect.Appear('conf_'+fid,{ duration: 0.2, queue: 'end' });
		}
	});
	
	return false;

}

 function sendConf(fid) {

	// sends configurator on product page
	
	var f = document.forms['order_'+fid+'_form'];
	
	var pos = getRadioValue('productos');
	
	if(pos) {
		f.submit();
	} else {
		new Effect.BlindDown("text_os_error", { duration: 0.3 });
	}
	
	return false;

 }
 
 function getRadioValue(idOrName) {
 
	 var value = null;
	 var element = document.getElementById(idOrName);
	 var radioGroupName = null;  
	 
	 // if null, then the id must be the radio group name
	 if (element == null) {
		 radioGroupName = idOrName;
	 } else {
		 radioGroupName = element.name;     
	 }
	 if (radioGroupName == null) {
		 return null;
	 }
	 var radios = document.getElementsByTagName('input');
	 for (var i=0; i<radios.length; i++) {
		 var input = radios[ i ];    
		 if (input.type == 'radio' && input.name == radioGroupName && input.checked) {                          
			 value = input.value;
			 break;
		 }
	 }
	 return value;
 }

 function updateConfBAK(fid) {

	// updates configurator on product page

	var f = document.forms['conf_'+fid+'_form'];
	var err = false;

	url=configurator_url+"?t=send";

	new Ajax.Request(url, {
		method: 'post',
		parameters: $('conf_'+fid+'_form').serialize(true),
		onCreate: function() {
			divh = document.getElementById('conf_'+fid).offsetHeight+20;
			//new Effect.Fade('conf_'+fid,{ duration: 0.2, queue: 'end' });
			divbefore = document.getElementById('conf_'+fid).innerHTML;
			
			//document.getElementById('conf_'+fid).innerHTML = " <div class='loading' style='height:"+divh+"px'>&nbsp;</div>";
			document.getElementById('conf_'+fid).innerHTML = " <div style='position:relative'><div class='loading' style='height:"+divh+"px'>&nbsp;</div><div class='loading_old'>"+divbefore+"</div></div>";

		} ,
		onSuccess: function(transport) {
			// $('conf_'+fid).style.display = 'none';
			document.getElementById('conf_'+fid).innerHTML = transport.responseText;
			//new Effect.Appear('conf_'+fid,{ duration: 0.2, queue: 'end' });
		}
	});
	
	return false;

}

function updateCart(prod_id,prod_quan,prod_type,prod_os) {
	
	// updates cart with delete button or quantity chooser

	var f = document.cart_form;
	var err = false;

	f.prod_id.value = prod_id;
	f.prod_quan.value = prod_quan;
	f.prod_type.value = prod_type;
	f.prod_os.value = prod_os;

	f.submit();

}


/* ############
png fix
############# */

function update_png() {

	var arVersion = navigator.appVersion.split("MSIE");
	var naVersion = parseFloat(arVersion[1]);

	if ((naVersion >= 5.5) && (document.body.filters)) 
	{
	   for(var i=0; i<document.images.length; i++)
	   {
		  var img = document.images[i]
		  var imgName = img.src.toUpperCase()
		  if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
		  {
			 var imgID = (img.id) ? "id='" + img.id + "' " : ""
			 var imgClass = (img.className) ? "class='" + img.className + "' " : ""
			 var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
			 var imgStyle = "display:inline-block;" + img.style.cssText 
			 if (img.align == "left") imgStyle = "float:left;" + imgStyle
			 if (img.align == "right") imgStyle = "float:right;" + imgStyle
			 if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
			 var strNewHTML = "<span " + imgID + imgClass + imgTitle
			 + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
			 + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
			 + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
			 img.outerHTML = strNewHTML
			 i = i-1
		  }
	   }
	}
}

/* ############
pop ups
############# */
	
function openWindow(url,wx,wy) {
	p = window.open(url,"Privacy","width="+wx+",height="+wy+",locationbar=no,menubar=no,toolbar=no,scrollbars=yes,resizable=yes,fullscreen=no,status=yes");
	p.focus();
 }


