var info = [];
info[1] = 'CAMARGUE';
info[2] = 'NYX';
info[3] = 'BIANCHI';
info[4] = 'UC';
info[5] = 'ENTER GALLERIA';
info[6] = 'HEAD';
info[7] = 'RÄTT MURAT & PUTSAT';
info[8] = 'YNIQ';
info[9] = 'PODIUM';
info[10] = 'PORSCHE';
info[11] = 'OSCARS';
info[12] = 'REST.1900';
info[13] = 'NORDIER';
info[14] = 'FULLSTRIKE';
info[15] = 'KUNGSMONTAGE';
info[16] = 'ROOMSERVICE';
info[17] = 'INDUSTRIFONDEN';
info[18] = 'SAVOR';
info[19] = 'HELLS KITCHEN';
info[20] = 'VÄLLINGBY PARKSTAD';
info[21] = 'SMÖGEN MAGASINET';
info[22] = 'MR MUSIC';
info[23] = 'TOTT HOTEL';
info[24] = 'AMBASSADEUR';
info[25] = 'SIVAB';
info[26] = 'SVEAFASTIGHETER';
info[27] = 'ERICS';
info[28] = 'HEMKÖP';
info[29] = 'KILGREN';
info[30] = 'DIVERSE PRINT';

/**
 * bw_to_color
 * A small script to change black/white images to colored ones.
 *
 * param	path to colored images
 * param	path to black/white images
 *
 * note:	last slash is needed
 * note:	jquery needed
 */
function bw_to_color (img_path, bw_img_path)
{
var original = [];
var id;
    $('.hover').mouseenter(function(){
    	// fetch src from img
    	var path = $(this).attr('src');
    	
    	id = $(this).attr('id');
    	
    	// if not an image, return
		//if($(id).attr('tagName') != 'IMG')return;
    	// remove folders from string
    	path = path.split('/');
    	var new_path;
       	// set filename
    	new_path = path[path.length - 1];
    	var temp = [id, new_path];
    	original.push(temp);
    	// insert new src
    	$(this).attr('src', img_path + new_path);
    	$(this).css('opacity',1)
    	
    	if(original.length == 1)
    	{
    	var stripped_id = id.split('_');
		stripped_id = stripped_id[1];
		
		//console.log(stripped_id)
		
		$('#companyname').html(info[stripped_id])
		} else $('#companyname').html('')
    	
    }).mouseleave(function(){
    id = '#' + $(this).attr('id');
    //console.log(id)
       	if($(id).attr('tagName') != 'IMG')return;
    	// return to original
    	for (var i = 0; i < original.length; i++)
    	{
    		$('#' + original[i][0]).attr('src', bw_img_path + original[i][1]);
    		$('#' + original[i][0]).css('opacity',0.1)
    	}
    	
    	original = [];
    	$('#companyname').html('')
    	
    }) 
}

function toggle_menu()
{
	if(not_link == 0)return;
	var px = open == 1 ? parseInt($('#menu').height()) - 18 + 'px' : '0px';
	var px2 = open == 1 ? '40px' : '192px';

	$('#menu').stop().animate({
		marginTop: px,
	}, 300, 'swing')
		
	$('#third_menu').stop().animate({
		bottom: px2,
	}, 300, 'swing')
	
	open = open == 0 ? 1 : 0;
}

$(window).load(function() {    

        var theWindow        = $(window),
            $bg              = $("#bg"),
            aspectRatio      = $bg.width() / $bg.height();

        function resizeBg() {

                if ( (theWindow.width() / theWindow.height()) < aspectRatio ) {
                    $bg
                        .removeClass()
                        .addClass('bgheight');
                } else {
                    $bg
                        .removeClass()
                        .addClass('bgwidth');
                }

        }

        theWindow.resize(function() {
                resizeBg();
        }).trigger("resize");
});
