function preloadImg() {
	var d=document;
	if(d.images){
		if(!d.PLImg_p)
			d.PLImg_p=new Array();
			
		var i,j=d.PLImg_p.length,a=preloadImg.arguments;
		for(i=0; i<a.length; i++)
			if (a[i].indexOf("#")!=0){
				d.PLImg_p[j]=new Image;
				d.PLImg_p[j++].src=a[i];
			}
	}
}

/* JQUERY Functions*/

jQuery(document).ready(function() {

	preloadImg('../images/sitestyle0_body_BG.png',
			   '../images/sitestyle0_header_BG.png',
			   '../images/sitestyle1_body_BG.png',
			   '../images/sitestyle1_header_BG.png',
			   '../images/sitestyle2_body_BG.png',
			   '../images/sitestyle2_header_BG.png',
			   '../images/sitestyle3_body_BG.png',
			   '../images/sitestyle3_header_BG.png',
			   '../images/sitestyle4_body_BG.png',
			   '../images/sitestyle4_header_BG.png',
			   '../images/sitestyle5_body_BG.png',
			   '../images/sitestyle5_header_BG.png',
			   '../images/sitestyle6_body_BG.png',
			   '../images/sitestyle6_header_BG.png');
	
	
	jQuery('.HomeBigLinks li').hover(function() {
		jQuery(this).children('span').animate({top:'75px'}, {queue:false, duration:500});
		jQuery(this).children('em').fadeIn(500);
		jQuery(this).children('img').fadeIn(500);
		jQuery(this).children('b').fadeIn(500);
	}, function() {
		jQuery(this).children('span').animate({top:'45px'}, {queue:false, duration:500});
		jQuery(this).children('em').hide();
		jQuery(this).children('img').hide();
		jQuery(this).children('b').hide();
	});
	
	
	jQuery('.SelectorBox1 li a').hover(function() {
		jQuery(this).parents('li').children('p').show().animate({top:'6.25em', opacity:1}, {queue:false, duration:500});
	}, function() {
		jQuery(this).parents('li').children('p').animate({top:'7.08em', opacity:0}, {queue:false, duration:500, complete:function(){
			jQuery(this).css({display:'none'});
			}
		});
	});
	
	
	jQuery('.SelectorBox1 li a').click(function() {
		jQuery('.MoreContent1_Box').hide();
		jQuery('.MoreContent1_Link').show();
		jQuery('.SelectorBox1 li a').removeClass('SBActive');
		jQuery(this).addClass('SBActive');
		jQuery(this).parents('li').children('p').fadeOut();
		if ( jQuery(this).hasClass('Prod1') ) {
			jQuery('.SelectorBox1').removeClass('SelBoxBG2');
			jQuery('.SelectorBox1').addClass('SelBoxBG1');
			jQuery('.Prod2_Wrapper').hide();
			jQuery('.Prod1_Wrapper').fadeIn();
		} else if ( jQuery(this).hasClass('Prod2') ) {
			jQuery('.SelectorBox1').removeClass('SelBoxBG1');
			jQuery('.SelectorBox1').addClass('SelBoxBG2');
			jQuery('.Prod1_Wrapper').hide();
			jQuery('.Prod2_Wrapper').fadeIn();
		}
		return false;
	});

	
	jQuery('.HeadFunctions li span').hover(function() {
		jQuery(this).animate({opacity:1}, {queue:false, duration:300});
	}, function() {
		jQuery(this).animate({opacity:0.7}, {queue:false, duration:300});
	});
	
	
	jQuery('.MoreContent1_Link').click(function() {
		jQuery(this).parents('p').parents('.ProductTextsContainer').children('.MoreContent1_Box').slideUp('fast');
		jQuery(this).parents('p').next().fadeIn();
		jQuery(this).parents('p').parents('.ProductTextsContainer').children('p').children('.MoreContent1_Link').show();
		jQuery(this).hide();
		var focusPoint = jQuery(this).attr('rel');
		setTimeout("jQuery.scrollTo( jQuery('#"+focusPoint+"'), 500)", 300);
		return false;
	});
	
	
	if ( jQuery('.ClientList1').length > 0 ) {
		jQuery('.ClientList1 .Content_Txt2:even').addClass('Even1');
	}


	jQuery('.FormBtnReset input').click(function() {
		jQuery('.error_msg').remove();
		jQuery('.FormContainer1 .FormField1 *').removeClass('FFilled');
	});


	jQuery('.FormContainer1 .FormField1 *').blur(function() {
		if ( jQuery(this).val() == '' || jQuery(this).val() == 'Nome' || jQuery(this).val() == 'E-mail' || jQuery(this).val() == 'Telefone de contacto' || jQuery(this).val() == 'Assunto' || jQuery(this).val() == 'Mensagem' || jQuery(this).val() == 'Name' || jQuery(this).val() == 'E-mail' || jQuery(this).val() == 'Phone number' || jQuery(this).val() == 'Subject' || jQuery(this).val() == 'Message' ) {
			jQuery(this).removeClass('FFilled');
		} else {
			jQuery(this).addClass('FFilled');
			jQuery(this).next().remove();
		}
	});
	
	
	jQuery('.EmployBtnsBox .SiteBtn1 b b b').click(function() {
		var formlang = jQuery('#form_lang').val();
		
		if ( formlang == 'pt' ) {
			var btntxt1 = 'ver ofertas';
			var btntxt2 = 'ocultar ofertas';
		} else if ( formlang == 'en' ) {
			var btntxt1 = 'browse offers';
			var btntxt2 = 'hide offers';
		}
		
		if ( jQuery('.EmployTable').is(':visible') ) {
			jQuery('.EmployTable').fadeOut();
			jQuery(this).html(btntxt1 + ' &raquo;');
		} else {
			jQuery('.EmployTable').slideDown();
			jQuery(this).html('&laquo; ' + btntxt2);
		}
	});
	
	
	jQuery('.ReplyBtnsBox .SiteBtn2').click(function() {
		var positionName = jQuery(this).parents().parents().parents().children('.ET_Col1').children('.ET_Pos_Name').text();
		var positionRef = jQuery(this).parents().parents().parents().children('.ET_Col1').children('.ET_Pos_Ref').text();
		jQuery.scrollTo({ top:0}, 800);
		jQuery('#subject').val(positionRef+' - '+positionName);
		jQuery('#subject').addClass('FFilled');
		jQuery('#subject').next().remove();
		jQuery('#subject').focus();
	});
	
	
	//IE Only
	if (jQuery.browser.msie) {
		

		jQuery('.HeadFunctions li span').css({opacity:0.7});
		jQuery('.SelectorBox1 li p').css({opacity:0});
	

		jQuery('.FormContainer1 .FormField1 *').hover(function() {
			jQuery(this).addClass('FHover');
		}, function() {
			jQuery(this).removeClass('FHover');
		});
	
		jQuery('.FormContainer1 .FormField1 *').focus(function() {
			jQuery(this).addClass('FFocus');
		});
		jQuery('.FormContainer1 .FormField1 *').blur(function() {
			jQuery(this).removeClass('FFocus');
		});
		

	}
	

});

