$('document').ready( function () {
	/* INIT */

	var auto_refresh = setInterval( function() {
		var reload = $('#reload').val();

		if(reload == 1){
			showNext();
		}
	}, 5000);

	var logo_refresh = setInterval( function() {
		showNextLogo();
	}, 3000);
}); 

//Visa nästa maskin
function showNext(){

	var active = parseInt($('#act_num').val());
	var max = parseInt($('#max_num').val());

	active++;

	$('#act_num').attr('value', active);

	if(active > max){
		$('#act_num').attr('value', 1);
		active = 1;
	}

	$('.machine_box').fadeOut('slow');
	$('#mac_'+active).fadeIn('slow');
}

//Visa nästa logga
function showNextLogo(){

	var active = parseInt($('#logo_act_num').val());
	var max = parseInt($('#logo_max_num').val());

	active++;

	$('#logo_act_num').attr('value', active);

	if(active > max){
		$('#logo_act_num').attr('value', 1);
		active = 1;
	}

	$('.logo_box').fadeOut('slow');

	$('#logo_'+active).fadeIn('slow');
}

function changeImg(img){

	$('#maskin .active').removeClass('active');
	$('#t_'+img).addClass('active');

	$('.image').fadeOut('slow');
	$('#'+img).fadeIn('slow');

}

function nemo(namn,foretag){
	location.href= 'mailto:'+namn+'@'+foretag;
	return false;
}

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

function fixPNG(myImage) 
{
	if ((version >= 5.5) && (version < 7) && (document.body.filters)) 
	{
	var imgID = (myImage.id) ? "id='" + myImage.id + "' " : ""
	var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : ""
	var imgTitle = (myImage.title) ? 
			 "title='" + myImage.title  + "' " : "title='" + myImage.alt + "' "
	var imgStyle = "display:inline-block;" + myImage.style.cssText
	var strNewHTML = "<span " + imgID + imgClass + imgTitle
				+ " style=\"" + "width:" + myImage.width 
				+ "px; height:" + myImage.height 
				+ "px;" + imgStyle + ";"
				+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
				+ "(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>"
	 myImage.outerHTML = strNewHTML	  
	}
}



function popup (url, width, height, status, menu, resizable) {
	var time = new Date();
	var name = Math.floor((Math.random() * Math.round(time.getTime())));

	var prop = 'toolbar=no,location=no,directories=no,scrollbars=yes,copyhistory=no,';
	prop += 'status='+ (status ? 'yes' : 'no') +',';
	prop += 'resizable='+ (resizable ? resizable : 'yes') + ',';
	prop += 'menu='+ (menu ? 'yes' : 'no') +',';
	prop += 'width='+ (width ? width : 500) +',';
	prop += 'height='+ (height ? height : 400);

	var win = window.open(typeof(url) == 'string' ? url : url.href, name, prop);
	win.focus();
	
	return false;
}