$(document).ready(function(){
	
	beautyLink();
if($('.doc_open')){
$('.doc_open a').each(function(){
	$(this).click(function(){
	window.open($(this).attr('href'),'_blank');	
	});
	
});
}
	var b = navigator.userAgent.toLowerCase();

// Figure out what browser is being used
		jQuery.browser = {
			safari: /webkit/.test(b),
			opera: /opera/.test(b),
			msie: /msie/.test(b) && !/opera/.test(b),
			msie6: /msie 6.0/.test(b) && !/opera/.test(b),
			mozilla: /mozilla/.test(b) && !/(compatible|webkit)/.test(b)
		};

//accordion organi
			jQuery.fn.extend({  
			       accordion: function() {       
			          return this.each(function() {
			  		if($(this).data('accordiated'))
			  			return false;						
			  		$.each($(this).find('div'), function(){
			  			$(this).data('accordiated', true);
			  			$(this).hide();
			  		});
			  		$.each($(this).find('a'), function(){
			  			$(this).click(function(e){
			  				activate(this);
			  				return false;
			  			});
			  		});
			  		var active = (location.hash)?$(this).find('a[href=' + location.hash + ']')[0]:'';
			  		if(active){
			  			activate(active, 'toggle');
			  			$(active).parents().show();
			  		}
			  		function activate(el,effect){
			  			$(el).toggleClass('active').siblings().removeClass('active').children('div').slideUp('slow');
			  			$(el).siblings('div')[(effect || 'slideToggle')]((!effect)?'slow':null);
			  		}
			   });
			 } 
			});


// start accordion with the first div open

	if ($('.organi').length>0){
		$(".organi").accordion();	

		$(".organi").attr("id", function (numb) {
			var valore = "acc_" + numb
			  return valore;
			 })
		$("#acc_0").each(function(){
			$("#acc_0 a.title").addClass('active');
			$("#acc_0 div").show();
		});



// riga si riga no

var nListElem= $('#dati').find('.organi').length;

for (e=0;e<nListElem;e++){
	var rifDiv= '#acc_'+e + ' ' + ".main_division li.prime";

	$(rifDiv).attr("id", function (num) {
			  return num;
			 }).each(function(){
					if(( parseInt($(this).attr("id")) % 4 <= (0) ) || ((parseInt($(this).attr("id")) - 1) % 4 <= (0) ) ) {
						$(this).addClass('grey_li');
					}
				});
	
	var subEle = '#acc_'+e + ' ' + ".main_division li ul li";		
	$(subEle).attr("id", function (numero) {
		  return numero;
		 }).each(function(){
			if(parseInt($(this).attr("id")) % 2 == 1){
				$(this).css({'text-align':'right', 'width':'40%'});
			} 
		});
	}
}

ReconizeIE();

// main menu	
	
	var mainSpeed = 200;
	
	$('#main_menu li a').css( {"background-image":'url("/images/bg/menu_left.png")', 'backgroundPosition':'0 33px'});
	$('#main_menu li a span').css( {"background-image":'url("/images/bg/menu_right.png")', 'backgroundPosition':'100% 33px'});
	$('#main_menu li.active a').css( {backgroundPosition: "0 0"} );
	$('#main_menu li.active a span').css( {backgroundPosition: "100% 0"} );
	
	$('#main_menu li ').mouseover(function(){
		$('a',this).stop().animate({backgroundPosition:'(0 0px)'}, {duration:mainSpeed}).css({'color':'#000', 'cursor':'pointer'});
		$('a span', this).stop().animate({backgroundPosition:"(100% 0px)"}, {duration:mainSpeed});	
	});
	$('#main_menu li').mouseout(function(){
		$('a',this).stop().animate({backgroundPosition:"(0 33px)"}, {duration:mainSpeed}).css({'color':'#fff', 'cursor':'default'});
		$('a span', this).stop().animate({backgroundPosition:"(100% 33px)"}, {duration:mainSpeed});
	});
	$('#main_menu li.active').mouseout(function(){
		$('a',this).stop().animate({backgroundPosition:'(0 0px)'}, {duration:mainSpeed}).css({'color':'#000', 'cursor':'pointer'});
		$('a span', this).stop().animate({backgroundPosition:"(100% 0px)"}, {duration:mainSpeed});
	});
	$('#service_link li').mouseover(function(){
		$(this).stop().animate({backgroundPosition:'(0 0px)'}, {duration:mainSpeed});
		$('a',this).css({'color':'#fff', 'cursor':'pointer'});
	});
	$('#service_link li').mouseout(function(){
			$(this).stop().animate({backgroundPosition:'(0 -22px)'}, {duration:mainSpeed});
			$('a',this).css({'color':'#000', 'cursor':'pointer'});
	});
	
	
	// view all for home 
	
	$('.view_all').mouseover(function(){
	 $(this).stop().animate({backgroundPosition:'(0 0px)'}, {duration:200}).css({'color':'#000', 'cursor':'pointer'});
	});
	$('.view_all').mouseout(function(){
	 $(this).stop().animate({backgroundPosition:'(0 -45px)'}, {duration:200}).css({'color':'#000', 'cursor':'pointer'});
	});
	
	$('#self_open').click(function(){
		window.open($('a',this).attr('href'),'_self');
	});
	
	
	// righe alternate tabella
	
	$('tr:odd').addClass('odd');
	$('tr:even').addClass('even');
	
	$('#calendar_list li:even').addClass('grey');
		
	//link generici
	
	if ($('.acrobat_down').length>0) {	
			$(".acrobat_down").attr('href','http://get.adobe.com/it/reader/');
			$(".acrobat_down").attr('target','_blank');
	}	
	if ($('.zip_down').length>0) {	
			$(".zip_down").attr('href','http://www.winzip.com/downwz.htm');
			$(".zip_down").attr('target','_blank');
	}
	
	// news home page
	
	$('.first_news li').mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(0 0)"}, {duration:300}).css({'color':'#444', 'cursor':'default'}).css({'color':'#444', 'cursor':'pointer'});
			$('.arrow',this).stop().animate({backgroundPosition:"(0px 0)"}, {duration:300});
	});	
	$('.first_news li').mouseout(function(){
			$(this).stop().animate({backgroundPosition:"(-1000% 0%)"}, {duration:300}).css({'color':'#000', 'cursor':'default'});
			$('.arrow',this).stop().animate({backgroundPosition:"(-10px 0)"}, {duration:300});
	});
	$('.first_news li:last').css('border-bottom','1px solid #FF9D01');
	
	$('.first_news li').click(function(){
		window.open($('a',this).attr('href'),'_blank');
	});
	
	$('.first_news li a.pdf').click(function(e){
		e.preventDefault();
	});
	
	if($('.first_news li.first img').length <= 0){
		
		$('.first_news li.first h2').css('width','100%');
		$('.first_news li.first p').css('width','100%');
	}
	
	
	// clendario home
			
  //  $('#calendar li').mouseover(function(){
  //  	$(this).css({'border-top':'1px solid #fff', 'padding-top':'5px'});
  //  	$('h3',this).css({'color':'#fff', 'cursor':'pointer'});
  //  	$('span',this).css({'color':'#fff', 'cursor':'pointer'});
  //  });	
  //  $('#calendar li').mouseout(function(){
  //  $(this).css({'border-top':'1px solid #fff', 'padding-top':'5px'});
  //  	$('h3',this).css({'color':'#000'});
  //  	$('span',this).css({'color':'#000'});
  //  });
    $('#calendar a#view_cal').mouseover(function(){
    	$('#calendar').stop().animate({backgroundPosition:"(100% 0%)"}, {duration:200}).css({'color':'#000', 'cursor':'pointer'});
    });	
    $('#calendar a#view_cal').mouseout(function(){
    	$('#calendar').stop().animate({backgroundPosition:"(100% -40px)"}, {duration:200}).css({'color':'#000', 'cursor':'pointer'});
    });		
    		
	//sidebar
			
	var anSide = 200;
	
	$('#sidebar li').click(function(){
		location.href = $('a',this).attr('href');
	});
	
	$('#sidebar li').mouseover(function(){
		$(this).stop().animate({backgroundPosition:"(0px -30px)"}, {duration:anSide});
		$(this).css({'cursor':'pointer'});
	});
	$('#sidebar li').mouseout(function(){
		$(this).stop().animate({backgroundPosition:"(0 0)"}, {duration:anSide});
	});
	$('#sidebar li.active').mouseout(function(){
		$(this).stop().animate({backgroundPosition:"(0 -30px)"}, {duration:anSide});
	});
	
	
	// sort table for years and menu style
	
	sortTable();		
  activateFirstTableTab();
	$('.menu_table li').mouseover(function(){
		$('a',this).stop().animate({backgroundPosition:"( 0px 3px)"}, {duration:mainSpeed});
		$('a span',this).stop().animate({backgroundPosition:"( 100% 3px)"}, {duration:mainSpeed});
	});
	$('.menu_table li').mouseout(function(){
		$('a',this).stop().animate({backgroundPosition:"( 0px 30px)"}, {duration:mainSpeed});
		$('a span',this).stop().animate({backgroundPosition:"( 100% 30px)"}, {duration:mainSpeed});
	});
	

	// display form inside page 
	
	/*if ($('#framespace').length>0) {
			$('#framespace').hide();
		$('.email').click(function(){
			$('#framespace').show();
			return false;
		});
		$('#close_form').click(function(){
			$('#framespace').hide();
			return false;
		});
	}*/
	
	ReplaceHome();
	PlayVideo();
	//CountryLand();	
	AnimateBg();
	PrintThisPage();
	MapsPage();
	MapsInter();
	CalendarEve();

	if ($('select').length>0) {	
		SkinSelect();	
	}

});

