/****************
	################# FUNCTIONS FOR GENERIC CODE ################# 
****************/


/****************
	################# WHEN SCROLL THE REST OF THE FOOTER APPEARS ################# 
****************/
var footerMinimalHeight = 40;
var footerMaximHeight = 618;
var scrollHeightMovement = 40;
var lastPos=0;
var heightFooter = $('.footerDinamic').height();
var heightFooter2 = $('.footerStatic').height();

var isRunning = false;

function openAndCloseFooterWithScroll(sDir,iPreviousScroll){
	
	var heightSite = heightSiteContent();
	var heightBrowser = $(window).height(); // get the height of site
	var scrollPosition = $(window).scrollTop() //get the scroll position of the browser 
	var docHeight = $(document).height();
	var heightFooter2 = $('.footerStatic').height();
	
	if(sDir == 'down'){
		
		if( (heightSite) <= (heightBrowser + scrollPosition + heightFooter -footerMinimalHeight) ){ 
			if(heightFooter==footerMinimalHeight)
			{
				$('.footerDinamic').hide();
			}
			if(lastPos<scrollPosition)
			{
				$('.footerDinamic').hide();
				lastPos = scrollPosition;
			}
		}
		else
		{
			$('.footerDinamic').show();
			heightFooter = footerMinimalHeight;
		}
	}
	
	if(sDir == 'up'){
		if( (heightSite) <= (heightBrowser + scrollPosition + heightFooter - footerMinimalHeight) ) 
		{
			$('.footerDinamic').hide();		
		}else{
			
			$('.footerDinamic').show();
		}
		lastPos = scrollPosition;
	}
}

/*CALCULATE THE HEIGHT OF SITE*/
function heightSiteContent(){
	var heightSite = $('.site').height() + footerMinimalHeight;
	//console.log(heightSite);
	return heightSite;
}


