function resizeFont(type){
	var originalCss = 'http://www.saipem.it/contents/instance2/css2/'+type+'.css';
	css = document.createElement('link');
	css.href = originalCss;
	css.rel = 'stylesheet';
	css.type = 'text/css';
	css.id = '3a';
	
	
	// var css = '<link href="'+originalCss+'" rel="stylesheet" type="text/css" id="3a">';

	// alert(css);

	if(!document.getElementById('3a')){
		document.getElementsByTagName("head")[0].insertAdjacentElement("BeforeEnd",css);
		//document.getElementById('head').addChild(css);
	}else{
		var a3 = document.getElementById('3a');
		a3.href = originalCss;
	}
	setCookieRF(type);
}

function setCookieRF(type){
	if(type != ''){
		document.cookie = 'rf-to' + '='+type+'' + '; path=/';
	}
}

function getCookieRF(){
	if (document.cookie.length > 0) {
		var source = new Array();
		source = document.cookie.split(';');
		//alert(source[0]);
		for(i=0;i<source.length;i++){
			if(source[i].indexOf('rf') == 0){
				//alert('ok');
				var rfto = source[i].substr(source[i].indexOf("=")+1);
				//alert(rfto);
				resizeFont(rfto);
			}else if(source[i].charAt(0) == ' ' && source[i].indexOf(' rf') == 0){
				var rfto = source[i].substr(source[i].indexOf("=")+1);
				//alert(rfto);
				resizeFont(rfto);
			}
		}
	}	
}

$(function(){
	$(".play_video").click(function () {
		var link_video = $(this).attr("rel");
		$("a").removeClass("bold");
		$(this).addClass("bold");
		
		//carico il nuovo video (comprensivo di player)
		video(link_video, 'video_primo_piano', false, 465, 340);
	});
});

function video(flv, id, autoPlay, width, height, preview_image) {
	var flashvars = {
		videoUrl: moviePath + '/' + flv,
		autoPlay: autoPlay ? 'play' : 'stop',
		videoImg: preview_image != null? preview_image : ''
	};
	var params = {
		allowScriptAccess: 'sameDomain',
		allowFullScreen: 'true',
		wmode: 'transparent'
	};
	var attributes = {
		id: id,
		name: id
	};
	
	swfobject.embedSWF(imgPath + '/video-player.swf', id, width, height, '9.0.0', false, flashvars, params, attributes);
}

