/* 
	Main declarations and variables (DON'T add trailing slash)
	Script by Net Media Planet ( xavi@netmediaplanet.com )
*/	
website = new Array ();
website["url"] = "http://192.168.21.3/webdev/201044/netmediaplanet.com";
website["template_url"] = "http://192.168.21.3/webdev/201044/netmediaplanet.com/wp-content/themes/netmediaplanet";


team_imgs = new Array ();

/* Start jQuery stuff */
$(document).ready(function() {

	/* Hover menu for IE6 */
	// Javascript originally by Patrick Griffiths and Dan Webb.
	// http://htmldog.com/articles/suckerfish/dropdowns/
	/*sfHover = function() {
		var sfEls = document.getElementById("navbar").getElementsByTagName("li");
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className+=" hover";
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" hover\\b"), "");
			}
		}
	}
	if (window.attachEvent) window.attachEvent("onload", sfHover);*/
	/*$('#navbar>li>ul').each(
		function (intIndex) {
			$(this).bind('mouseenter mouseleave', function() {
				$(this).toggleClass('hover');
			});
		}
	);*/
	$('#navbar>li').bind('mouseenter mouseleave', function() {
  		$(this).toggleClass('hover');
	});
	
	/* Keep current submenu displaying when mouse leave */
	$('.current_page_ancestor,.current_page_item')
		.addClass("hover")
		.bind('mouseleave mouseenter', function() {
			$(this).removeClass("hover");
	});
	$('#navbar').bind('mouseleave mouseenter', function() {
		$('.current_page_ancestor,.current_page_item').toggleClass("hover");
	});
		
	/*
		Main menu subitems to start just below the main item
	*/
	$('#navbar>li>ul').each(
		function (intIndex) {
			var offsetmenu = $('#navbar').offset();
			var offsetitem = $(this).parent().offset();
			$(this).css("padding-left", offsetitem.left - offsetmenu.left);
		}
	);

	/* 
		People Slideshow by Net Media Planet 
		Last updt: 23rd March 2010
	*/
	$('li[id^="person_"]').each(
		function (intIndex) {
			var person = $(this);
            var person_img = person.find('img');
            var person_big_img = person.find('.people-big');
            var axis = person_img.position();                           
            var axis_x = axis.left;        
                axis_x = axis_x+106;                
            var axis_y = axis.top;       
                axis_y = axis_y+20;
            
			person.bind("mouseenter", function(e){ 
                person_big_img.css({'left':axis_x,'top':axis_y}).fadeIn(300).dropShadow({'left':-1,'top':3,'blur':5});
			});
            person.bind("mouseleave", function(){                              
                person.find('.people-big').removeShadow().fadeOut(200);
            });
            person_big_img.bind('mousemove',function(){
                person_big_img.removeShadow().fadeOut(200);
            });
		}
	);

	/*  Fix IE6 weird menu, the naughty way. but there's no way to detect ie6 through jquery.support in 1.4 */
	if (jQuery.browser.msie && jQuery.browser.version == 6) {
		$('#navbar').trigger('mouseenter').trigger('mouseleave');
	}
	
	var twit_data = $.cookie('lasttweets');
    if(twit_data!=null){
        /*if(typeof console != "undefined" && console.log){
            console.log('Data returned --> '+twit_data)
        }*/
        $.ajax({
            type: "GET",
            url: '/wp-content/themes/netmediaplanet/includes/php/ajax.php?a=tweet',
            success: function( data ) {
                $('#tweet_sri').html(data);
                $('#twitters ul').css({display:'block'});
            }
        });
    }else{
        if(typeof console != "undefined" && console.log){
            console.log('No data')
        }/* Request latest feed */
        $.ajax({
            type: "GET",
            url: '/wp-content/themes/netmediaplanet/includes/php/ajax.php?a=tweet',
            beforeSend: function() {
                $('#twit_load').css({display:'block'});
            },
            success: function( data ) {
                $('#tweet_sri').html(data);
                $('#twitters ul').fadeIn('slow').delay(500).slideDown('slow',function(){
                    $('#twit_load').css({display:'none'});
                });
            }
        });
    }
    
/**
 *    Search box clean
 * 
 */ /************************/
 
    input_text = function(ele,str){
        $(ele)
            .addClass("suggestion")
            .val(str)
            .click(function(){
                var input = $(this);
                if (input.hasClass("suggestion")) {input.val("");}
                input.removeClass("suggestion").css('color','#666');
            })
            .blur(function() {
                var input = $(this);
                if (input.val()=="") {
                input.addClass("suggestion").val(str).css('color','#ccc');
            }
        });
    }
    input_text('#nl_subscribe,#nl_subscribe_sb',"enter email address");
    
    // DC Storm tracking for submit button on Contact form
    $('input.wpcf7-submit').live('click',function(){
        trackConv();
        logOCPV('isconv=0|pover=NMP Form Submission');
    });
    
    $('.click').live("click",function() {
        window.location = $(this).find('a:first').prop('href');
        return false;
    });

}); // end document ready