// Per input e textarea style

ReconizeIE = function(){	
ie = (navigator.appName == "Microsoft Internet Explorer");
   if (ie) {
	  $('#sidebar li').each(function() {
				PIE.attach(this);
		});
		$('#choose_country li').each(function() {
				PIE.attach(this);
		});

		$('#contact_form').each(function() {
				 PIE.attach(this);
		});		
		$('.submit').each(function() {
				 PIE.attach(this);
		});
			$('#contact_page input').each(function() {
				   PIE.attach(this);
			});
		$('.wrapper input').each(function() {
			   PIE.attach(this);
		});	
		$('.wrapper textarea').each(function() {
			   PIE.attach(this);
		});		
		$('#framespace').each(function() {
			   PIE.attach(this);
		});	
		$('#contact_form input').each(function() {
		   PIE.attach(this);
		});
		$('#contact_form textarea').each(function() {
		   PIE.attach(this);
		});
	}
}

SkinSelect =function(){
	    $.fn.select_skin = function (w) {
	        return $(this).each(function(i) {
	            s = $(this);
	            if (!s.attr('multiple')) {
	                s.wrap('<div class="custom_select"></div>');
	                c = s.parent();
	                c.children().before('<div class="custom_text">&nbsp;</div>').each(function() {
	                    if (this.selectedIndex >= 0) $(this).prev().text(this.options[this.selectedIndex].innerHTML)
	                });
									s.width(192);
	                s.height(27);
	                c.width(s.outerWidth()-2);
	                c.height(s.outerHeight()-2);

	                // skin the container
	                c.css('background-color', s.css('background-color'));
	                c.css('color', s.css('color'));
	                c.css('font-size', s.css('font-size'));
	                c.css('font-family', s.css('font-family'));
	                c.css('font-style', s.css('font-style'));
	                c.css('position', 'relative');
	                s.css( { 'opacity': 0,  'position': 'relative', 'z-index': 100 } );
	                var t = c.children().prev();
 t.height(c.outerHeight()-s.css('padding-top').replace(/px,*\)*/g,"")-s.css('padding-bottom').replace(/px,*\)*/g,"")-t.css('padding-top').replace(/px,*\)*/g,"")-t.css('padding-bottom').replace(/px,*\)*/g,"")-2);	                t.width(c.innerWidth()-s.css('padding-right').replace(/px,*\)*/g,"")-s.css('padding-left').replace(/px,*\)*/g,"")-t.css('padding-right').replace(/px,*\)*/g,"")-t.css('padding-left').replace(/px,*\)*/g,"")-c.innerHeight());
	                t.css( { 'opacity': 100, 'overflow': 'hidden', 'position': 'absolute', 'text-indent': '0px', 'z-index': 1, 'top': 0, 'left': 0 } );
	                // add events
	                c.children().click(function() {
	                    t.text( (this.options.length > 0 && this.selectedIndex >= 0 ? this.options[this.selectedIndex].innerHTML : '') );
	                });
	                c.children().change(function() {
	                    t.text( (this.options.length > 0 && this.selectedIndex >= 0 ? this.options[this.selectedIndex].innerHTML : '') );
	                });
	             }
	        });
	    }
	
			$(".smallForm select").select_skin();
			$("#maps_form select").select_skin();
			$(".table_top select").select_skin();
			$(".title_graph select").select_skin();
			$(".wrapper select").select_skin();	
}

