function removebookmark(id) {
        c = confirm('Weet je het zeker?')
        if (c == true) {
         new Ajax.Request('/forms/remove_bookmark/'+id,
        {
                asynchronous:true,
                evalScripts:true,
                onComplete:function(request){ $(id).remove()},
                onLoading:function(request){
                        $(id).innerHTML='<img src=\'/themes/inspiratiepost/images/spinner.gif\'><p>&nbsp;</p>'}
                });
}
}

function toggleSearch() {
	$('s_result').innerHTML = '';
        $('s').focus();
}

function toggleContentMenu(active,inactive) {
	$(active).removeClassName('active');
	$(inactive).addClassName('active');
	
}

function activateListItem(id) {
	if ($(id) != null) { 
		$(id).addClassName('active');
	}
}

function setShippingCosts(value) {
       prijs = '0.00';
       display = '&#8364 0.00';
       if (value == 'bezorgen') {
         prijs = '7.50';
         display = '&#8364 7.50';
       }
       $('orderBezorgenprijs').value = prijs;
       $('currencyBezorgenprijs').innerHTML = display;
}

function copyAddress(address,copy) {
         addressfields = ['voornaam','achternaam','adres','postcode','plaats'];
         addressfields.each(function(field) {
           if ($(copy+field) != null && $(address+field) != null) {
             $(address+field).value = $(copy+field).value; 
           }
         });
}

function setOrderStatus(status) {
       ids = status.split(",")
       ids.each(function(id) {
         switch(id) {
           case '309':
             $(id).getElementsByClassName('thumbnail')[0].firstChild.src='http://static.halveflesjes.nl/picture/get/246'
           break;
           case '304':
             $(id).getElementsByClassName('thumbnail')[0].firstChild.src='http://static.halveflesjes.nl/picture/get/247'
           break;
           case '299':
             $(id).getElementsByClassName('thumbnail')[0].firstChild.src='http://static.halveflesjes.nl/picture/get/248'
           break;
           case '294':
             $(id).getElementsByClassName('thumbnail')[0].firstChild.src='http://static.halveflesjes.nl/picture/get/249'
           break;
           case '289':
             $(id).getElementsByClassName('thumbnail')[0].firstChild.src='http://static.halveflesjes.nl/picture/get/250'
           break;
           case '284':
             $(id).getElementsByClassName('thumbnail')[0].firstChild.src='http://static.halveflesjes.nl/picture/get/251'
             $('314').getElementsByClassName('thumbnail')[0].firstChild.src='http://static.halveflesjes.nl/picture/get/252'
           break;
         }	
       });
       if (ids.indexOf('294') == -1) {
             // reset bezorgadres
             $('294').getElementsByClassName('thumbnail')[0].firstChild.src='http://static.halveflesjes.nl/picture/get/128';
       };
}

function resetOrderStatus(status) {
       ids = status.split(",")
       ids.each(function(id) {
         switch(id) {
           case '309':
             $(id).getElementsByClassName('thumbnail')[0].firstChild.src='http://static.halveflesjes.nl/picture/get/125'
           break;
           case '304':
             $(id).getElementsByClassName('thumbnail')[0].firstChild.src='http://static.halveflesjes.nl/picture/get/126'
           break;
           case '299':
             $(id).getElementsByClassName('thumbnail')[0].firstChild.src='http://static.halveflesjes.nl/picture/get/127'
           break;
           case '294':
             $(id).getElementsByClassName('thumbnail')[0].firstChild.src='http://static.halveflesjes.nl/picture/get/128'
           break;
           case '289':
             $(id).getElementsByClassName('thumbnail')[0].firstChild.src='http://static.halveflesjes.nl/picture/get/129'
           break;
         }
       });
}


function wijnpakketlink(href) {
 	if ($('wijnpakket') == null) {
	  document.location = href;	
	}
}

function toggleruler(e,size) {
        image = '243';  //default image	
	if (e.src.indexOf('243') != -1) {
	  if (size.indexOf('37') != -1) {
	    image = '240'; //37.5cl
	  } 
	  if (size.indexOf('50') != -1) { 
	    image = '241'; //50cl.
          }	
	};
	e.src = 'http://static.halveflesjes.nl/picture/get/' + image;
}

function addSpinnerClass(target, e) {
	Element.addClassName(e, target + 'spinner');
}

function removeSpinnerClass(target, e) {
	Element.removeClassName(e, target + 'spinner');
}

function updatePresentation (index, image) {
	
	var navelements = $$('li.active')
	for (var i=0; i < navelements.length; i++) {
		navelements[i].removeClassName('active');
		navelements[i].addClassName('inactive');		
	}
	$('presentationindex_' + index).removeClassName('inactive');
	$('presentationindex_' + index).addClassName('active');
	$('presentationimage').update("<img src=\""+ image +"\" >");
}


// get absolute position for element, either for tl is 'top' or 'left'
function getAbsPosition(e,tl) {
	var val = 0;
	while ( e.nodeName != "BODY" ) {
	val += parseInt( ( tl == 'top' ) ? e.offsetTop : e.offsetLeft );
	e = e.parentNode;
	}
	return val;
  }


// png fix for IE6
function findImages(e) {
	try {
		var browser=navigator.appName;
		var arVersion = navigator.appVersion.split("MSIE")
		var version = parseFloat(arVersion[1])
		
		if (browser == "Microsoft Internet Explorer" && (version >= 6 && version < 7))  {		
			// find image elements in element block
			if (e != null) {
				var elementList = e.descendants();
				for(var i=0; i< elementList.length; i++) {
					if (Element.inspect(elementList[i]).toUpperCase().indexOf("<IMG") != -1) {
						fixPNG(elementList[i]);
					}
				}
			}
		}
	}catch (e) {
		return null
	}
}

//fix PNG Transparency
function fixPNG(img) {
	if (img.src != null) {
    	var imgName = img.src.toUpperCase();
	    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;float:left;margin:" + img.getStyle("margin")+ ";width:" + img.getStyle("width")+ ";height:" + img.getStyle("height")+";";
	    var imgAttribs = img.attributes;
	    for (var j=0; j<imgAttribs.length; j++) {
	    	var imgAttrib = imgAttribs[j];
	    	if (imgAttrib.nodeName == "align"){		  
	       		if (imgAttrib.nodeValue == "left") imgStyle = imgStyle + "float:left;" 
	       		if (imgAttrib.nodeValue == "right") imgStyle = imgStyle + "float:right;" 
	       		break
	    	}
	     }
	    var strNewHTML = "<span " + imgID + imgClass + imgTitle;
	    strNewHTML += " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
	    strNewHTML += "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
	    strNewHTML += "(src='" + img.src + "', sizingMethod='scale');\""
	    strNewHTML += "></span>" 
	    img.outerHTML = strNewHTML
	} else {
	//	alert ("no source");
	}
}

// logout button
function logout_mouseover() {
	$('designlayerminibox_0').src='http://static.inspiratiepost.nl/picture/get/426 '
	if ($('ie6_imgspan_designlayerminibox_0') != null) {
		Element.setStyle('ie6_imgspan_designlayerminibox_0', {filter:'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'http://static.inspiratiepost.nl/picture/get/426 \')'} );
	}	
}

function logout_mouseout() {
	$('designlayerminibox_0').src='http://static.inspiratiepost.nl/picture/get/425'
	if ($('ie6_imgspan_designlayerminibox_0') != null) {
		Element.setStyle('ie6_imgspan_designlayerminibox_0', {filter:'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'http://static.inspiratiepost.nl/picture/get/425\')'} );
	}
}
function logout_click() {
	document.location.href='/logout';
}


