// JavaScript Document

 var months = new Array("", "Januarie", "Februarie", "Maart", "April", "Mei", "Junie", "Julie", "Augustus", "September", "Oktober", "November", "Desember");

function addCommas(nStr) {
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}

function testSelected(rb) {
	for (count=0;count<rb.length;count++) {
		if (rb[count].checked)
			return true;
	}
	return false;
}

function getSelected(rb) {
	for (count=0;count<rb.length;count++) {
		if (rb[count].checked)
			return count;
	}
	return -1;
}

// verifies that thee email address provided is correct.

//var reEmail = /^.+\@.+\..+$/
var reEmail =  /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/
var defaultEmptyOK = false


function isEmpty(s) { 
  return ((s == null) || (s.length == 0))
}


function isEmail (s){
  if (isEmpty(s)) 
    if (isEmail.arguments.length == 1) return defaultEmptyOK;
    else return (isEmail.arguments[1] == true);
    
  else {
    return reEmail.test(s)
  }
}


function windowpic(f,w,h) {
	window.open("vergroot.asp?f="+f,'popup','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=' + w + ',height=' + h);
}

function windowpic2(f,d) {
	window.open("vergroot.asp?d="+d+"&f="+f,'popup','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=100,height=100');
}

function numbersonly(e){
  var unicode=e.charCode? e.charCode : e.keyCode;
//alert(unicode);
	if ((unicode!=8) && (unicode!=9)) { 
    if ((unicode<43 || unicode>57) && (unicode!=37) && (unicode!=39) && (unicode!=35) && (unicode!=36)) 
      return false 
  }
}


// page functions

var currentSchedule = 1;

function changeWeather(id) {
	if (currentWeather==id)
		return;
		
	$("#weather"+currentWeather).hide();
	$("#wind"+currentWeather).hide();
	$("#weatherlink"+currentWeather).removeClass("active");
	
	currentWeather = id;
	
	$("#weather"+currentWeather).show();
	$("#wind"+currentWeather).show();
	$("#weatherlink"+currentWeather).addClass("active");
}

function chooseSchedule(id) {
	$("#scli"+currentSchedule).removeClass("active");	
	$("#schedule"+currentSchedule).hide();
	
	currentSchedule = id;
	$("#scli"+currentSchedule).addClass("active");	
	$("#schedule"+currentSchedule).show();
	$("#schedule"+currentSchedule).scrollTop(0);
}

function chooseScheduleFull(id) {
	$("#schedule" + currentSchedule + " .oggend").hide();
	$("#schedule" + currentSchedule + " .middag").hide();
	$("#schedule" + currentSchedule + " .aand").hide();
				
	$("#scli"+currentSchedule).removeClass("active");	
	$("#schedule"+currentSchedule).hide();
	
	currentSchedule = id;
	$("#scli"+currentSchedule).addClass("active");	
	$("#schedule"+currentSchedule).show();
	$("#schedule"+currentSchedule).scrollTop(0);
	
	if (currentTime=="Volledige")  {
		$("#schedule" + currentSchedule + " .oggend").show();
		$("#schedule" + currentSchedule + " .middag").show();
		$("#schedule" + currentSchedule + " .aand").show();
	} else {
		$("#schedule" + currentSchedule + " ." + currentTime.toLowerCase()).show();
	}
}


function MakeDatePicker(id) {
	$('#'+id+'Picker').DatePicker({
		format:'e B Y',
		date: $('#'+id+'').val(),
		current: $('#'+id+'').val(),
		starts: 1,
		position: 'r',
		onBeforeShow: function(){					
			//$('#'+id+'Picker').DatePickerSetDate($('#'+id+'').val(), true);
		},
		onChange: function(formated, dates){
			var i = $('#'+id+'Picker').GetLayout();
			
			if (i=="day") {
				$('#'+id+'').val(formated);
				$('#'+id+'Picker').DatePickerHide();
			}
		},
		locale: {
			days: ["Sondag", "Maandag", "Dinsdag", "Woensday", "Donderdag", "Vrydag", "Saterdag", "Sondag"],
			daysShort: ["Son", "Maa", "Din", "Woe", "Don", "Vry", "Sat", "Son"],
			daysMin: ["So", "Ma", "Di", "Wo", "Do", "Vr", "Sa", "So"],
			months: ["Januarie", "Februarie", "Maart", "April", "Mei", "Junie", "Julie", "Augustus", "September", "Oktober", "November", "Desember"],
			monthsShort: ["Jan", "Feb", "Maa", "Apr", "Mei", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Des"],
			weekMin: 'wk'
		}
	});
}






function printPage() {
	window.print();
}

$(document).ready(function(){
		if (swapPresenters=="1")
			$('#topRotate').jshowoff({ speed:5000, links: false, controls: false }); 
});




// google search code

	function frmValidateSearchMainView(thisform){

		var msg = "Please enter text to search for";
		if (document.RSGMSearch.q.value == "")
		{
			alert(msg);
			document.RSGMSearch.q.focus();
			return false;

		} else if (document.RSGMSearch.q.value == " ")
		{
			alert(msg);
			document.RSGMSearch.q.focus();
			return false;
		} else if (document.RSGMSearch.q.value == "  ")
		{
			alert(msg);
			document.RSGMSearch.q.focus();
			return false;
		} else if (document.RSGMSearch.q.value == "--- enter keywords here ---")
		{
			alert(msg);
			document.RSGMSearch.q.focus();
			return false;
		}
	
		//This provide RSGfm search
		if(document.RSGMSearch.radSearch[0].checked){
			document.RSGMSearch.cx.value = "partner-pub-7837760522231511:9823238686";
			document.RSGMSearch.cof.value = "FORID:10";

			//This provide all SABC site search
		} else if(document.RSGMSearch.radSearch[1].checked){
			document.RSGMSearch.cx.value = "partner-pub-7837760522231511:7790677851";
			document.RSGMSearch.cof.value = "FORID:10";
			//This provide web search
		} else {
			
			document.RSGMSearch.cx.value = "partner-pub-7837760522231511:5273414151";
			document.RSGMSearch.cof.value = "FORID:10";
		}

		document.RSGMSearch.submit();
	}

	function FocusTitle(){
		document.RSGMSearch.q.value = " ";
	}