// table sort years 

 LoadTable = function(init){
							$(".table_target .doc_year").remove();
							var table = $('#content_load').html();
							$(table).clone().appendTo('.table_target');				
}

activateFirstTableTab = function(){

					LoadTable();
      var first = $('.menu_table').children("li:eq(1)").children().first();
					$('.menu_table li').removeClass('active');
					first.parent().addClass('active');
					var filter = first.attr('id');
					var remain ="mainth";
					if ( ($(".table_target .doc_year tr").attr('class')!==filter)){
							var elClass =".doc_year tr." + filter;
							var elRemain =".doc_year tr." + remain;
							 $(".table_target .doc_year tr").not(elClass).not(elRemain).remove(); 
				   }

}


sortTable = function(){
	 LoadTable();
	$(".doc_year tr td.years").attr("id",function(line){
			return line;
		}).each(function(){
			var valore = $(this).text();
		   $(this).parent().addClass(valore);
		 });

	$(".menu_table li:gt(6)").hide();
	$(".menu_table li.all").show();	
	$(".menu_table li a").each(function(){
				if($(this).parent().hasClass('all')){
						$("span", this).html();
				}else{
				     $("span", this).html( this.id );
				}
				$(this).click(function(event){
					LoadTable();
					$('.menu_table li').removeClass('active');
					$(this).parent().addClass('active');
					var filter = this.id;
					var remain ="mainth";
					if ( ($(".table_target .doc_year tr").attr('class')!==filter)){
						var elClass =".doc_year tr." + filter;
						var elRemain =".doc_year tr." + remain;
						$(".table_target .doc_year tr").not(elClass).not(elRemain).remove(); 
					}
					event.preventDefault();
					});
			});
	$('.menu_table li.all ').click(function(){
			LoadTable();
			var year = $(this).attr('id');
			var limit = '2006';
			$(".table_target .doc_year tr").each(function()
			{
				$(this).removeClass('odd');
				 $(this).removeClass('even');
			var onlyears = parseInt($(this).attr('class'));	
			
			if(onlyears >= limit)
				{
					$(this).remove();
				}
				$('.table_target .doc_year tr:odd').addClass('odd');
				$('.table_target .doc_year tr:even').addClass('even');
				//if( $(this).attr('class').replace("odd ", "").replace("even ","") < limit)
				//{
				//	$(this).remove();
				//}
			});
	});
}