/*SHOW DIV CONTENT OUR ACTIVIES*/
function showDivActivies(idDiv){
	 var description = new Array();

	description[0]='For brands that want to upgrade \' their platform to adapt and win in the Digital Age, FullSIX has expanded the traditional Vision- Mission -Positioning triangle that was created for the TV age. This leads to building a Brand Glass House, that redefines the brand pillars by adding Experience (defining the interaction guidelines) and Halo(defining the social / reputation guidelines) to the overarching brand platform. <br/><br/> Once the Glass House is defined through a series of collaborative workshops with our clients, we then elaborate the Core Engagement Idea that will be at the core of all communication, interaction and reputation creative elements and guidelines. It then leads to creative execution & guidelines per channel and key consumer clusters, to that all these elements can seamlessly be synchronized in time with consumer and market reality. ';       
	
	description[1]='The Digital landscape is continuously evolving and reaches far beyond just WebSites. Designing a winning Digital Strategy includes: <br/><br/>&bull; Setting the appropriate objectives and KPIs that digital can handle and boost within the global brand and marketing objectives and KPIs and creating the appropriate reporting and dashboard tools to constantly optimize performance <br/>&bull; Defining the Experience Platform, i.e. how we want consumers to react both emotionally and rationally when interacting with the brand digital assets <br/> &bull; Defining the Brand Digital Footprint, i.e. the most relevant content approach by integrating the key consumer profiles interests, the brand objectives and the existing sources of available Digital content and services <br/> &bull; Defining the Digital brand presence, i.e. what are the Digital point of contacts the brand can and should use, how they integrate in the global Digital eco-system and how they synergize together with clearly define roles and measurable KPIs <br/> &bull; Drafting the acquisition strategy and the optimized consumer funnels per key objectives';
	
	description[2]=	'Every brand knows that in the Digital Age their Social Marketing Strategy is going to be key. But it is often yet unclear what can be the objectives and what can really be done to influence consumers leveraging social media. We helps brands define a clear and actionable social media strategy : <br/><br/>&bull;	What are the key objectives that a Social Strategy can fulfill for the brand in coherence with all the other communication and interaction plans ? <br/>&bull;	What is the social presence that the brand needs to have?<br/>&bull;	What is the conversation management strategy? What are the contents and services that a brand already has and that can be "socialized" ? <br/>&bull;	How can a brand recruit fans and turn them into ambassadors? <br/>&bull;	What is the ideal planning and orchestration in time? <br/>&bull;	How does a brand define social KPIs and monitor performance?';
		
	description[3]='Synchronized Marketing is an upgraded approach to integrated brand marketing communications that is both fit for and enabled by the Digital Age. The core focus of Synchronized Marketing is to deliver increased performance through more relevance and less frequency. To do so, on one hand one synchronizes all communication, interaction and reputation creative and campaigns with brand reality (Authenticity), and on the other hand it synchronizes all actions with consumer profiles, consumer behavior and business performance. The full potential of Synchronized Marketing is enabled by five strategic pillars: <br/><br/>&bull; 3D Profiles: Consumer Segments in three dimensions (Value Profile, Channel Profile & Interaction Profile)<br/>&bull; Brand Platforms 2.0: Fact & data based strategic planning, adding Halo and Experience to brand platforms.<br/>&bull; Synchronization Engines: the set of rules and programs that allow turning data into useful, action oriented information<br/>&bull; Creative Engagement Idea & Guidelines: The core creative idea and how to execute it across channels & profiles<br/>&bull; Brand Asset Management: Building and managing all brand assets (websites, models, applications, databases...)';

	description[4]='FullSIX helps it clients build integrated advertising campaigns across all channels. Our core differences lie in the fact that (i) we start by a core, cross channel creative engagement idea that we then synchronize on all channels and (ii) we integrate media teams in the creative thinking from day 1 so that message and medium are seamlessly integrated to the benefit of relevance and (iii) we have a media neutral approach and do not give mass digital channels an accessory role in the brand and advertising strategies.';
	
	description[5]='We believe that Digital has become the real mass media, where more and more consumers spend most of their time and make their purchase decisions. We have strong media planning and buying teams that are integrated with creative people to plan and negotiate the most effective Online media plans. We master all digital media opportunities, from @lternative TV to Search, Display, Digital events, Social media and e-mailing. ';

	description[6]='We are one of the European leaders in Social Media strategies and action plans, helping the biggest European brands make the most of this new opportunity. For us this is strongly related to content, since credibility and authenticity come through truly interesting and relevant content that can either spark of buzz or answer specific queries. We also think that it is by tying Social Action Plans to real world events that a brand can make the most of its efforts and ambassadors.  ';
	
	description[7]='We orchestrate all Digital Media in real time to optimize acquisition costs for our clients. This includes CPM, CPC and CPA campaign management, with a scope including not only planning but also cre tive, and conversion funnel optimization and management. <br/><br/>We also build predictive models enabling to plan and monitor spending depending on the targeted acquisition cost, the market specifics and the amount of leads or clients needed.';
	
	description[8]='We fully implement best in class eCommerce platforms for all categories, from information architecture and design to funnel optimization and technical implementation. We think that eCommerce is not only about the platform, but also about the shopping experience, that is why we propose our clients to implement Social Shopping features, OnLine / OffLine shopping integration, Online promotion management, dynamic keyword bidding, personalization features, eCRM integration, glorified product presentation...';
		
	description[9]='Relationship marketing is massively changing with the Digital Age, creating the opportunity to enhance the customer relationships and deliver ever-increased ROI. In a world that is more and more data-rich, consumer profiles can be enriched with behavioural and transactional data, that is why we believe in building 3D profiles include Customer Value (Business Potential  & Ambassadorship Value), Channel Profile (what channel is the most effective per customer) and Interaction profile (what are the kind of emotional and rational rewards the customer wants from the brand).  By adding Social & Mobile to CRM programs, we enliven the relationship making it more meaningful and relevant.  But most of all, we believe that relationships are now always on and that Relationship  programs can no longer be just about newsletters and points systems. Relationship programs are about an ongoing, always on connection with your key customers to deliver the most relevant message through the most effective channel at the best moment in time. ';
	
	description[10]='The Internet is no longer just about the Web. Your website is a core element in a multi-screen consumer experience that integrates mobiles devices, tablets, Facebook, Connected TV...  Through 15 years of being market leaders and makers in Digital, we have the Information Architecture teams, the consulting teams, the Creative teams, the technical teams to build best in class interactive experiences across digital channels. A strong brand and communication culture coupled with a rigorous approach, proven effective methodologies, and a wide range of experience and proprietary tools, we are able to put the best experts of the market at the service of our clients to deliver impeccable and breakthrough websites, platforms and applications. ';
			
	description[11]='Smartphones are changing the way people shop. Kinnect is going to revolutionize in store interaction. Facebook is following consumers in store... The opportunities in Shopper Marketing are bigger than ever, and we have already triggered a series of initiatives around Europe. With Online geolocalisation, Dynamic Mobile Couponing, POS centric eCRM, Mobile Marketing, we develop custom solutions out of proven effective experiences to boost sales not only OnLine, but also InStore.';
	
	description[12]="We have proprietary OnLine & Mobile panels that allow us to gather strong consumer insights with speed and accuracy. Consumer Research has become the backbone of any marketing and communication campaign, not only to check its performance after it's been done, but to embed it in the strategic and creative process to make sure that everything done will be as effective, consumer centric and relevant as possible. We believe that it is by mixing declarative data and behavioral data that the true insights are gathered.";
		
	description[13]="Many companies already have a lot of data about their clients, but have difficulties transforming that data into useful information to make their marketing and communications more effective. With strong datamining teams, innovative models, tools and methodologies mixing behavioral and transactional data, our Consumer Intelligence teams feed both the client teams and the fullsix teams with relevant insights and consumer clusters that can make a profound difference.";
	
	description[14]="We know that today all that happens Online can be measured. But the strong challenge is to define what really needs to be measured, and how data can be turned into relevant information for performance purposes. This required to often mix tools and trackers to make sure the data is consistent. Through years of experience and measurement, our Analytics teams have learned to build the reports that CMOs can read and that can be turned into actionable decisions. We deliver these to our clients either by using their own analytics and tracking tools, either by using some of our proprietary tools when needed.";
		
	description[15]="Today brands can not ignore what consumers and opinion leaders are saying about them. Our research teams monitor conversations, score positives and negatives and deliver daily, weekly and monthly reports to our clients about what is being said. Alerts are triggered if some conversations are spotted as potentially damaging. We also score key market influencers to track the real importance of a conversation in terms of echo. ";

	colorBlock = $('#'+idDiv).parents('li').attr('class');
	blockContent = $('.layerActivies').addClass(colorBlock);

	splitIdDiv = idDiv.split("_") ;
	title = $('#' + idDiv).find('cite').text();
	image = $('#' + idDiv).find('span').html();
	$('.layerActivies').attr('id','content_'+splitIdDiv[1] ).show();
	$('.title').html(title);
	$('.iconActivies').html(image);
	$('.descriptionActivies').html(description[splitIdDiv[1]]);
}

