function call_ajax(url, div_to_update)
{
    new Ajax(url , {method: 'get', update: div_to_update, evalScripts: true, onComplete: function(){       
            /*
            if(effect == 'opacity')
            {
                div_to_update.effects({duration:500}).start({
                    'opacity':[0, 1]
                });
            }
            else if(effect)
            {          
                effect.style.cursor = "pointer"; 
                div_to_update.effects({duration: 1000, transition: Fx.Transitions.Bounce.easeOut}).start({'left':[630,3]})
            }
            else
                div_to_update.setStyle('display','block');
             */
      
        }}).request(); 

}

function product_highlight (id)
{   
    if($('products_image_list')) 
    {
        $('products_image_list').getElements('div.thumb').each(function(el){                    
            if ($(el.id + '_color') && el != $('thumb_' + id))
            {
                $(el.id + '_color').setStyle('display','none');        
                $(el.id + '_grey').setStyle('display','block');        
            }
        });
    }
    
    $('title_' + id + '_highlight').setStyle('display', 'block');     
    $('title_' + id + '_std').setStyle('display', 'none');
    
}

function product_downlight(id)
{
    if($('products_image_list')) 
    {
        $('products_image_list').getElements('div.thumb').each(function(el){      
            if($(el.id + '_color'))
            {
                $(el.id + '_color').setStyle('display','block');        
                $(el.id + '_grey').setStyle('display','none');        
            }
        }); 
    }
    
    $('title_' + id + '_std').setStyle('display', 'block');
    $('title_' + id + '_highlight').setStyle('display', 'none');
    
}
  
function designer_highlight(id)
{
    $('thumb_' + id + '_grey').setStyle('display','none'); 
    $('thumb_' + id + '_color').setStyle('display','block');    
    
    $('title_' + id + '_highlight').setStyle('display', 'block');     
    $('title_' + id + '_std').setStyle('display', 'none');
}

function designer_downlight(id)
{
    $('thumb_' + id + '_grey').setStyle('display','block'); 
    $('thumb_' + id + '_color').setStyle('display','none');     

    $('title_' + id + '_std').setStyle('display', 'block');
    $('title_' + id + '_highlight').setStyle('display', 'none');
}
  
function switch_product_closeup(openclose)
{     
    if (openclose == 1)
    {    
        $('img_switch_open').setStyle('display','none');
        $('img_switch_close').setStyle('display','block');
        $('image_closeup').effects({duration: 800, transition: Fx.Transitions.Quint.easeOut}).start({'left':[415,170]});
    }
    else
    {
        $('img_switch_open').setStyle('display','block');
        $('img_switch_close').setStyle('display','none');
        $('image_closeup').effects({duration: 800, transition: Fx.Transitions.Quint.easeOut}).start({'left':[170,415]});
    }
     
}
 
function highlight_opener(hl,div)
{
    if(hl == 1)
    {        
        $(div).setStyle('display', 'none');
        $(div + '_highlight').setStyle('display', 'block');
    }    
    else
    {
        $(div).setStyle('display', 'block');
        $(div + '_highlight').setStyle('display', 'none');         
    }    
}
 
function highlight_closer(hl)
{
    if(hl == 1)
    {
        $('img_closer').setStyle('display', 'none');
        $('img_closer_highlight').setStyle('display', 'block');
    }    
    else
    {
        $('img_closer').setStyle('display', 'block');
        $('img_closer_highlight').setStyle('display', 'none');         
    }         
}
 
function title_downlight(id)
{
    
    
    thumb_highlight_all();
}
 
function title_highlight(id)
{       
    

    thumb_highlight($('thumb_' + id));
}

function init_search()
{
    if($('search_term').value != '')
        location.href = '/products/find/' + $('search_term').value;    
}

/////////////////////////


document.addEvent('keydown', function(event){
    //The passed event parameter is already an instance of the Event class. 
    //alert(event.keyCode);   //Returns the lowercase letter pressed.
    if (event.keyCode == '13')        
        init_search();
    //alert(event.shift); //Returns true if the key pressed is shift.
    //if (event.key == 's' && event.control) alert('Document saved.'); //Executes if the user hits Ctr+S.
});