// mappa for homepage 

MapsInter=function(){
	
	$('#interactive_map a.usa').mouseover(function(){
		$('#interactive_map a.usa').addClass('active');
	}).click(function(){
		$('#interactive_map a').removeClass('selected');
		$('#interactive_map a.usa').addClass('selected');
	});
	$('#interactive_map a.eu').mouseover(function(){
		$('#interactive_map a.eu').addClass('active');
	}).click(function(){
			$('#interactive_map a').removeClass('selected');
			$('#interactive_map a.eu').addClass('selected');
		});
	$('#interactive_map a.or').mouseover(function(){
		$('#interactive_map a.or').addClass('active');
	}).click(function(){
			$('#interactive_map a').removeClass('selected');
			$('#interactive_map a.or').addClass('selected');
		});
	
	$('#interactive_map a').mouseout(function(){
		$('#interactive_map a').removeClass('active');
	});
}


MapsPage=function(){
	
	// per attivare il country secondo scelta dalla home
	if($('#maps').hasClass('america')){
		$('a.usa').addClass('select').parent().addClass('active');
	}else if($('#maps').hasClass('europe')){
		$('a.eu').addClass('select').parent().addClass('active');
	}else{
		$('a.est').addClass('select').parent().addClass('active');
	};
	
	$('#choose_country li').mouseover(function(){
		$(this).stop().animate({backgroundPosition:"(0px -30px)"}, {duration:300}).css({'cursor':'pointer'});	
	});
	$('#choose_country li').mouseout(function(){
		$(this).stop().animate({backgroundPosition:"(-400px -30px)"},{duration:300});
	});
	
	$('#choose_country li').click(function(){	
		$('#choose_country li').removeClass();
		$('#selectBy_map a').removeClass('select');
		if($('a',this).hasClass('est')){
			$('a.est').addClass('select').parent().addClass('active');
		}
		else if($('a',this).hasClass('eu')){
			$('a.eu').addClass('select').parent().addClass('active');
		}
		else if($('a',this).hasClass('usa')){
			$('a.usa').addClass('select').parent().addClass('active');
		}	
	});
	
	$('#selectBy_map a').click(function(){	
		$('#choose_country li').removeClass();
		$('#selectBy_map a').removeClass('select');
		if($(this).hasClass('est')){
			$('a.est').addClass('select').parent().addClass('active');
		}
		else if($(this).hasClass('eu')){
			$('a.eu').addClass('select').parent().addClass('active');
		}
		else if($(this).hasClass('usa')){
			$('a.usa').addClass('select').parent().addClass('active');
		}	
	});
	
}


