// JavaScripts

function Image_Swap(id, image){
	document.getElementById(id).src = "images/" + image;
}

function Increase_Points(points){
	alert(points);
}

function Open_Article(article){
	window.open(article, 'Article', 'toolbars=0, width=725, height=545, top=100, left=100, scrollbars=yes');
}

function Close_Window(){
	window.close();
}

function Authenticate(){
	var un = document.getElementById('txtEmail').value;
	var pwd = document.getElementById('txtPassword').value;
	
	if((un.length == 0) || (pwd.length == 0)){
		alert("Please note that both the Username and Password fields are compulsory.");
		return false;
	}else{
		return true;
	}
}

function Update_Profile(){
	var fn = document.getElementById('txtFName').value;
	var ln = document.getElementById('txtLName').value;
	var mail = document.getElementById('txtEmail').value;
	var course = document.getElementById('txtCourse').value;
	var password = document.getElementById('txtPassword').value;
	
	var is = false;
	
	if((fn.length == 0) || (ln.length == 0) || (mail.length == 0) || (course.length == 0) || (password.length == 0)){
		alert("Please note that all fields marked with a * sign is compulsory.");
		is = false;
	}else{
		// check mail.
		if ((mail.indexOf('@') < 0) || ((mail.charAt(mail.length-4) != '.') && (mail.charAt(mail.length-3) != '.'))){
		  	alert('Please enter a valid Email address.');
			is = false;
		}else{
			is = true;
		}
	}
	
	return is;
}

function Fill_Years(){
	var current_year = new Date();
    current_year = current_year.getFullYear();
	for(i = current_year; i >= 1981; i--){
    	var oOption = document.createElement('OPTION');
	    oOption.value=i;
	    oOption.innerHTML=i;
	    document.getElementById('ddlYearFrom').appendChild(oOption);
		
		var oOption2 = document.createElement('OPTION');
	    oOption2.value=i;
	    oOption2.innerHTML=i;
	    document.getElementById('ddlYearTo').appendChild(oOption2);
   	}  
}