/**
 * @author administrator
 */
var currentImage = 1;
function slideShow(){
	var imageURL = "/images/slide_home/";	
	//document.getElementById("slideImage").src=imageURL+currentImage+".jpg";
	document.getElementById("slideImage").src=imageURL+currentImage+".gif";
	if(currentImage < 5)
		currentImage ++;
	else	
		currentImage = 1;	
	setTimeout("slideShow()",2500);
}

function hideLogInErrors(){
	//hideError("errInvalidUserNamePassword");
	hideError('errUserName');	
	hideError('errPassword');	
	setFocus('userName');
}


function validateLogInForm(){	    
	var iError = 0;
    var userName=getValue('userName');
   	var password=getValue('password');
	iError = validateField(userName, 'errUserName', iError);
	iError = validateField(password, 'errPassword', iError);	
	if (iError > 0){
		return false;
	}else{
		return true;	
	}
}
function validateField(sValue, errDivID, iError){
	if (sValue==""){
		showError(errDivID);
		return iError + 1;
	}else{
		hideError(errDivID);
		return iError;
    }
}

function hideError(divID){
	document.getElementById(divID).style.display = 'none';
}

function showError(divID){
	document.getElementById(divID).style.display = 'block';
}

function getValue(fieldID){
	return document.getElementById(fieldID).value;
}

function setFocus(divID){
	document.getElementById(divID).focus();
}

function redirectPage(pageURL){
	//pageURL = pageURL.replace("'", "");
	window.location = pageURL;
}

function toogleLayer(divID){
	hideAllGandParentDivs();
	showError(divID);	
	hideAllParentDivs();
}

function showDiv(grandParentDivID, parentDivID, childDivID){
	hideAllDivs();
	showError(grandParentDivID)
	showError(parentDivID)
	showError(childDivID)
}	 
	 
function showAllGandParentDivs(){
	showError("acp");
	showError("accaCat");
	showError("othm");
	showError("abe");
	showError("abp");
	showError("english");
}

function hideAllGandParentDivs(){
	hideError("acp");
	hideError("accaCat");
	hideError("othm");
	hideError("abe");
	hideError("abp");
	hideError("english");
}

function toogleLayerParent(divID){
	hideAllParentDivs();
	showError(divID);
}

function hideAllParentDivs(){	
	hideError("acpCertificate");
	hideError("acpDiploma");
	hideError("acpAdvancedDiploma");
	
	hideError("pgd");
	hideError("dbm");
	hideError("adbm");
	
	hideError("acca");		
	//hideError("othmIntroductoryCertificate");
	hideError("othmProfessionalCertificate");
	hideError("othmProfessionalDiploma");
	hideError("othmProfessionalHigherDiploma");	
	hideAllChildDivs();
}

function toogleLayerChild(divID){
	hideAllChildDivs();
	showError(divID);
}

function hideAllChildDivs(){		
	hideError("acpCertificateITF");
	hideError("acpCertificateCAO");
	hideError("acpCertificateAP");
	hideError("acpDiplomaSAD");
	hideError("acpDiplomaSE");
	hideError("acpDiplomaBIS");
	hideError("acpCertificateITF");
	hideError("acpCertificateITF");
	hideError("acpCertificateITF");
	hideError("acpCertificateITF");
	hideError("acpCertificateITF");
	hideError("acpAdvancedDiplomaISM");
	hideError("acpAdvancedDiplomaISADP");
	hideError("acpAdvancedDiplomaISPN");	
}

var noticeVal = 1;
function noticeShowHide(noticeID){
	noticeVal = noticeVal + 1;
	if(noticeVal==3){
		invisibleDiv(noticeID);
	}else{
		visibleDiv(noticeID);	
	}
	var methodName = "noticeShowHide('"+noticeID+"')";
	if(noticeVal==6)
		noticeVal = 1;
	setTimeout(methodName,1300);
}

var newsVal = 1;
function newsShowHide(newsID){
	newsVal = newsVal + 1;
	if(newsVal==3){
		invisibleDiv(newsID);
	}else{
		visibleDiv(newsID);	
	}
	var methodName = "newsShowHide('"+newsID+"')";
	if(newsVal==15)
		newsVal = 1;
	setTimeout(methodName,250);
}

function visibleDiv(divID){
	document.getElementById(divID).style.visibility="visible";
}

function invisibleDiv(divID){
	document.getElementById(divID).style.visibility="hidden";
}

var studentId = 0;

	
function showTestimonial(){	 
	var fileName = "/includes/xml/testimonial.xml";	
	var xmlDoc;
	//for IE
	
	if (window.ActiveXObject){	
		var xmlDoc=new ActiveXObject("MSXML.DOMDocument");
		xmlDoc.async="false";
		xmlDoc.load(fileName);	  
		var students=xmlDoc.getElementsByTagName("student");	 	 	 
	}
	//for FF
	else if (document.implementation && document.implementation.createDocument){
		xmlDoc = document.implementation.createDocument("","",null);
		xmlDoc.load(fileName);
		var students=xmlDoc.getElementsByTagName("student");	 	 	 
		
	}
	
	if(studentId ==  0){
		return false;
	}
	
	 //alert(studentId);
	 var studentName = students[studentId].getElementsByTagName("studentname")[0].childNodes[0].nodeValue;	 	 
	 var studentCountry = students[studentId].getElementsByTagName("country")[0].childNodes[0].nodeValue;	 
	 var studentImage = students[studentId].getElementsByTagName("image")[0].childNodes[0].nodeValue;	 	 
	 var studentCourse = students[studentId].getElementsByTagName("course")[0].childNodes[0].nodeValue;	 	 
	 var studentMessage = students[studentId].getElementsByTagName("testimonial")[0].childNodes[0].nodeValue;	 

	 //alert(studentName);
	 document.getElementById("student_name").innerHTML = studentName;
	 document.getElementById("student_country").innerHTML = studentCountry;
	 document.getElementById("student_course").innerHTML = studentCourse;
	 document.getElementById("student_image").src= studentImage;
	 document.getElementById("student_message").innerHTML = studentMessage;	 
	 
	 studentId = studentId + 1;
	 if(studentId==3)
		studentId = 0;
	
	var test = setTimeout('showTestimonial();',5000); 	    			
	//studentId = 0;
	
	 
}




