/* Author: Paul Kutschmarski | Nimbus Labs

*/

$(document).ready(function(){
	$(function () {
        $('.bubbleInfo').each(function () {
            var distance = 0;
            var time = 250;
            var hideDelay = 100;

            var hideDelayTimer = null;

            var beingShown = false;
            var shown = false;
            var trigger = $('.trigger', this);
            var info = $('.popup', this).css('opacity', 0);


            $([trigger.get(0), info.get(0)]).mouseover(function () {
                if (hideDelayTimer) clearTimeout(hideDelayTimer);
                if (beingShown || shown) {
                    // don't trigger the animation again
                    return;
                } else {
                    // reset position of info box
                    beingShown = true;

                    info.css({
                        top: -50,
                        right: -230,
                        display: 'block'
                    }).animate({
                        right: '-=' + distance + 'px',
                        opacity: 1
                    }, time, 'swing', function() {
                        beingShown = false;
                        shown = true;
                    });
                }

                return false;
            }).mouseout(function () {
                if (hideDelayTimer) clearTimeout(hideDelayTimer);
                hideDelayTimer = setTimeout(function () {
                    hideDelayTimer = null;
                    info.animate({
                        right: '-=' + distance + 'px',
                        opacity: 0
                    }, time, 'swing', function () {
                        shown = false;
                        info.css('display', 'none');
                    });

                }, hideDelay);

                return false;
            });
        });
    });
    
    // Show read more link on pages
    // amd hide / show content	
	$('#showContent').hide();
	
	$('#readMoreLink').click(function(){
		
		$('#showContent').slideDown();
		$('#readMoreLink').hide();
		
	});
	
	$(".smsIdea").hide();
	$("#smsType1").click(function(){	
		$("#smsIdea1").toggle("fast");	
	});  
	$("#smsType2").click(function(){	
		$("#smsIdea2").toggle("fast");	
	}); 
	$("#smsType3").click(function(){	
		$("#smsIdea3").toggle("fast");	
	}); 
	$("#smsType4").click(function(){	
		$("#smsIdea4").toggle("fast");	
	}); 
	$("#smsType5").click(function(){	
		$("#smsIdea5").toggle("fast");	
	}); 
	$("#smsType6").click(function(){	
		$("#smsIdea6").toggle("fast");	
	}); 
	$("#smsType7").click(function(){	
		$("#smsIdea7").toggle("fast");	
	}); 
	$("#smsType8").click(function(){	
		$("#smsIdea8").toggle("fast");	
	}); 
	
	// Show / Hide the icons
	$("#hideIcons").click(function(){
		
		$("#icons").animate({
		    top: '-280px'
		}, 400, function () {
		    $("#hideIcons").hide();
		    $("#showIcons").show();
		    setCookie('showIcons', 0, 30);
		});
		
		
	});
	
	$("#showIcons").click(function(){
		
		$("#icons").animate({
		    top: '198px'
		}, 400, function () {
		    $("#showIcons").hide();
		    $("#hideIcons").show();
		    setCookie('showIcons', 1, 30);
		});
		
	});
	
});

function setCookie(c_name,value,exdays){
	
	var exdate=new Date();
	exdate.setDate(exdate.getDate() + exdays);
	var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString()) + '; path=/';
	document.cookie=c_name + "=" + c_value;
	
}

function getCookie(c_name){

	var i,x,y,ARRcookies=document.cookie.split(";");
	for (i=0;i<ARRcookies.length;i++)
	{
	  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
	  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
	  x=x.replace(/^\s+|\s+$/g,"");
	  if (x==c_name)
	    {
	    return unescape(y);
	    }
	  }
  
}

function checkCookie(){
	
	var showIcons = getCookie("showIcons");
		
	if (showIcons !=null && showIcons!=""){
	  
		if( showIcons == 0 ){
			$("#icons").css('top', -280);
			$("#hideIcons").hide();
			$("#showIcons").show();
		}else{
			$("#icons").css('top', 198);
			$("#hideIcons").show();
			$("#showIcons").hide();
		}
		
	}
	  
}

checkCookie();










