﻿$(document).ready(function(){
	
	setUpSearchForm();	
		
	try{
		$("a.example-link").fancybox({
			'width'	: 900,
			'height': 750,
	        	'autoScale' : false,
	        	'transitionIn'	: 'none',
			'transitionOut'	: 'none',
			'type'	: 'iframe',
			titleShow : false
		});
		
		$("a.example-link-big").fancybox({
                    'width'        : '95%',
                    'height': '95%',
                    'autoScale' : false,
                    'transitionIn'	: 'none',
                    'transitionOut'     : 'none',
                    'type'          : 'iframe',
                    titleShow : false
		});
		
		$("a.movie-link").fancybox({
			'width'	: 700,
			'height': 550,
	        	'autoScale' : false,
	        	'transitionIn'	: 'none',
			'transitionOut'	: 'none',
			'type'	: 'iframe',
			titleShow : false
		});
		
		$("a.image-link").fancybox();
		$("#webcamera").fancybox({
			'width'	: 700,
			'height': 500,
	        	'autoScale' : false,
	        	'transitionIn'	: 'none',
			'transitionOut'	: 'none',
			'type'	: 'iframe'
		});
		$(".editlink").fancybox({
		'width'	: 800,
		'height': 800,
        	'autoScale' : false,
        	'transitionIn'	: 'none',
		'transitionOut'	: 'none',
		'type'	: 'iframe'
		});
		
		$('#puffContainer .puff').css({cursor: "pointer"}).click(function(){
			var url = $(this).find('a').attr('href');			
			document.location = url;	
		});
		
		
	}
	catch(e)
	{
		alert(e);	
	}

	
});

function setUpSearchForm()
{
		$('#searchForm input[type="text"], #search').each(function(){
		    
		    var id = $(this).attr('id');
		    var lbl = $('label[for="' + id + '"]');
		    
		    
		    if($(this).val() == "")
		        $(this).val($(lbl).text());
		    
		    $(this).focus(function () {
		        $obj = $(this);
		        if($obj.val() == $(lbl).text())
		        {   		           
		          $obj.val(''); 
		        }
		         
		    }).blur(function(){
                 	$obj = $(this);
		         
		         if($obj.val() == "")
		         {			           
		            $obj.val($(lbl).text());
		         }
		    });

		    $(lbl).hide();
	});

}

function scrollToID(id){
	try{
		var $target = $(id);
		$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
		if ($target.length) 
		{
			var targetOffset = $target.offset().top - 94;
			$('html,body').animate({scrollTop: targetOffset},{duration: 600, easing:'easeInSine'});		
		}
	}catch(e){
		alert("scrollToID() " + e.message);
	}
}
function wFlash(id,movie)
{
	var params = {};
       	var flashvars = {};
       	var url = movie;
       	
       	params.allowfullscreen = "true";
       	params.allowscriptaccess = "true";
        params.wmode = "transparent"; 
                            
       	swfobject.embedSWF(url, id, "100%", "100%", "10.0.0" ,false,flashvars,params);
}

jQuery.fn.flowScroll = function() 
{
	this.find("a[href^=#]").click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
		    && location.hostname == this.hostname) {
		      var $target = $(this.hash);
		      $target = $target.length && $target 
		      || $('[name=' + this.hash.slice(1) +']');
		      if ($target.length) {
		        var targetOffset = $target.offset().top - 94;
		        $('html,body')
		        .animate({scrollTop: targetOffset},{duration: 600, easing:'easeInSine'});
		       return false;
		      }
		    }
	     });
}
