
function search_widget_onLoad() {
	jQuery('#searchsubmit').val('');
}

if (window.attachEvent) {window.attachEvent('onload', search_widget_onLoad);}
else if (window.addEventListener) {window.addEventListener('load', search_widget_onLoad, false);}
else {document.addEventListener('load', search_widget_onLoad, false);}

/*
jQuery.fn.infiniteCarousel = function () {
//function infiniteCarousel(){
    function repeat(str, num) {
        return new Array( num + 1 ).join( str );
    }

    return this.each(function () {
        var $wrapper = jQuery('> div', this).css('overflow', 'hidden'),
            $slider = $wrapper.find('> ul'),
            $items = $slider.find('> li'),
            $single = $items.filter(':first'),

            singleWidth = $single.outerWidth(),
            visible = Math.ceil($wrapper.innerWidth() / singleWidth), // note: doesn't include padding or border
            currentPage = 1,
            pages = Math.ceil($items.length / visible);


        // 1. Pad so that 'visible' number will always be seen, otherwise create empty items
        if (($items.length % visible) != 0) {
            $slider.append(repeat('<li class="empty" />', visible - ($items.length % visible)));
            $items = $slider.find('> li');
        }

        // 2. Top and tail the list with 'visible' number of items, top has the last section, and tail has the first
        $items.filter(':first').before($items.slice(- visible).clone(true).addClass('cloned'));
        $items.filter(':last').after($items.slice(0, visible).clone(true).addClass('cloned'));
        $items = $slider.find('> li'); // reselect

        // 3. Set the left position to the first 'real' item
        $wrapper.scrollLeft(singleWidth * visible);

        // 4. paging function
        function gotoPage(page) {
            var dir = page < currentPage ? -1 : 1,
                n = Math.abs(currentPage - page),
                left = singleWidth * dir * visible * n;

            $wrapper.filter(':not(:animated)').animate({
                scrollLeft : '+=' + left
            }, 500, function () {
                if (page == 0) {
                    $wrapper.scrollLeft(singleWidth * visible * pages);
                    page = pages;
                } else if (page > pages) {
                    $wrapper.scrollLeft(singleWidth * visible);
                    // reset back to start position
                    page = 1;
                }

                currentPage = page;
            });

            return false;
        }

        //$wrapper.after('<a class="arrow back">&lt;</a><a class="arrow forward">&gt;</a>');

        // 5. Bind to the forward and back buttons
        jQuery('a.back', this).click(function () {
            return gotoPage(currentPage - 1);
        });

        jQuery('a.forward', this).click(function () {
            return gotoPage(currentPage + 1);
        });

        // create a public interface to move to a specific page
        jQuery(this).bind('goto', function (event, page) {
            gotoPage(page);
        });
    });
};
*/
  jQuery(document).ready(function() {

        //options( 1 - ON , 0 - OFF)
        var auto_slide = 1;
            var hover_pause = 1;
        var key_slide = 1;

        //speed of auto slide(
        var auto_slide_seconds = 1500;
        /* IMPORTANT: i know the variable is called ...seconds but it's
        in milliseconds ( multiplied with 1000) '*/

        /*move the last list item before the first item. The purpose of this is
        if the user clicks to slide left he will be able to see the last item.*/
        jQuery('#carousel_ul li:first').before(jQuery('#carousel_ul li:last'));

        //check if auto sliding is enabled
        if(auto_slide == 1){
            /*set the interval (loop) to call function slide with option 'right'
            and set the interval time to the variable we declared previously */
            var timer = setInterval('slide("right")', auto_slide_seconds);

            /*and change the value of our hidden field that hold info about
            the interval, setting it to the number of milliseconds we declared previously*/
            jQuery('#hidden_auto_slide_seconds').val(auto_slide_seconds);
        }

        //check if hover pause is enabled
        if(hover_pause == 1){
            //when hovered over the list
            jQuery('#carousel_ul').hover(function(){
                //stop the interval
                clearInterval(timer)
            },function(){
                //and when mouseout start it again
                timer = setInterval('slide("right")', auto_slide_seconds);
            });

        }

        //check if key sliding is enabled
        if(key_slide == 1){

            //binding keypress function
            jQuery(document).bind('keypress', function(e) {
                //keyCode for left arrow is 37 and for right it's 39 '
                if(e.keyCode==37){
                        //initialize the slide to left function
                        slide('left');
                }
				else if(e.keyCode==39 ){
                        //initialize the slide to right function
                        slide('right');
                }
            });

        }

  });

//FUNCTIONS BELLOW

