/*
CSS Browser Selector v0.3.4 (Sep 29, 2009)
Rafael Lima (http://rafael.adm.br)
http://rafael.adm.br/css_browser_selector
License: http://creativecommons.org/licenses/by/2.5/
Contributors: http://rafael.adm.br/css_browser_selector#contributors
*/
function css_browser_selector(u){var ua = u.toLowerCase(),is=function(t){return ua.indexOf(t)>-1;},g='gecko',w='webkit',s='safari',o='opera',h=document.getElementsByTagName('html')[0],b=[(!(/opera|webtv/i.test(ua))&&/msie\s(\d)/.test(ua))?('ie ie'+RegExp.$1):is('firefox/2')?g+' ff2':is('firefox/3.5')?g+' ff3 ff3_5':is('firefox/3')?g+' ff3':is('gecko/')?g:is('opera')?o+(/version\/(\d+)/.test(ua)?' '+o+RegExp.$1:(/opera(\s|\/)(\d+)/.test(ua)?' '+o+RegExp.$2:'')):is('konqueror')?'konqueror':is('chrome')?w+' chrome':is('iron')?w+' iron':is('applewebkit/')?w+' '+s+(/version\/(\d+)/.test(ua)?' '+s+RegExp.$1:''):is('mozilla/')?g:'',is('j2me')?'mobile':is('iphone')?'iphone':is('ipod')?'ipod':is('mac')?'mac':is('darwin')?'mac':is('webtv')?'webtv':is('win')?'win':is('freebsd')?'freebsd':(is('x11')||is('linux'))?'linux':'','js']; c = b.join(' '); h.className += ' '+c; return c;}; 

css_browser_selector(navigator.userAgent);

function isIPad(){
    return navigator.platform == "iPad";
}


if (isIPad()) {
	//alert("ipad user");
	//$('#ipad_content').css("display", "block");
	//$('.social_links').css("border", "1px solid red");
	//$('.social_links').css("width", "200px");
	//$('.social_links span').css("float", "left");
	
}




