var Homepage;
 $(function() {
        $('a.ImageBox').lightBox();
    });
//Dreamweaver Javascript ----------------------------------------------------------------------------------//
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//
//PreLoad script using Dreamweaver function
//Specify which images need to be preloaded on all pages
function Default_PreLoad() {
	if(Homepage == true){
		MM_preloadImages('/images/home-banner.jpg,/images/content1-home-bg.gif');
	}
	MM_preloadImages('/images/bg.gif','/images/forta-logo.gif','/images/content1-bg.gif','/images/content1-bg2.gif','/images/forta-for-concrete.gif','/images/header1-bg.gif','/images/header2-bg.gif','/images/header3-bg.gif','/images/header4-bg.gif','/images/nav-bg.gif','/images/nav-bg-roll.gif','/images/nav-bg-highlight2.gif')
	
	
}


//*************************************************************************************************
//Open Video

function SetVideoLinks(){
		
		$('.VideoLink').click(function(e){
		e.preventDefault();
		
		var VideoRef = $(this).attr('href');
		var top = (screen.height /2)-270 ;
		var left = (screen.width / 2)-160;
		var theFeatures = "width=540,height=400,toolbar=no,menubar=no,location=no,scrollbars=no,status=no,resizable=no,top=" + top + ",left=" + left;
		var vidWindow= window.open(VideoRef ,"Video",theFeatures);
		vidWindow.focus();
		return false;
		
		});
		
		
		
	}


//*************************************************************************************************

function SetTabs(){
	$('#TabContainer .tab').addClass('inactive');
	
	$('#TabContainer div:eq(0)').removeClass('inactive').addClass('active');
	$('.TabNav li:eq(0)').addClass('active');
	//
	//$('#tab-general').removeClass('inactive').addClass('active');
	

	$('.TabNav .tabbutton').click(function(e){
		e.preventDefault();

		//get the href attribute
		var $tabref = $(this).attr('href');
		//remove #
		$tabref = $tabref.substring(1);
		
		$('.TabNav > li').removeClass('active');
		$(this).parent().addClass('active');
	
		
		$('#TabContainer .tab').removeClass('active').addClass('inactive');
		$('#tab-' + $tabref).removeClass('inactive').addClass('active');

		});

}

function SetList(){
	
	$('#ListContainer .listcontent').css('display','none');
	$('#ListContainer .closecontent').css('display','block');
	
	
	$('#PDFAQ h2').text('Select a Question Below:');
	$('#FAQ #Content2 h2').text('Select a Question Below:');
	$('#PDLiterature h2').text('Select a Document Category Below:');
	
	
	$('#ListContainer .listhead').click(function(e){
		e.preventDefault();
		
		$(this).parent().next().toggle('slow');
		$(this).parent().parent().toggleClass("HighlightDiv");

		});
	
	$('#ListContainer .closecontent').click(function(e){
		e.preventDefault();
		
		$(this).parent().parent().toggle('slow');
		$(this).parent().parent().parent().toggleClass("HighlightDiv");
		
		
		});
	
}


function SetProjectList(){
	
	
	$('.ProjectTitle').before('<div id="ProjectTitleBox"></div>');
	$('.ProjectTitle').prependTo('#ProjectTitleBox');
	$('.ProjectSubtitle').appendTo('#ProjectTitleBox');
	$('#ProjectTitleBox').after($('#ProjectsListMenu'));
	$('#ProjectsListMenu').after($('#ToggleList'));

	
	$('.ProjectsListContent').css('display','none');
	$('#ToggleList').css('display','block');
	$('.OpenMenu').html("+ Select Another Project");

	
	
	$('.OpenMenu').click(function(e){
		e.preventDefault();
		
		$('.ProjectsListContent').toggle('slow');
		
		var p = $('#ProjectsListMenu').position();
		var h = $('#ProjectsListMenu').height();
		var dm = $('#ProductDetailsMenu').height();
		
		if($(this).html() == "+ Select Another Project"){
			$(this).html("+ Close Menu");
			
			window.setTimeout( function() {
			var s = p.top + h +dm;
			$('html,body').animate( { scrollTop:s }, 1000 );
			}, 1);
		
			
		}else{
			$(this).html("+ Select Another Project");
			
			window.setTimeout( function() {
			var s = p.top ;
			$('html,body').animate( { scrollTop:s }, 1000 );
			}, 1);
		};
		
		
	
	});
	
	
}