// print this page (note - privacy - calendar) 

PrintThisPage= function(){
 $('.print_page').click(function(){
		var headerPrint ='<img id="page_print" src="/images/printpage.jpg"/>';
		$('#main_wrapper').prepend(headerPrint);
		window.print(); 
		$("#page_print").remove();
		return false;
	});
	
	$('.print_page').mouseover(function(){
			$('.print_page').stop().animate({backgroundPosition:"(0 0)"}, {duration:200});
	});
	$('.print_page').mouseout(function(){
			$('.print_page').stop().animate({backgroundPosition:"(0 -65px)"}, {duration:200});
	});
}
 
// no outline for link

beautyLink = function (){
	var a = document.getElementsByTagName('A');
	for(i=0;i< a.length;i++) {
	  a[i].onmousedown = function() {
	    this.blur(); 
	    this.hideFocus = true;
	    this.style.outline = 'none';
	  }
	  a[i].onmouseout = a[i].onmouseup = function() {
	    this.blur();
	    this.hideFocus = false; 
	    this.style.outline = 'none';
	  }
	}
}

AnimateBg = function (){
	if(!document.defaultView || !document.defaultView.getComputedStyle){ // IE6-IE8
	                var oldCurCSS = jQuery.curCSS;
	                jQuery.curCSS = function(elem, name, force){
	                        if(name === 'background-position'){
	                                name = 'backgroundPosition';
	                        }
	                        if(name !== 'backgroundPosition' || !elem.currentStyle || elem.currentStyle[ name ]){
	                                return oldCurCSS.apply(this, arguments);
	                        }
	                        var style = elem.style;
	                        if ( !force && style && style[ name ] ){
	                                return style[ name ];
	                        }
	                        return oldCurCSS(elem, 'backgroundPositionX', force) +' '+ oldCurCSS(elem, 'backgroundPositionY', force);
	                };
	        }
	        var oldAnim = $.fn.animate;
	        $.fn.animate = function(prop){
	                if('background-position' in prop){
	                        prop.backgroundPosition = prop['background-position'];
	                        delete prop['background-position'];
	                }
	                if('backgroundPosition' in prop){
	                        prop.backgroundPosition = '('+ prop.backgroundPosition;
	                }
	                return oldAnim.apply(this, arguments);
	        };
	        function toArray(strg){
	                strg = strg.replace(/left|top/g,'0px');
	                strg = strg.replace(/right|bottom/g,'100%');
	                strg = strg.replace(/([0-9\.]+)(\s|\)|$)/g,"$1px$2");
	                var res = strg.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);
	                return [parseFloat(res[1],10),res[2],parseFloat(res[3],10),res[4]];
	        }
	        $.fx.step. backgroundPosition = function(fx) {
	                if (!fx.bgPosReady) {
	                        var start = $.curCSS(fx.elem,'backgroundPosition');

	                        if(!start){//FF2 no inline-style fallback
	                                start = '0px 0px';
	                        }

	                        start = toArray(start);

	                        fx.start = [start[0],start[2]];

	                        var end = toArray(fx.options.curAnim.backgroundPosition);
	                        fx.end = [end[0],end[2]];

	                        fx.unit = [end[1],end[3]];
	                        fx.bgPosReady = true;
	                }
	                //return;
	                var nowPosX = [];
	                nowPosX[0] = ((fx.end[0] - fx.start[0]) * fx.pos) + fx.start[0] + fx.unit[0];
	                nowPosX[1] = ((fx.end[1] - fx.start[1]) * fx.pos) + fx.start[1] + fx.unit[1];
	                fx.elem.style.backgroundPosition = nowPosX[0]+' '+nowPosX[1];

	        };
}
CalendarEve = function(){

if($('#jMonthContent').length>0){
	var options = {
		width: 265,
		navHeight: 25,
		labelHeight: 25
	};
	$.jMonthCalendar.Initialize(options, events);	
	
	$('#calendar_list li').click(function(){
		var setMonth = ($('.hidden',this).text()) - 1;
		var myMonth = new Date((new Date()).getFullYear(), setMonth, 1);
		jQuery.J.ChangeMonth(myMonth);
	});
 }
}

