// JavaScript Document

function loadSection(id) 
{

	obj = document.getElementById(id);

	document.getElementById('mostread_a').className = "";
	document.getElementById('mostemailed_a').className = "";
	document.getElementById('recentcomment_a').className = "";

	document.getElementById(id+'_a').className = "sel";
	document.getElementById("articlefeatures").innerHTML = obj.innerHTML;

	//document.getElementById("articlefeatures").innerHTML = id;
}

function subscribeNL()

{

	checked='';

	for(i=1;i<=5;i++) {

		if (document.getElementById("NL"+i).checked)

			checked = checked + document.getElementById("NL"+i).value + '|';

	}

	email = document.getElementById("email").value;

	if (email != '' && checked != '') {

		url = '/include/insertNL.php?param='+email + "|" + checked;
		//alert(url);
		//insertNLUser(url);
		do_ajaxRequest_bc(url,'placeholderdiv');

	} else {

		alert('Please Enter Email address OR select at least one Newsletter group');

	}

}

function showArticleDetail(id) 
{
	d=document.getElementById(id);
	if(d.style.display=='none')
	{ 
		d.style.display='';  
	} else { 
		d.style.display='none'; 
	}
}

function nextPage()
{
	
	btn = document.getElementById("next");
	if (btn.value == 'Next Page') {
		btn.value='Previous Page';
		document.getElementById("tar").innerHTML = document.getElementById("sp").innerHTML;
		document.getElementById("nextpagetext").innerHTML ='';
	} else {
		btn.value='Next Page';
		document.getElementById("tar").innerHTML = document.getElementById("fp").innerHTML;
		document.getElementById("nextpagetext").innerHTML ='Continued on page 2...';
	}
	uri = window.location.href;
	if (uri.substr(-4) == '#tar')
		window.location.href=window.location.href;
	else
		window.location.href=window.location.href+'#tar';
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}

var speed=Math.round(15);

function showConfirmation(msg)
{
	scrolled = f_scrollTop();
	timer =0;
	msgDiv = document.getElementById("confirmationMessage");
	msgDiv.innerHTML = msg;
	msgDiv.style.top  = ( ( (screen.height /2) -100) + scrolled ) + 'px';
	msgDiv.style.left = ( ( (screen.width)/2) - 250) + 'px';
	msgDiv.style.display = 'block';
	
	for(i = 1; i <= 100; i++) {
        setTimeout("changeOpac(" + i + ",'confirmationMessage')",(timer * speed));
        timer++;
    }
	setTimeout('hideConfirmation()',2500);
}

function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}



function hideConfirmation()
{
	timer =0;
	for(i = 100; i > 0; i--) {
        setTimeout("changeOpac(" + i + ",'confirmationMessage')",(timer * speed));
        timer++;
    }
	
	//document.getElementById("confirmationMessage").style.display='none';
	
}


function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

function validateReviewSubmit()
{
	name 	= document.getElementById("rname").value;
	review 	= document.getElementById("rreview").value;
	
	if (name == '' || review == '') {
		showConfirmation('Please enter your Name and Review');
		return false;
	}
	
	return true;
	
}