// Opening Popup Windows
function OpenMyWindow(url,winName,h,w) { // (url,winName,height,width)
var p = "height=" + h + ",width=" + w + ",scrollbars=no";
window.open(url,winName,p);
} 

function listen_live(url) {
	newwindow=window.open(url,'name','height=385,width=276');
	if (window.focus) {newwindow.focus()}
	return false;
}

//Side Image Rotator
$.fn.cycle.defaults.timeout = 6000;
$(function() {
    // run the code in the markup!
    $('div pre code').not('#skip,#skip2').each(function() {
        eval($(this).text());
    });
});
function onBefore() {
    $('#output').html("Scrolling image:<br>" + this.src);
    //window.console.log(  $(this).parent().children().index(this) );
}
function onAfter() {
    $('#output').html("Scroll complete for:<br>" + this.src)
        .append('<h3>' + this.alt + '</h3>');
}	
    
// Initialises the demo scollpanes on the page.			
$(function() {
	$('.talent-text').jScrollPane();
	$('#pane1').jScrollPane();
});
		
// Subnavigation Rollovers
$(function () {
   if ($.browser.msie && $.browser.version < 7)return; $('#sub_navigation li') .removeClass('highlight') .find('a') .append('<span class="hover" />').each(function () {
      var $span = $('> span.hover', this).css('opacity', 0); $(this).hover(function () {
         // on hover
         $span.stop().fadeTo(350, 1); }
      , function () {
         // off hover
         $span.stop().fadeTo(350, 0); }
      ); }
   ); }
); 	
  
// Header Navigation -- Currently Not in Use
//$(function () {
//   if ($.browser.msie && $.browser.version < 7) return; $('#navigation1 li') .removeClass('highlight') .find('a') .append('<span class="hover" />').each(function () {
//      var $span = $('> span.hover', this).css('opacity', 0); $(this).hover(function () {
         // on hover
//         $span.stop().fadeTo(500, 1); }
//      , function () {
         // off hover
//         $span.stop().fadeTo(500, 0); }
//      ); }
//   ); }
//);


// Footer Navigation -- Currently Not in Use
//$(function () {
//   if ($.browser.msie && $.browser.version < 7)return; $('#navigation2 li') .removeClass('highlight') .find('a') .append('<span class="hover" />').each(function () {
//      var $span = $('> span.hover', this).css('opacity', 0); $(this).hover(function () {
//         // on hover
//         $span.stop().fadeTo(500, 1); }
//      , function () {
         // off hover
//         $span.stop().fadeTo(500, 0); }
//      ); }
//   ); }
//);
    
// Listen Live Info -- Currently Not In Use	
//$(function () {
//	if ($.browser.msie && $.browser.version < 7)return;
//    	$('#listen_live li')
//    	.removeClass('highlight')
//        .find('a')
//            .append('<span class="hover" />').each(function () {
//                    var $span = $('> span.hover', this).css('opacity', 0);
//                    $(this).hover(function () {
//                        // on hover
//                        $span.stop().fadeTo(350, 1);
//                    }, function () {
//                        // off hover
//                        $span.stop().fadeTo(350, 0);
//                    });
//                });
//});	

	
// Doing a little validation stuff		
$(function(){

	$("#f-error-1").hide();	
	$("#f-error-2").hide();	
	$("#f-error-3").hide();
	$("#f-error-4").hide();
	
	$("#close-1").click(function(){
		$("#f-error-1").fadeOut("slow");
	});
	$("#close-2").click(function(){
		$("#f-error-2").fadeOut("slow");
	});
	$("#close-3").click(function(){
		$("#f-error-3").fadeOut("slow");
	});
	$("#close-5").click(function(){
		$("#f-error-4").fadeOut("slow");
	});
	$("#close-6").click(function(){
		$("#f-error-6").fadeOut("slow");
	});
	$("#close-4").click(function(){
		$("#f-success").fadeOut("slow");
	});
	$(".f-h-container").hide();
	
	$("#show-f-h-container").click(function(){
		$(".f-h-container").slideToggle("slow");
	});
});

function validate_request_form ( )
{
	valid = true;

        if ( document.request_form.firstname.value == "" )
        {
                valid = false;
				$("#f-error-1").fadeIn(1500);		
        }
		if ( document.request_form.lastname.value == "" )
        {
                valid = false;
				$("#f-error-2").fadeIn(1500);
        }
		if((document.request_form.email.value.length<6) || (document.request_form.email.value.indexOf('@')<2) || (document.request_form.email.value.indexOf('.')<1))
		{
                valid = false;
				$("#f-error-3").fadeIn(1500);
		}

        return valid;
}
//function validate_event_form ()
//{
//	valid = true;
//	
//		 if ( document.insert.eventname.value == "" )
//        {
//                valid = false;
//				$("#f-error-1").fadeIn(1500);		
//        }
//		 if ( document.insert.eventday.value == "" )
//        {
//                valid = false;
//				$("#f-error-2").fadeIn(1500);		
//        }
//         if ( document.insert.eventmonth.value == "" )
//        {
//                valid = false;
//				$("#f-error-2").fadeIn(1500);		
//        }
//	     if ( document.insert.eventyear.value == "" )
//        {
//                valid = false;
//				$("#f-error-2").fadeIn(1500);		
//        }
//		if ( document.insert.eventlocation.value == "" )
//        {
//                valid = false;
//				$("#f-error-4").fadeIn(1500);		
//        }
//		 if ( document.insert.eventdesc.value == "" )
//        {
//                valid = false;
//				$("#f-error-3").fadeIn(1500);		
//        }
//	return valid;
//}


$(function(){
		   
$('#insert')
	.validate({
      submitHandler: function(form) {
       $(form).ajaxSubmit({
          success: function() {
            $('#insert').hide();
            $('#main_content').append("<p class='thanks'>Thanks! Your request has been sent.</p>")
          }
       });
      }
    });  
	
});