function loadPopupScript()
{
$(".image-areas a img.pop-up-link").parent().each(function() { /*Find every a tag with img+class inside*/
    var url = $(this).attr("href"); /*Grab the url*/
    $(this).attr("href", "#").removeAttr("target"); /*Remove attributes making it a usable link*/

    $(this).click(function() { /*Add an on-click event*/
      $("#pop-up").fadeIn("slow", function() { /*Show pop-up div*/
        $("#pop-up-loader").hide( function() { /*Hide loader placeholder */
          $("#slideshow-cycle").load(url + " #import-slideshow", function() { /*Load in slideshow data*/
            $("#import-slideshow").replaceWith( $("#import-slideshow").contents() ); /*Remove wrapper*/
          $("#slideshow-description").load(url + " #import-description", function() { /*Load in description data*/
            $("#import-description").replaceWith( $("#import-description").contents() ); /*Remove wrapper*/
            
            var slideCount = $("#pop-up-loader tr").size();
            
            if(slideCount == 1){
              $("#slideshow .pop-up-button").css("display", "none");
            } else {
              $("#slideshow .pop-up-button").css("display", "block");
            }
            
            $("#pop-up-loader td").each(function() { /*Replace td tags with divs for styling*/
              $(this).replaceWith($("<div>" + this.innerHTML + "</div>"));
            });
            
            $("#pop-up-loader tr").each(function() { /*Give divs classes for styling*/
              $(this).children().eq(0).addClass("pop-up-image");
              $(this).children().eq(0).children("img").addClass("popupImageToZoom");
              $(this).children().eq(1).addClass("pop-up-caption");
            });
            
            $("#pop-up-loader tr").each(function() { /*Replace tr tags with divs for styling*/
              $(this).replaceWith($("<div>" + this.innerHTML + "</div>"));
            });
            
            $("#pop-up-loader tbody").replaceWith( $("#pop-up-loader tbody").contents() ); /*Remove tbody*/
            $("#pop-up-loader table").replaceWith( $("#pop-up-loader table").contents() ); /*Remove table*/
            $("#pop-up-loader #slideshow-cycle br").remove();

            brightcove.createExperiences();
            
            $("#slideshow-cycle").cycle({ /*Enable cycle plugin on loaded page*/
              fx:     "fade", 
              speed:  "fast", 
              timeout: 0, 
              next:   "#jquery-cycle-next", 
              prev:   "#jquery-cycle-prev" 
            });
            
            if  ($.browser.msie  && parseInt($.browser.version) == 7) 
            {  
            	$(".popupImageToZoom").parent().css({'width' : '400px'});
            	$(".popupImageToZoom").css({'width' : '400px', 'height' : '270px'});				
            }
            else
            {            	
            	$(".popupImageToZoom").css({'width' : '400px', 'height' : '270px', 'z-index' : '0', 'overflow' : 'hidden'});				
            }
            
            $("#jquery-cycle-next, #jquery-cycle-prev").click(function() {			  
			  setTimeout("buttonClicked()", 100);
			});
			
            $("#pop-up-loading").fadeOut("slow", function() { /*Hide loading animation*/
              $("#pop-up-loader").fadeIn("slow"); /*Show loaded and cycle initialized page*/
            });
            
            var imageWidth = 400;
            var imageHeight = 270;
            var zoomImageWidth = imageWidth * 2 + "px";
			var zoomImageHeight = imageHeight * 2 + "px";
            var normalImageWidth = imageWidth + "px";
			var normalImageHeight = imageHeight + "px";
            
            $(".popupImageToZoom").hover(function() {
            	$(this).css({'z-index' : '1000', 'overflow' : 'visible'});
				$(this).parent().parent().css({'z-index' : '1001'});		
				
					
					/*if  ($.browser.msie  && parseInt($.browser.version) == 7) 
		            {  */
		            	$(this).parent().css({'width' : '800px'});
		            	$(this).css({'width' : '800px', 'height' : '540px'});
						$(this).parent().parent().css({'top' : '-190px', 'left' : '-125px'});								
		            	$("#jquery-cycle-next, #jquery-cycle-prev").hide();		            	
		            /*}
		            else		            
					{
						$(this).addClass("hover").stop()					
							.animate({
								width: '800px',
								height: '540px'
							}, 150);
							
							$(this).parent().parent().animate({
								top: '-190px',
								left: '-125px'
							}, 150);
					}*/
					$(".pop-up-caption").hide();
					
				} , function() {
				
				
					
					/*if  ($.browser.msie  && parseInt($.browser.version) == 7) 
		            {  */
		            	$(this).parent().css({'width' : '400px'});
		            	$(this).css({'width' : '400px', 'height' : '270px'});
						$(this).parent().parent().css({'top' : '0px', 'left' : '0px'});
		            	$("#jquery-cycle-next, #jquery-cycle-prev").show();
		            	$(".pop-up-caption").show();
		            	if  ($.browser.msie  && parseInt($.browser.version) == 7)
		            	{
		            		//IE7
		            	}
		            	else
		            	{
		            		$(this).parent().parent().css({'z-index' : '1'});
							$(this).css({'z-index' : '0', 'overflow' : 'hidden'});
		            	}
		           /* }
		            else
		            {
		            	$(this).removeClass("hover").stop()					
							.animate({
								width: '400px',
								height: '270px'	
							}, 150, 
								function()
									{
										$(this).parent().parent().css({'z-index' : '1'});
										$(this).css({'z-index' : '0', 'overflow' : 'hidden'});
										$(".pop-up-caption").show();
									}					
							);
							
							$(this).parent().parent().animate({
								top: '0px',
								left: '0px'
							}, 150);
							
							
		            }*/
		            
			});
            
            
            
            
            
          });
          });
        });
      }); 
    });
  });

  $("a#close-button").click(function() { /*Close button click event*/
    $("#pop-up").fadeOut("fast", function() { /*Hide loaded page, to stop transparency issues*/
      $("#pop-up").fadeOut("slow", function() {  /*Hide pop-up div*/
        $("#slideshow-cycle").empty();
        $("#pop-up-loader").hide();  /*Hide page data placeholder*/
        $("#pop-up-loading").show();  /*Show loading animation*/
      });
    });
  });
}

function buttonClicked() 
{	
	$(".popupImageToZoom").parent().parent().css({'z-index' : '1', 'width' : 'auto', 'height' : 'auto'});
}

function addRolloverToImages(containerID){
	$(containerID + ' input').each(function(){		
		var containerArray = $(this).attr("src").split("?");
		containerArray = containerArray[0].split(".");	
		if (containerID == ".form-button") {
			$(this).attr("title", "Send");
			$(this).attr("alt", "Send");
		}
		$(this).mouseover(function() {
        	$(this).attr("src", containerArray[0]+"_over."+containerArray[1]);
  		}).mouseout(function(){
    		$(this).attr("src", containerArray[0]+"."+containerArray[1]);
  		});
	})
}