$(document).ready(function(){


/*var $CheckPCat = $('#Content1Main h1').text().replace(/ /g,'');
var $NavRef;

if($CheckPCat=="Macrofibers" || $CheckPCat=="FibrillatedMicrofibers" || $CheckPCat=="MonofilamentMicrofibers"|| $CheckPCat=="SpecialtyFibers" || $CheckPCat=="FiberTransportSystems" || $CheckPCat=="FlowableFill"){
 
 $NavRef = $CheckPCat;
 $('#'+$NavRef).addClass('Active');
// $('#'+$NavRef + ' a').addClass('HNavActiveA');
 //$('#'+$NavRef).css('background','#244855');
// $('#'+$NavRef + ' a').css('color','#FFFFFF');

};*/



function addMega(){
  $(this).addClass("hovering");
  }

function removeMega(){
  $(this).removeClass("hovering");
  }


var megaConfig = {    
     interval: 300,
     sensitivity: 4,
	 over: addMega,
	 timeout: 300,
     out: removeMega
     };
	 
	//if($.browser.className !="msie6"){ 
	$("li.mega").hoverIntent(megaConfig);
	//}
	
	
	HighLightNav()
	
;
	
	
									
});


function HighLightNav(){
	var path = location.pathname;     
	var pathItems = path.split("/");
	//Highlight product category menu, product menus, application menu and about menu
	if(pathItems[2]!= ""){
	$('#'+ pathItems[2]).addClass('Active');
	}
	if(pathItems[3]!=""){
		
		if(pathItems[3] =="forta-ferro"){
			$('#FortaFerro a').addClass('Active');
		}
		
		$('#'+ pathItems[3]).addClass('Active');
	}
	
	
}

function SetChatLink(){
	$("#ChatLink").each(function()
   { 
      this.href = this.href + '?link=true';
   });
	$('#ChatLink').click(function(e){
	e.preventDefault();
	//var path = window.location; 
	
	var top = (screen.height /2)-300 ;
		var left = (screen.width / 2)-400;
		var theFeatures = "width=800,height=400,top=" + top + ",left=" + left;
		var chatWindow= window.open(this.href,"ChatWindow",theFeatures);
		chatWindow.focus();
	
	
	
	
	 });
}

function ChatClearElements(){
	$('#Content1').css('display','none');
	$('#SideDiv').css('display','none');
	$('#Site_Header').css('display','none');
	$('#Content3').css('display','none');
	$('#BottomDiv').css('display','none');
	$('#Site_Footer').css('display','none');
	$('#Site_Container').css('padding-top', '0px');
	$('body').css('background', '#FFF');
	

	$('#ClickForForm').click(function(e){
	e.preventDefault();
	window.opener.location = this.href;
	window.close();
	 });
	
}


//*************************************************************************************************
//Get Directions from Google
function GetDirections(){
	
	if(document.getElementById('startAddress').value!=""){
	
		var startlocation = document.getElementById('startAddress').value;
		var destination = "100 Forta Drive, Grove City, PA 16127";
		var directionURL = "http://maps.google.com/maps?saddr="+startlocation +"&daddr="+ destination;
		
		
	}else{
		//alert("Please fill out a starting location.");	
		var directionURL = "http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=100+Forta+Drive,+Grove+City,+PA++16127&sll=37.0625,-95.677068&sspn=44.118686,57.919922&ie=UTF8&z=16&iwloc=A";
		
	}
		var top = (screen.height /2)-400 ;
		var left = (screen.width / 2)-400;
		var theFeatures = "width=775,height=650,toolbar=yes,menubar=yes,location=yes,scrollbars=yes,status=yes,resizable=yes,top=" + top + ",left=" + left;
		var dirWindow= window.open(directionURL,"NewWindow",theFeatures);
		dirWindow.focus();
}




$(document).ready(function(){
SetChatLink();
});

