/**
 * Tidbit : window.openCentered
 */

Object.extend(window,{	
	openedWindows: {},
	openCentered: function(location,name,params){
		this.openedWindows[name] = window.open(location,name,$H({
			width: 800,
			height: 600,
			left: (screen.width ? (screen.width - (params && params.width ? params.width : 800)) / 2 : 0),
			top: (screen.height ? (screen.height - (params && params.height ? params.height : 600)) / 4 : 0),
			dependent: true,
			directories: true,
			fullscreen: false,
			location: true,
			menubar: true,
			resizable: true,
			scrollbars: true,
			status: true,
			toolbar: true
		}).merge(params || {}).inject('',function(str,item){
			if(item[1] == true)
				value = 'yes';
			else if(item[1] == false)
				value = 'no';
			else
				value = item[1];
			return str + item[0] + '=' + value + ',';
		}).replace(/\,$/,''));
		this.openedWindows[name].focus();
		return this.openedWindows[name];
	}
});


function popup(url, w, h) { 

  if(!w) w = 300;
  if(!h) h = 300;

  window.openCentered(url,'popup',{
      width : w,
      height : h,
      status : false,
      toolbar : false,
      menubar : false,
      location : false      
  });
  return false;
} 

function openPreview(url, w, h) {
    popup(url, w, h);
    return false;
}



function add_to_cart(href) {
    new Ajax.Request(href); 

    $('warenkorb_link').show();
    $('show_cart').show();        
    $('remove_from_cart').show();        
    $('add_to_cart').hide();        
    return false;

}

function remove_from_cart(href) {
    new Ajax.Request(href); 

    $('show_cart').hide();        
    $('remove_from_cart').hide();        
    $('add_to_cart').show();        
    return false;
    
}


function activate_link(id) {
    
    $$('#' + id + ' a').each(function(el) {
        el.addClassName('active');
    });
    
}

function deactivate_link(id) {

    $$('#' + id + ' a').each(function(el) {
        el.removeClassName('active');
    });

}









