String.prototype.trim = function() {
                return this.replace(/^\s+|\s+$/g,"");
}



function valid_email(email){
    var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
    return reg.test(email)
}
function validate_feedback_form(){
                var title=document.getElementById("title").value.trim();
                var first_name=document.getElementById("first_name").value.trim();
                var surname=document.getElementById("surname").value.trim();
                var email = document.getElementById("email").value.trim();
                var privacy = document.getElementById("privacy");

                var message='The following errors have been found-\n\n';
                var flag=true;
                if(title == "" ){
                    flag=false;
                    message=message+"\t- Title must be provided\n"
                }
                if(first_name == "" ){
                    flag=false;
                    message=message+"\t- First Name must be provided\n"
                }
                if(surname == "" ){
                    flag=false;
                    message=message+"\t- Surname must be provided\n"
                }

                if(email == ""  ){
                    flag=false;
                    message=message+"\t- Email must be provided\n"
                }else{
                    if(!valid_email(email)){
                        flag=false;
                        message=message+"\t- Email must be a valid email address\n"
                    }
                }
                

                if (!flag){
                        alert(message);
                 }
                    return flag;
}
function show(id){
     ID = document.getElementById(id);
     ID.style.display = "";
}

function hide(id){
     ID = document.getElementById(id);
     ID.style.display = "none"; 
}


function googleSearch() {
  if (document.searchquery.searchbox.value!="") { 
      window.location ="http://www.google.com/search?hl=en&q=" + document.searchquery.searchbox.value + "%3Asite:www.aquasure.com.au" ;
  }
  else {
    alert("Please enter a search term.")
    document.searchquery.searchbox.focus();
  }
}

$(document).ready(function(){
	$('#gal_1 .gallery li .thumb a').lightBox();
	$('#gal_2 .gallery li .thumb a').lightBox();
});


var headline_count;
var headline_interval;
var old_headline = 0;
var current_headline = 0;
$(document).ready(function(){
  headline_count = $("div.headline").size();
  $("div.headline:eq("+current_headline+")").css('top', '5px');
 
  headline_interval = setInterval(headline_rotate,5000);
  $('#scrollup').hover(function() {
    clearInterval(headline_interval);
  }, function() {
    headline_interval = setInterval(headline_rotate,5000);
    headline_rotate();
  });
});
function headline_rotate() {
  current_headline = (old_headline + 1) % headline_count;
  $("div.headline:eq(" + old_headline + ")")
    .animate({top: -205},"slow", function() {
      $(this).css('top', '30px');
    });
  $("div.headline:eq(" + current_headline + ")")
    .animate({top: 5},"slow");  
  old_headline = current_headline;
}

$(document).ready(function(){
	
 				/*$('.imglist li a').click(function(){
 					imgFile = $(this).attr('href');
 					imgTitle = $(this).attr('title');
					$('.imgblock').html('<img src="gallery_image.php?file=galleryimages/'+imgFile+'"/>');
 					$('.imgcaption p').text(imgTitle);
 					$(this).parent().parent().children('li').removeClass('current');
 					$(this).parent('li').addClass('current');
 					return false;
 				});*/
				
				  $(".galleries_list ul li a").click(function() {
 					$(this).parent().parent().children('li').removeClass('current');
 					$(this).parent('li').addClass('current');
 					return false;
				  }); 
});
$(document).ready(function(){
 				$('.videolist li a').click(function(){
 					videoFile = $(this).attr('href');
 					videoTitle = $(this).attr('title');
					$('.videoblock embed').remove();
					$('.videoblock').html('<embed allowfullscreen="true" allowscriptaccess="always" flashvars="file='+videoFile+'" height="362" id="player2" name="player2" src="flash/player-viral.swf" type="application/x-shockwave-flash" width="480"></embed>');
 					$('.featured h3').text(videoTitle);
 					$(this).parent().parent().children('li').removeClass('current');
 					$(this).parent('li').addClass('current');
 					return false;
 				});

	
	        $('.photo_gallery_links').click(function(){
	            var gallery_id = $(this).attr('id');
	            $.get("photo_gallery_ajax.php?id="+gallery_id, function(data){
	                    $("#artist_impressions").html(data);   
	            });
	
	        });
	        $('.photo_gallery_links').click(function(){
	            var gallery_id = $(this).attr('id');
	            $.get("photo_gallery_ajax.php?id="+gallery_id, function(data){
	                    $("#artist_impressions").html(data);   
	            });
	
	        });	        
	        $('.imglist li a').live("click",function(){
					imgFile = $(this).attr('href');
					imgTitle = $(this).attr('title');
					$("#imgblock").html('<img src="'+imgFile+'"/>');	
					$('.imgcaption p').text(imgTitle);
					$(".imglist ul li").removeClass('current');
					$(this).parent('li').addClass('current');
					return false;
				});
});