var sh = {
    timeout: 0,
    header_images: [],
    current_image: 0,
    prima: 1,
    images_count:0 ,
    initSlideShow: function () {
      this.images_count = this.header_images.length;

			$.preload(this.header_images,{
				loaded_all: function(){
					sh.nextImage();  
			}});
     },
    nextImage: function(){
      var image = this.header_images[this.current_image];
      sh.replaceImage(image);
			sh.updateCurrentImage(+1);
      this.timeout = setTimeout('sh.nextImage()',6400);
    },
    replaceImage: function(image){
      var dom_image = $('#slide_show img:first');
      var moviment = $('#slide_content.moviment');
	    if (moviment.length != 0) {
		   if (this.prima==0) {
		     dom_image.animate({
				   top: -1
				 }, 2500).delay(3000);;
		   } else { 
			this.prima=0; 		
			}
      }  
	
      dom_image.next('img').remove();
      dom_image.before('<img src="'+image+'" />');
      dom_image.fadeOut(1200).delay(500);
    },
		updateCurrentImage: function(add){
			sh.current_image+=add
      if((sh.current_image == sh.images_count )){
        sh.current_image = 0
      }
			if((sh.current_image < 0 )){
        sh.current_image = sh.header_images.length-1
      }
		},
		activeControl: function(){
			$('#slide_show').mouseenter(function(){
				$('#control a#next').fadeIn().animate({opacity: 0.7}, 50);
				$('#control a#prev').fadeIn().animate({opacity: 0.7}, 50);
				clearTimeout(sh.timeout);
			});
			$('#slide_show').mouseleave(function(){
				$('#control a#prev').fadeOut().animate({opacity: 0}, 50);
				$('#control a#next').fadeOut().animate({opacity: 0}, 50);
				sh.nextImage();
			});	
			$('#prev').click(function(e){
				sh.updateCurrentImage(-1);
				var image = sh.header_images[sh.current_image];
				sh.replaceImage(image);
				e.preventDefault();
			});	
			$('#next').click(function(e){
				sh.updateCurrentImage(+1);
				var image = sh.header_images[sh.current_image];
				sh.replaceImage(image);
				e.preventDefault();
			});	
			if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
				$('a#I_slide').show();
				$('#slide_show').toggle(function(){
					$('#control a').show();
				},function(){
					$('#next').hide();
					$('#prev').hide();
				});
			}else{
				$('a#slide').hide();
			}
	} 
};

$(function () {
	$('#slide_content').hide();
	$('#slide_show').find('img').each(function(){
		sh.header_images.push($(this).attr('src'));
	});
	if(sh.header_images.length >1){
		$('#slide_show img:gt(1)').css('display', 'none');
		sh.initSlideShow();
		sh.activeControl();
		$('#slide_content').delay(600).fadeIn(300);
	}else{
		$('#slide_content').show();
		$('#slide_show').find('img').css('display', 'block');
	}
});



PlayVideo = function(){	
if ($('a.video').length >0 ){
	if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {	
		$('a.video').attr('href','/flash/tods.mp4');
	}else{
 		$('a.video').attr('href','/movie.html');
 		$(".video").fancybox({
 			'width'				: 660,
 			'height'			: 500,
 			'autoScale'			: false,
 			'transitionIn'		: 'none',
 			'transitionOut'		: 'none',
 			'type'				: 'iframe',
			'scrolling' : 'no'
 		 });
		}	
	}
}

ReplaceHome = function (){
	if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {	
		if($('#flash_home').length >0){
			$('#flash_home').remove();
			$('#slide_show').html('<img src="/images/home_slide.jpg"/>');
		}
		
		if($('#flash_splash').length >0){
			$('#flash_splash').remove();
			$('#flash_splash').html('<img src="/images/home_splash.jpg"/>');
		}
	}
}	









