


function winBRopen(theURL, Name, popW, popH, scroll) { // V 1.0
var winleft = (screen.width - popW) / 2;
var winUp = (screen.height - popH) / 2;
winProp = 'width='+popW+',height='+popH+',left='+winleft+',top='+winUp+',scrollbars='+scroll+',resizable'
Win = window.open(theURL, Name, winProp)
if (parseInt(navigator.appVersion) >= 4) { Win.window.focus(); }

}





function showPosts(what)
	{
	document.getElementById('dnn_newsLatest').className='hiddy';
	document.getElementById('dnn_newsPopular').className='hiddy';
	document.getElementById('dnn_newsComment').className='hiddy';

	document.getElementById('dnn_newsLatestLink').className='menNews';
	document.getElementById('dnn_newsPopularLink').className='menNews';
	document.getElementById('dnn_newsCommentLink').className='menNews';

	
	document.getElementById(what).className='vissy';
	document.getElementById(what+"Link").className='menNewsActive';
	}


//Email validation
function isValidEmailAddress(emailAddress){var pattern=new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);return pattern.test(emailAddress);}




// JavaScript Document
jQuery.noConflict();

jQuery(document).ready(function() {
	//ACCORDION BUTTON ACTION	
	jQuery('.hostAccordion').click(function() {
		jQuery('.hostContainer').slideUp('normal');	
		jQuery(this).next().slideDown('normal');
//		jQuery('a.hostAccordion').css("background-image", "url(../../images/container/hostBulletDown.gif)");
	});
	
								



//EMAILING FUNCTION
    jQuery('.error').hide();

    jQuery(".emailButton").click(function() {
        // validate and process form
        // first hide any error messages

        jQuery('.error').hide();

        var name = jQuery("input#name").val();
        if (name == "") {
            jQuery("label#name_error").show();
            jQuery("input#name").focus();
            return false;
        }
        var email = jQuery("input#email").val();
        if (email == "") {
            jQuery("label#email_error").show();
            jQuery("input#email").focus();
            return false;
        }
		
		var emailTo = jQuery("input#emailTo").val();
        
        if (email!="" && !isValidEmailAddress(email)) {
            jQuery("label#email_error").show();
            jQuery("input#email").focus();
            jQuery("label#email_error").html("Invalid email");
            return false;
        }


        var message = jQuery("textarea[name='ta']").val();
        if (message == "") {
            jQuery("label#message_error").show();
            jQuery("textarea[name='ta']").focus();
            return false;
        }


        var dataString = 'name=' + name + '&email=' + email + '&emailTo=' + emailTo + '&message=' + message;
        //alert(dataString); return false;


        jQuery.ajax({
            type: "POST",
            url: "http://www.radiolive.co.nz/Handlers/EmailContactUs.ashx",
            data: dataString,
            success: function() {
                jQuery('#contact_form').html("<div id='message'></div>");
                jQuery('#message').html("<b>Your email has been sent.</b>")
        .append("<p>Thanks for taking the time to contact us.</p>")
        .hide()
        .fadeIn(1500, function() {
                jQuery('#message');
        });
            }
        });

        return false;
    });

//EMAILING FUNCTION




















	
	
	//HIDE THE DIVS ON PAGE LOAD
	jQuery('.hostContainer').hide();

	var d = new Date();
	var curr_day = d.getDay();
	var weekDay = false;
	if(curr_day>=2 && curr_day <=6)
	{
		weekDay = true;	
	}
	else
	{
		weekDay = false;			
	}



		
	var curr_hour = d.getHours();

//Weekday shows
	if(weekDay)
	{
		if(curr_hour>6 && curr_hour<9){
			jQuery('.hostContainer:eq(0)').slideDown('normal');
		}
		if(curr_hour>=9 && curr_hour<12){
			jQuery('.hostContainer:eq(1)').slideDown('normal');
		}
		if(curr_hour>=12 && curr_hour<13){
			jQuery('.hostContainer:eq(2)').slideDown('normal');
		}
		if(curr_hour>=13 && curr_hour<16){
			jQuery('.hostContainer:eq(3)').slideDown('normal');
		}
		if(curr_hour>=16 && curr_hour<18){
		jQuery('.hostContainer:eq(4)').slideDown('normal');
		/*	
		jQuery('.hostDetails').remove();
		jQuery('.hostContainer:eq(4)').css('overflow', 'visible');
		jQuery('.hostContainer:eq(4)').css('height', 90);
		jQuery('.hostContainer:eq(4)').css('background-image', 'url(/Portals/0/images/westpacLogo.gif)');
		jQuery('.hostContainer:eq(4)').css('background-Repeat', 'no-repeat');
		jQuery('.hostContainer:eq(4)').css('backgroundPosition', 'bottom center');
		*/
		}
		if(curr_hour>=18 && curr_hour<22){
			jQuery('.hostContainer:eq(5)').slideDown('normal');
		}
		if(curr_hour>=22 && curr_hour<24){
			jQuery('.hostContainer:eq(6)').slideDown('normal');
		}
		if(curr_hour==1){
			jQuery('.hostContainer:eq(6)').slideDown('normal');
		}
		if(curr_hour>=1 && curr_hour<5){
			jQuery('.hostContainer:eq(7)').slideDown('normal');
		}
		if(curr_hour>=5 && curr_hour<6){
			jQuery('.hostContainer:eq(8)').slideDown('normal');
		}
	}
	else
	{
		//Saturday
		if(curr_day==7)
		{
		//Kitchen and Garden
		if(curr_hour>=6 && curr_hour<10){
			jQuery('.hostContainer:eq(0)').slideDown('normal');
		}
		//Graeme Hill
		if(curr_hour>=10 && curr_hour<14){
			jQuery('.hostContainer:eq(1)').slideDown('normal');
		}
		if(curr_hour>=14 && curr_hour<19){
			jQuery('.hostContainer:eq(2)').slideDown('normal');
		}
		if(curr_hour>=19 && curr_hour<20){
			jQuery('.hostContainer:eq(3)').slideDown('normal');
		}
		if(curr_hour>=20 && curr_hour<24){
			jQuery('.hostContainer:eq(4)').slideDown('normal');
		}	
		if(curr_hour==1){
			jQuery('.hostContainer:eq(4)').slideDown('normal');
		}	
		if(curr_hour>=1 && curr_hour<5){
			jQuery('.hostContainer:eq(4)').slideDown('normal');
		}
		if(curr_hour>=5 && curr_hour<6){
			jQuery('.hostContainer:eq(4)').slideDown('normal');
		}
	}
	//Sunday
	else
	{
		//Kitchen and Garden
		if(curr_hour>=6 && curr_hour<9){
			jQuery('.hostContainer:eq(0)').slideDown('normal');
		}
		//Graeme Hill
		if(curr_hour>=9 && curr_hour<10){
			jQuery('.hostContainer:eq(1)').slideDown('normal');
		}
		if(curr_hour>=10 && curr_hour<14){
			jQuery('.hostContainer:eq(2)').slideDown('normal');
		}
		if(curr_hour>=14 && curr_hour<19){
			jQuery('.hostContainer:eq(3)').slideDown('normal');
		}
		if(curr_hour>=19 && curr_hour<20){
			jQuery('.hostContainer:eq(4)').slideDown('normal');
		}	
		if(curr_hour>=20 && curr_hour<24){
			jQuery('.hostContainer:eq(4)').slideDown('normal');
		}
		if(curr_hour>=1 && curr_hour<6){
			jQuery('.hostContainer:eq(4)').slideDown('normal');
		}
	  }		
	}




setTimeout(function(){jQuery("#dnn_advert").fadeTo('slow', 0);}, 15000);

jQuery("#hoverPoint").mouseover(function(){
jQuery("#dnn_advert").stop().fadeTo('slow', 1);
});
jQuery("#hoverPoint").mouseout(function(){
jQuery("#dnn_advert").stop().fadeTo(6000, 0);
});




/* TABS */ 


jQuery('#tabs div').hide();
jQuery('#tabs div:first').show();
jQuery('#tabs ul li:first').addClass('active');
 
jQuery('#tabs ul li a').click(function(){
jQuery('#tabs ul li').removeClass('active');
jQuery(this).parent().addClass('active');
var currentTab = jQuery(this).attr('href');
jQuery('#tabs div').hide();
jQuery(currentTab).fadeIn();
return false;
});



/*
        jQuery('.CommentSubmitButton').click(function(){
         tb_show('Your post will appear after it has been moderated','TB_inline?height=120&amp;width=800&amp;inlineId=comsubmit');
            return false;
        });
 
 
       jQuery('input#TBsubmit').click(function(){
            document.Form.submit();
        });

*/


jQuery('.newsBulletin').popupWindow({ 
centerBrowser:1,
height:415, 
width:470
}); 


jQuery('.audioPlayer').popupWindow({ 
centerBrowser:1,
height:415, 
width:470
}); 

jQuery('.webCam').popupWindow({ 
centerBrowser:1,
height:415, 
width:470
});


});




