$(document).ready(function(){

// jQuery image change on hover
	$('ul.socials li img,div.leftContainer img,div#clients img,div#flickrContainer ul li img,div.contactContent a img,div#breadcrumbsContainer h2 img,div#pageContent ul.ourwork img')
        .mouseover(function() { 
            var src = $(this).attr("src").match(/[^\.]+/) + "Over.png";
            $(this).attr("src", src);
        })
        .mouseout(function() {
            var src = $(this).attr("src").replace("Over", "");
            $(this).attr("src", src);
        });
 
  //Activate the Poshytips ------------------------------------------------------ //
    $('.poshytip').poshytip({
    	className: 'tip-twitter',
		showTimeout: 1,
		alignTo: 'target',
		alignX: 'center',
		alignY:'bottom',
		offsetY: 10,
		allowTipHover: false
    });
	 $('.poshytip1').poshytip({
    	className: 'tip-twitter',
		showTimeout: 1,
		alignTo: 'target',
		alignX: 'center',
		alignY:'top',
		offsetY: 10,
		allowTipHover: false
    });
//Activate the Twitter
$(function(){
      $('#tweets').tweetable({username: 'affinitytv247', time: true, limit: 1, replies: true, position: 'append'});
  });
  	$(window).load(function(){
				$('#hovereffect').hoverwords({ delay:50 });
				$('#hovereffect1').hoverwords({ delay:50 });
	})
	// Activate the Nivo slider	
$(window).load(function() {
    $('#slider').nivoSlider({
    });
});
 
 //Activate the Piecemaker 
    var flashvars = {};
  flashvars.xmlSource = "piecemaker.xml";
  flashvars.cssSource = "piecemaker.css";
  var params = {};
  params.play = "true";
  params.menu = "false";
  params.scale = "showall";
  params.wmode = "transparent";
  params.allowfullscreen = "true";
  params.allowscriptaccess = "always";
  params.allownetworking = "all";
  
  swfobject.embedSWF('piecemaker.swf', 'piecemaker', '640', '300', '10', null, flashvars,    
  params, null);
  
  // Activate the prettyPhoto
 $(document).ready(function(){
    $("a[rel^='prettyPhoto']").prettyPhoto();
  });

  // Hover effect --------------------------------------------- //
	
		$('div#employeesContent .one-half img,div#servicesContent img,div#portfolio2columns img,div#portfolioFirstrow img,div#portfolioSecondrow img,div#portfolioThirdrow img,div#blog img,.advertising ul li img,div.post img').hover(function(){
		// on rollover
		$(this).stop().animate({ 
			opacity: "0.7"
		}, "fast");
	} , function() { 
		// on out
		$(this).stop().animate({
			opacity: "1" 
		}, "fast");
	});
  
  // Activate the toggle-content on click
$('.toggle-content').hide();
    $('.toggle-title').click(function(){
        $(this).next().slideToggle(300);
        $(this).children('span.open-toggle').toggleClass('closed');
        $(this).attr('title', ($(this).attr('title') == 'Close') ? 'Open' : 'Close');
        return false;
    });
		   	
	// Activate the contactform
$(function(){
	$('#contact_form').submit(function(e){
		e.preventDefault();
		var form = $(this);
		var post_url = form.attr('action');
		var post_data = form.serialize();
		$('#loader', form).html('<img src="img/loader.gif" /> Please Wait...');
		$.ajax({
			type: 'POST',
			url: post_url, 
			data: post_data,
			success: function(msg) {
				$(form).fadeOut(500, function(){
					form.html(msg).fadeIn();
				});
			}
		});
	});
});  	
	});
	