//slide function
function slide(where){

            //get the item width
            //var item_width = jQuery('#carousel_ul li').outerWidth() + 10;
            var item_width = 220;

            /* using a if statement and the where variable check
            we will check where the user wants to slide (left or right)*/
            if(where == 'left'){
                //...calculating the new left indent of the unordered list (ul) for left sliding
                var left_indent = parseInt(jQuery('#carousel_ul').css('left')) + item_width;
            }else{
                //...calculating the new left indent of the unordered list (ul) for right sliding
                var left_indent = parseInt(jQuery('#carousel_ul').css('left')) - item_width;

            }

            //make the sliding effect using jQuery's animate function... '
            jQuery('#carousel_ul:not(:animated)').animate({'left' : left_indent},500,function(){

                /* when the animation finishes use the if statement again, and make an ilussion
                of infinity by changing place of last or first item*/
                if(where == 'left'){
                    //...and if it slided to left we put the last item before the first item
                    jQuery('#carousel_ul li:first').before(jQuery('#carousel_ul li:last'));
                }else{
                    //...and if it slided to right we put the first item after the last item
                    jQuery('#carousel_ul li:last').after(jQuery('#carousel_ul li:first'));
                }

                //...and then just get back the default left indent
                jQuery('#carousel_ul').css({'left' : '-220px'});
            });

}

jQuery(document).ready( function(){
/*
	try{
		var set = 0;
		var ci = -1;
		var timer;
		function createLoop(dir){
			var id = 'slides';
			var el = 'div';
			var time = 5000;
			var lp = document.getElementById(id).getElementsByTagName(el);
			if(set == 0){
				$j("#showcase #next").click( function(){ clearTimeout(timer); createLoop(); } );
				$j("#showcase #prev").click( function(){ clearTimeout(timer); createLoop("reverse"); } );
			}
			set = 1;
			if(dir == "reverse"){
				ci = ci-1;
				if(ci < 0){ ci = lp.length-1; }
			}else{
				ci = ci+1;
				if(ci > lp.length-1){ ci = 0; }
			}
			for(var y=0; y<lp.length; y++){
				if(y != ci){ $j(lp[y]).fadeOut('slow'); }


			}
			jQuery(lp[ci]).fadeIn('slow');
			timer = setTimeout(function(){ createLoop(); }, time);
		}
		var lp = document.getElementById('slides').getElementsByTagName('div');
		for(var i=1; i<lp.length; i++){
			lp[i].style.display = 'none';
			if(i == lp.length-1){ document.getElementById('slides').style.visibility = 'visible'; setTimeout(function(){ createLoop(); }, 5000); }
		}
	}catch(e){}
*/
	//$('.infinteCarousel').infiniteCarousel();

//	jQuery(".cover", this).stop().animate({top:'180px'});
	//To switch directions up/down and left/right just place a "-" in front of the top/left attribute
	/*Vertical Sliding
	jQuery('.boxgrid.slidedown1').hover(function(){
		jQuery(".cover", this).stop().animate({top:'-250px'},{queue:false,duration:300});
	}, function() {
		jQuery(".cover", this).stop().animate({top:'0px'},{queue:false,duration:300});
	});
	$('.boxgrid.slidedown2').hover(function(){
		$(".cover", this).stop().animate({top:'-250px'},{queue:false,duration:300});
	}, function() {
		$(".cover", this).stop().animate({top:'0px'},{queue:false,duration:300});
	});
	$('.boxgrid.slidedown3').hover(function(){
		$(".cover", this).stop().animate({top:'-250px'},{queue:false,duration:300});
	}, function() {
		$(".cover", this).stop().animate({top:'0px'},{queue:false,duration:300});
	});
	*/
	//Caption Sliding (Partially Hidden to Visible)
	jQuery('.boxgrid.caption1').hover(function(){
		jQuery(".cover", this).stop().animate({top:'0px'},{queue:false,duration:160});
	}, function() {
		jQuery(".cover", this).stop().animate({top:'180px'},{queue:false,duration:160});
	});

	jQuery('.boxgrid.caption2').hover(function(){
		jQuery(".cover", this).stop().animate({top:'0px'},{queue:false,duration:160});
	}, function() {
		jQuery(".cover", this).stop().animate({top:'180px'},{queue:false,duration:160});
	});

	jQuery('.boxgrid.caption3').hover(function(){
		jQuery(".cover", this).stop().animate({top:'0px'},{queue:false,duration:160});
	}, function() {
		jQuery(".cover", this).stop().animate({top:'180px'},{queue:false,duration:160});
	});
	

	/*
	$("input.placeHolderInput, textarea.placeHolderInput")
	.filter(function(){
		return this.value.trim() == "";
	})
	.val(function(){
		return $(this).attr('title');
	})
	.addClass('unfocused')
	.focus(function(){
	        if($(this).val()==$(this).attr('title')){
			$(this).removeClass('unfocused').val('');
		}
	})
	.blur(function(){
		if($(this).val()==$(this).attr('title') || $(this).val().length==0){
			$(this).val($(this).attr('title')).addClass('unfocused');
		}
	});*/
});

jQuery(function(){
	jQuery("input.placeHolderInput, textarea.placeHolderInput").each(function(i, e){
		if( jQuery(e).val() == '' || jQuery(e).val()==jQuery(e).attr('title') ){
		        jQuery(e).val( jQuery(e).attr('title') ).addClass('unfocused');
		}
		jQuery(e).focus(function(){
		        if(jQuery(this).val()==jQuery(this).attr('title')){
				jQuery(this).removeClass('unfocused').val('');
			}
		})
		.blur(function(){
			if(jQuery(this).val()==jQuery(this).attr('title') || jQuery(this).val().length==0){
				jQuery(this).val(jQuery(this).attr('title')).addClass('unfocused');
			}
		});
	});
});