/*SHOW DIV CONTENT OUR ACTIVIES*/
function showDivActiviesDetail(idDiv, body) {
    var description = new Array();


    colorBlock = $('#' + idDiv).parents('li').attr('class');
    blockContent = $('.layerActivies').addClass(colorBlock);

    splitIdDiv = idDiv.split("_");
    title = $('#' + idDiv).find('cite').text();
    image = $('#' + idDiv).find('span').html();
    $('.layerActivies').attr('id', 'content_' + splitIdDiv[1]).show();
    $('.title').html(title);
    $('.iconActivies').html(image);
    bodyX = $('#' + idDiv).find('div').html();
    $('.descriptionActivies').html(bodyX);
}

/*CLOSE DIV CONTENT OUR ACTIVIES*/
function hideDivActivies(){
	$('.layerActivies .close').click(function(){
		$('.layerActivies').hide();
	});	
}




/*CLOSE POPIN MOVIE PLAYER*/
function closePopinMovie(blockContent, titleContent, divPlayer){
	$('.youtubeContent').remove();
	$('.'+divPlayer).hide();
	$('h2#' + titleContent).show();

	$('.hoverMovie').remove();
	$('.hoverDoc').remove();

	$('.' + blockContent).find('a.doc img').removeClass('imgOpacity');
	$('.'+blockContent).find('a.movie img').removeClass('imgOpacity');
	$('.'+blockContent).find('span').removeClass('imgOpacity');
	$('.'+blockContent).find('cite').removeClass('imgOpacity');

	heightSiteContent();

}


