// Thinknblink
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}
function getElementsByClassName(node, classname) {
    var a = [];
    var re = new RegExp('\\b' + classname + '\\b');
    var els = node.getElementsByTagName("*");
    for(var i=0,j=els.length; i<j; i++)
        if(re.test(els[i].className))a.push(els[i]);
    return a;
}
function swapEmails() {
  var spans1 = getElementsByClassName(document, "emailger");
  var spans2 = getElementsByClassName(document, "emailinfo");
  for (var i=0; i<spans1.length; i++) {
      spans1[i].innerHTML = '<a class="email" title="this will open your email program" href="&#109;&#097;&#105;&#108;&#116;&#111;:&#103;&#101;&#114;&#064;&#116;&#104;&#105;&#110;&#107;&#110;&#098;&#108;&#105;&#110;&#107;&#046;&#105;&#101;">&#103;&#101;&#114;&#064;&#116;&#104;&#105;&#110;&#107;&#110;&#098;&#108;&#105;&#110;&#107;&#046;&#105;&#101;</a>'   
  }
  for (var i=0; i<spans2.length; i++) {
      spans2[i].innerHTML = '<a class="email" title="this will open your email program" href="mailto:info@thinknblink.ie">info@thinknblink.ie</a>'   
  }
}

addLoadEvent(swapEmails);

$(document).ready(function(){

	$("div.thumbs").append('<div class="clear"></div>');
	
	$('#services .service').css("cursor","pointer");
   	$('#services .service').click(function () {
		var addr = $(this).find('a').attr("href");
		window.location = addr;
      }
    );
	$('#secondarycontent .service-side').css("cursor","pointer");
   	$('#secondarycontent .service-side').click(function () {
		var addr = $(this).find('a').attr("href");
		window.location = addr;
      }
    );

});




    $(function()
    {
            $("#navigation li").hover(function()                {
                 var theIcon = $(this).children("a");
                 var theNextIcon = $(this).next("li").children("a");
                 var thePreviousIcon = $(this).prev("li").children("a");
                 
                 //Zoom Specifications
                 var zoom = {fontSize: "20px"};
                 var normalSize = {fontSize: "15px"};                  
                 var siblingZoom = {fontSize: "18px"};
                  
            if (theIcon.is(":animated")){
                    theIcon.stop().animate(zoom, "fast");
                }
            else{
                    theIcon.animate(zoom, "fast");
                };
                
            if ( theNextIcon.is(":animated") ||  thePreviousIcon.is(":animated") ) {
                     theNextIcon.stop().animate(siblingZoom, "fast");
                     thePreviousIcon.stop().animate(siblingZoom, "fast");
                }
            else{
                    theNextIcon.animate(siblingZoom, "fast");
                    thePreviousIcon.animate(siblingZoom, "fast");
                };
                    $(this).children("span").addClass("showSpan");
            },
        function()
            {
                 var theIcon = $(this).children("a");
                 var theNextIcon = $(this).next("li").children("a");
                 var thePreviousIcon = $(this).prev("li").children("a");
                 
                 var zoom = {fontSize: "20px"};
                 var normalSize = {fontSize: "15px"};                  
                 var siblingZoom = {fontSize: "18px"};

            if ( theIcon.is(":animated") ){
                    theIcon.stop().animate(normalSize, "fast");
                }
            else {
                    theIcon.animate(normalSize, "fast");
                };
                
            if ( theNextIcon.is(":animated") || thePreviousIcon.is(":animated") ){
                     theNextIcon.stop().animate(normalSize, "fast");
                     thePreviousIcon.stop().animate(normalSize, "fast");
                }
            else{
                    theNextIcon.animate(normalSize, "fast");
                    thePreviousIcon.animate(normalSize, "fast");
                };
                    $(this).children("span").removeClass("showSpan");
            });
    });


