



function submitForm(formId) {
	document.getElementById(formId).submit();
	return true;
} 


function searchActivities(formId) {
	var formObj = document.getElementById(formId);
	formObj.isFormSubmit.value='true';
	submitForm(formId);
} 
	
	
function reportAbuse(commentId){
	
	document.getElementById("abuseForm").commentId.value=commentId;
	document.getElementById("abuseForm").submit();
	return true;
}

function showNextDiv(currDiv){
		var linkObj = document.getElementById("pageSize").getElementsByTagName('a')[0];
		var divObj = document.getElementById('pageDiv'+currDiv);
		var nextDiv = parseFloat(currDiv) + 1;
		var divAfterNext  = parseFloat(currDiv) + 2;
		linkObj.onclick = function() {
				showNextDiv(nextDiv+'.0');
		}
		var nextDivObj = document.getElementById('pageDiv'+nextDiv+'.0');
		nextDivObj.style.display="block";
		var divAfterNextObj = document.getElementById('pageDiv'+divAfterNext+'.0');
		if (!divAfterNextObj) {
			document.getElementById('nextLink').style.display="none";
		}
}


function showDiv(id) {
	document.getElementById(id).style.display="block";
	document.getElementById("button").style.display="none";
}

/*
*****************  Star Rating Start ***********************
*/
var sMax;	// Isthe maximum number of stars
var holder; // Is the holding pattern for clicked state
var preSet; // Is the PreSet value onces a selection has been made
var rated;
var currentRating = 0; // Is the initial Rating that is set for the contentItem

// Rollover for image Stars //
function rating(num){
	sMax = 0;	// Isthe maximum number of stars
	for(n=0; n<num.parentNode.childNodes.length; n++){
		if(num.parentNode.childNodes[n].nodeName == "A"){
			sMax++;	
		}
	}
	
	if(!rated){
		s = num.id.replace("_", ''); // Get the selected star
		a = 0;
		for(i=1; i<=sMax; i++){		
			if(i<=s){
				document.getElementById("_"+i).className = "on";
				document.getElementById("rateStatus").innerHTML = num.title;	
				holder = a+1;
				a++;
			}else{
				document.getElementById("_"+i).className = "";
			}
		}
	}
}

// For when you roll out of the the whole thing //
function off(me){
	if(!rated){
		if(!preSet){	
			for(i=1; i<=sMax; i++){		
				document.getElementById("_"+i).className = "";
				document.getElementById("rateStatus").innerHTML = me.parentNode.title;
			}
		}else{
			rating(preSet);
			document.getElementById("rateStatus").innerHTML = document.getElementById("ratingState").innerHTML;
		}
		setStarRatingForContentItem(currentRating);
	}
	
}

// When you actually rate something //
function rateIt(me){
	if(!rated){
		document.getElementById("ratingState").innerHTML = "Your Rating &nbsp;";
		document.getElementById("rateStatus").style.display="none";
		preSet = me;
		rated=1;
		sendRate(me);
		rating(me);
	}
}

// Send the rating information somewhere using Ajax.
function sendRate(selId){
	document.forms['voteForm'].contentRating.value = selId.id.substring(1);
	var formData = getFormData('voteForm');
	// encode for Spry
 	formData = encodeURI(formData);
	//	var req = Spry.Utils.loadURL("POST", "/nl_BE/insertContent", true);
	Spry.Utils.loadURL('POST',"/nl_BE/insertContent", true,resFunc,{postData: formData,headers:{"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"}});
}

function resFunc(request) {
   var result = request.xhRequest.responseText; 
   document.getElementById("totalVotes").innerHTML ="&nbsp;"+result+ " votes";
}

function setStarRatingForContentItem(contentRating) {
	var ratingNode = document.getElementById('contentRating');
	var currentCount = 0;
	for(n=0; n<ratingNode.childNodes.length; n++){
		if(ratingNode.childNodes[n].nodeName == "A"){
			if (currentCount < contentRating) {
				ratingNode.childNodes[n].className = "on";
				currentCount++;	
			}
		}
	currentRating = contentRating; // Keeping the Rating of the contentItem in a global variable
	}
}	

function sortActivites() {
	var formData = getFormData('sortForm');
	// encode for Spry
 	formData = encodeURI(formData);
	Spry.Utils.loadURL('POST',"/nl_BE/activities",true,displayResponse,{postData: formData,headers:{"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"}});
}

function displayPage(pageNum) {
	document.forms['pagingForm'].pageNum.value = pageNum;
	var formData = getFormData('pagingForm');
	// encode for Spry
 	formData = encodeURI(formData);
	Spry.Utils.loadURL('POST',"/nl_BE/activities",true,displayResponse,{postData: formData,headers:{"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"}});
}

function displayResponse(request) {
   var result = request.xhRequest.responseText; 
   document.getElementById("activityItemsDiv").innerHTML = result;
}

function getFormData(formId) {
	var formData = "";
	//Get the form values
 	formElements=document.forms[formId].elements;
 	//loop through the array , building up the formData
 	for ( var i=formElements.length-1; i>=0; --i ){
 		//we escape each value
 		formData= formData + escape(formElements[i].name)+"="+escape(formElements[i].value)+"&";
 	}
 	formData = formData.substring(0,formData.length-1);
 	return formData;
} 
/*
********************************* Star Rating End ************************************
*/

function authorPopUp(authorId){
	window.open('/nl_BE/parenting-expertBio/authorId/'+authorId,'PopUp','width=600,height=600,toolbar=no,scrollbars=yes');
}

function wopenprofile(url, name, w, h) {
  wleft = (screen.width - w) / 2;
  wtop = (screen.height - h) / 2;
  if (wleft < 0) {
    w = screen.width;
    wleft = 0;
  }
  if (wtop < 0) {
    h = screen.height;
    wtop = 0;
  }
  var win = window.open(url,name,'width=' + w + ', height=' + h + ', ' +
    'left=' + wleft + ', top=' + wtop + ',location=no, menubar=no, ' +
    'status=no, toolbar=no, scrollbars=yes, resizable=no');
  win.resizeTo(w, h);
  win.moveTo(wleft, wtop);
  win.focus();
  
}



