
function swapChart(chartid){
	 for ( x=0; x < document.getElementsByTagName('div').length; x++ ) {
		var thisDivId = document.getElementsByTagName('div')[x].id;
		
		if (thisDivId.search(/ctnID_/) != -1){
			if (thisDivId == 'ctnID_' + chartid){
				document.getElementById(thisDivId).style.display = 'block';
				document.getElementById('tabs_' + chartid).className = 'chartingTab active';
			}
			else
			{
				document.getElementById(thisDivId).style.display = 'none';
				strDiv = thisDivId.split('_');
				document.getElementById('tabs_' + strDiv[1]).className = 'chartingTab notactive';
			}
		}
	 }
}

function showActivityDiv(f){
	 for ( x=0; x < document.getElementsByTagName('div').length; x++ ) {
		var thisDivId = document.getElementsByTagName('div')[x].id;
		
		if (thisDivId.search(/activity_/) != -1){
			if (thisDivId == 'activity_' + f){
				document.getElementById(thisDivId).style.display = 'block';
			}
			else
			{
				document.getElementById(thisDivId).style.display = 'none';
			}
		}
	 }
}

function showDetail(f){
	
	if(document.getElementById(f).style.display == 'none'){
		document.getElementById(f).style.display = '';
	}else{
		document.getElementById(f).style.display = 'none';
	}
	curvyCorners.redraw();
}

function showArkibDiv(f,g){
	 for ( x=0; x < document.getElementsByTagName('div').length; x++ ) {
		var thisDivId = document.getElementsByTagName('div')[x].id;
		
		if (thisDivId.search(/arkibDiv_/) != -1){
			if (thisDivId == 'arkibDiv_' + f + '_' + g){
				document.getElementById(thisDivId).style.display = '';
			}
			else
			{
				document.getElementById(thisDivId).style.display = 'none';
			}
		}
		if (thisDivId.search(/arkibIcon_/) != -1){
			if (thisDivId == 'arkibIcon_' + f + '_' + g){
				document.getElementById(thisDivId).setAttribute("class","iconMinus");
			}else{
				document.getElementById(thisDivId).setAttribute("class","iconPlus");
			}
		}
	 }
	 curvyCorners.redraw();
}
function showArkibActivityDiv(f,g){
	 for ( x=0; x < document.getElementsByTagName('div').length; x++ ) {
		var thisDivId = document.getElementsByTagName('div')[x].id;
		
		if (thisDivId.search(/activityArkib_/) != -1){
			if (thisDivId == 'activityArkib_' + f + '_' + g){
				document.getElementById(thisDivId).style.display = '';
				
			}
			else
			{
				document.getElementById(thisDivId).style.display = 'none';
			}
			
		}
	 }
	 curvyCorners.redraw();
}

function changeClass(action,div){
	if(action == 'over'){
		document.getElementById(div).style.background='#e1eca3';
	}else{
		document.getElementById(div).style.background='';
	}
}

function confirmDelete(e) {
  if (confirm("Adakah anda pasti untuk melupuskan data ini?")) {
    document.location = e;
  }
}

function checkGroup(){
	if(document.getElementById('group').value=='2' || document.getElementById('group').value=='5'){
		document.getElementById('tr_state').style.display = '';
		document.getElementById('tr_school').style.display = '';
		curvyCorners.redraw();
	}else{
		document.getElementById('tr_state').style.display = 'none';
		document.getElementById('tr_school').style.display = 'none';
		curvyCorners.redraw();
	}
}

function checkOption(){
	if(document.getElementById('asnb').value=='1'){
		document.getElementById('tr_account').style.display = '';
		curvyCorners.redraw();
	}else{
		document.getElementById('tr_account').style.display = 'none';
		curvyCorners.redraw();
	}
}

function theRotator() {
		$('div#rotator ul li').css({opacity: 0.0});		
		$('div#rotator ul li:first').css({opacity: 1.0});			
		setInterval('rotate()',5000);		
	}
	
	function rotate() {	
		//Get the first image
		var current = ($('div#rotator ul li.show')?  $('div#rotator ul li.show') : $('div#rotator ul li:first'));
	
		//Get next image, when it reaches the end, rotate it back to the first image
		var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('div#rotator ul li:first') :current.next()) : $('div#rotator ul li:first'));	
		
		//Set the fade in effect for the next image, the show class has higher z-index
		next.css({opacity: 0.0})
		.addClass('show')
		.animate({opacity: 1.0}, 1000);
	
		//Hide the current image
		current.animate({opacity: 0.0}, 1000)
		.removeClass('show');
		
	};
	
	$(document).ready(function() {		
		//Load the slideshow
		theRotator();
	});

function openWin(e){
	mywindow = window.open(e,'Skim','location=1,status=1,scrollbars=1,width=600,height=400');
	mywindow.moveTo(0,0);
}	