function caseStudiesPopinMovie(divContent, titleContent, divPlayer, blockContent, typeCaseStudie, url ){
	 closePopinMovie(blockContent,titleContent, divPlayer);

	 var isPad = false;
	 if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/iPad/i))) {
	     isPad = true;
	 }

	//console.log("typeCaseStudie:" + typeCaseStudie);
	//console.log("url:" + url);
	//console.log("isPad:" + isPad);

	 if (typeCaseStudie == 'movieClick' || typeCaseStudie == 'movieClickVimeo') {
	    
		var bgSelect = '<code class="hoverMovie"></code>';
		
		justNumber = divContent.split("_") ;

		var ola = '';

		if (typeCaseStudie == 'movieClickVimeo') {
		    ola = '<iframe src="http://player.vimeo.com/video/' + url + '" width="701" height="398" frameborder="0"></iframe>';
		}
		else {
		    if (isPad) {
		        ola = '<div class="youtubeContent"><iframe title="YouTube video player" width="700" height="420" src="http://www.youtube.com/embed/' + url + '" frameborder="0" scrolling="no" allowfullscreen></iframe></div>';
		    }
		    else {
		        ola = '<div class="youtubeContent"><object width="700" height="420><param name="movie" value="http://www.youtube.com/v/' + url + '?fs=1&amp;hl=en_GB"></param><param name="allowFullScreen" value="true"></param><param name="wmode" value="transparent"/><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/' + url + '?fs=1&amp;hl=en_GB" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" wmode="transparent" width="700" height="420"></embed></object></div>'
		    }
		}
		//console.log(ola);
		$('.'+divPlayer).show().find('.objectYoutube').html(ola);

		//$('#'+divPlayer).show();	
		$('h2#'+titleContent).hide();	
		$('#'+divContent).parents('li').find('a.movie').prepend(bgSelect);
		$('#'+divContent).parents('li').find('a.movie img').addClass('imgOpacity');
		$('#'+divContent).parents('li').find('span').addClass('imgOpacity');
		$('#' + divContent).parents('li').find('cite').addClass('imgOpacity');


	}else if( (typeCaseStudie == 'docClick') ){
		
		var bgSelect = '<code class="hoverDoc"></code>';
		
		justNumber = divContent.split("_") ;


        //http://icant.co.uk/slidesharehtml/embed.php?url=http://www.slideshare.net/FullSIX/'+ url +'&width=685
        //http://static.slidesharecdn.com/swf/ssplayer2.swf?doc='+ url +'&stripped_title='+ url +'&userName=FullSIX

		var ola = '';
		if (isPad) {
		    ola = ('<iframe  width="700" height="560" scrolling="no" frameborder="0"  src="'+ url +'"></iframe>');
		}
		else {
		    ola = ('<div class="youtubeContent"><object id="sse6843363" width="700" height="420"><param name="movie" value="'+ url +'" /><param name="allowFullScreen" value="true"/><param name="wmode" value="transparent"/><param name="allowScriptAccess" value="always"/><embed name="_sse6843363" src="'+ url+'" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" wmode="transparent" width="700" height="420"></embed></object></div>')
		}
		//'<div class="youtubeContent"><object id="sse6843363" width="700" height="420"><param name="movie" value="" /><param name="allowFullScreen" value="true"/><param name="wmode" value="transparent"/><param name="allowScriptAccess" value="always"/><embed name="_sse6843363" src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=casestudyfullsix-simplicime-englishversion-110207160358-phpapp02&stripped_title=case-study-fullsix-simplicime-english-version&userName=FullSIX" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" wmode="transparent" width="700" height="420"></embed></object></div>'
		//console.log(ola);
		$('.'+divPlayer).show().find('.objectYoutube').html(ola);
			
		//$('#'+divPlayer).show();	
		$('h2#'+titleContent).hide();
		$('#' + divContent).parents('li').find('a.movie').prepend(bgSelect);
		$('#' + divContent).parents('li').find('a.movie img').addClass('imgOpacity');
		$('#'+divContent).parents('li').find('span').addClass('imgOpacity');
		$('#'+divContent).parents('li').find('cite').addClass('imgOpacity');
		
		
	}
	heightSiteContent();
	return false;


	/* var bgSelect = '<code class="hoverMovie"></code>';

	

	$('h2#'+titleContent).hide();	
	$('#'+divContent).parents('li').find('a.movie').prepend(bgSelect);
	$('#'+divContent).parents('li').find('a.movie img').addClass('imgOpacity');
	$('#'+divContent).parents('li').find('span').addClass('imgOpacity');
	$('#'+divContent).parents('li').find('cite').addClass('imgOpacity');

	 heightSiteContent();	*/
	
}

		

/****************
################# INIT INPUT DEFAULT VALUE FUNCTION ################# 
****************/

function initInputValue(){
	$('input[type="text"]').each(function(){
		$(this).data('defaultValue',$(this).val());					 
	});
	$('input[type="text"]').focus(function() {
		if($(this).val() == $(this).data('defaultValue')){
			$(this).val("");
		}
	});
	$('input[type="text"]').blur(function() {
		if($(this).val()== "") {
			$(this).val($(this).data('defaultValue'));
		}
	});
}

/*SHOW LIST OF COUNTRIES*/
function showListCountry(divContent){

	$('#'+divContent+' .list').toggle();
}

/*SHOW POPIN NEWSLETTER*/
function ShowNLSubscribe(){
	$('.newsletter').show();
}
/*HIDE POPIN NEWSLETTER*/
function HideNLSubscribe(){
	$('.newsletter').hide();
}



/****************
################# TABS FOR CONTACT PAGE ################# 
****************/
function tabsContact(){
	
    var tabContainers = $('div.tabsContactUs > .contentTab');     
                
	tabContainers.hide().filter(':first').show();                                               
	$('div.tabsContactUs ul.tabNavigation a').click(function () {
		                                
		tabContainers.hide();                                
		tabContainers.filter(this.hash).show();     
                        
		$('div.tabsContactUs ul.tabNavigation a').removeClass('selected');                                
		$(this).addClass('selected'); 
		
		linkTab = this.hash;
		justNameTab = linkTab.split("#") ;
		
		xxx = justNameTab[1];
		
		
		if( $('.googleMap').is(':visible') ) {
				setTimeout('callFlashFunction(xxx)',400);
		}
		
		$('.ipadGoogleMaps').children().hide();
		$('.ipadGoogleMaps').children('.'+xxx+'').show();
                           
		return false;                        
	}).filter(':first').click();     
}




//NAVIGATE between PAGES
function getQueryVariable(variable) {
    var query = window.location.search.substring(1); // This grabs everything after the ? in the url
    var vars = query.split("&"); // This seperates all the queries. (in this example, there is only one - page=http://www.webdeveloper.com)
    for (var i=0;i<vars.length;i++) { // This loops through all the split queries
        var pair = vars[i].split("="); // This splits the query into Name and value. (i.e. the Name is "page" and the value is "http://www.webdeveloper.com")
        if (pair[0] == variable) { // If the Name in the url is "page" stop and remember the value, otherwise, move to the next name/value pair
            return pair[1];
        }
    } 
   // alert('Query Variable ' + variable + ' not found');
   
}

function navigateBetweenPages(classLink){
    var page = $.getUrlVar('page');
	if(page == null || page == undefined){
		//alert('nao tem');
	}else{
		//alert('tem');
		//console.log(page);
		tabContainers = $('div.tabsContactUs > .contentTab');                        
	    tabContainers.hide();                                
		$('#'+page).show();                                
		$('div.tabsContactUs ul.tabNavigation a').removeClass('selected');                                
		$('#'+page).addClass('selected');      
		$('.tabNavigation li a[href=#'+page+']').addClass('selected'); 
		
		yyy = page; 
                   
		
		
		if( $('.googleMap').is(':visible') ) {
				setTimeout('callFlashFunction(yyy)',1000);
		}		   
				  $('.ipadGoogleMaps').children().hide();
		$('.ipadGoogleMaps').children('.'+yyy+'').show(); 
				         
	    return false;
	}
}


function callFlashFunction(country) {
   //swfobject.getObjectById("main").onMapChanged(country);
}

function witdhWindow(windowWidth){
	if(windowWidth > 940){
		$('.witdhFooter').css({'width': '940px', 'margin': 'auto'})
		$('.wrapper').css({'width': '940px', 'margin': 'auto'})
			

	}else{
		$('.witdhFooter').removeAttr('style')
		$('.wrapper').removeAttr('style')
	}	
}







			





