var xmlHttp, xmlHttp1
var titleY
var titleX
var userComment


function emailPageSave(){
alert(0);
	toEmails1 = document.getElementById('toEmails');
	userMsg1 = document.getElementById('userMsg');
	userEmail1 = document.getElementById('userEmail');
	sendLink1 = document.getElementById('sendLink');
	if (validEmail(userEmail1.value)||((userEmail1.value)==null)||((userEmail1.value)=="")) {
		xmlUrl="?unit=user&task=emailPageSave&output=xml&country=nz";
		//alert(xmlUrl);
		postString = '<xml>'+
			'<toEmails>'+escape(toEmails1.value)+'</toEmails>'+
			'<userMsg>'+userMsg1.value+'</userMsg>'+
			'<sendLink>'+escape(window.location.href)+'</sendLink>'+
			'<userEmail>'+userEmail1.value+'</userEmail>'+
			'</xml>';
		//alert(postString);
		//alert(window.location.href);
		dummy = runXML(xmlUrl, postString)
		commentFormClose();
		//alert(dummy);
	}else{
		alert("Invalid Sender email");
	}
}

function emailPage(){
	coverPage();
	xmlUrl="?unit=user&task=emailPage&output=xml&country=nz";
	postString = null;
	elementBox = document.getElementById('commentBox');
	document.getElementById('commentBox').innerHTML = runXML(xmlUrl, postString);
	elementBox.style.display='block';
	tempHeight = document.getElementById('commentBox').offsetHeight;
	tempWidth = document.getElementById('commentBox').offsetWidth;
	elementBox.style.top=(f_clientHeight()-tempHeight)/2+f_scrollTop()+"px";
	elementBox.style.left=(f_clientWidth()-tempWidth)/2+f_scrollLeft()+"px";
}


function switchAdminMode(){
	//alert('chalaka');
	xmlUrl="?unit=admtools&task=adminMode&output=xml&country=nz";
	postString = '<xml><adId>null</adId></xml>';
	runXML(xmlUrl, postString);
	window.location.reload();
	}

function AdClickAction(adId){
	xmlUrl="?unit=ads&task=recordClick&output=xml&country=nz";
	postString = '<xml><adId>'+adId+'</adId></xml>'
	destination = runXML(xmlUrl, postString);
	//alert(destination);
	window.location = destination;
	}


function newUserSave()	{
	var dialogTitle = "Chalaka&nbsp;Salpadoru";
	var dialogMsg = "Your email address is already in our database. Please select an option below";
	var myCars=new Array();
		myCars[0]="Email password";
		myCars[1]="emailPassword()";
		myCars[2]="Back to register";
		myCars[3]="backToRegister()";
//	alert (document.getElementById('emailAddress').value);
	if (validateUser()) {
		url="?unit=user&task=save&output=xml";
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return
		}
		xmlHttp.open("POST",url,false)
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		alert (document.getElementById('emailAddress').value);
		sendString = "output=xml&emailAddress="+document.getElementById('emailAddress').value+"&mainPassword="+document.getElementById('mainPassword').value;
		xmlHttp.send(sendString)
		if (xmlHttp.responseText == "exists") {
			showDialogBox(dialogTitle, dialogMsg, myCars);
		}else{
			var myCars1=new Array();
			dialogTitle = "Your registration was accepted";
			dialogMsg = "Thank you for registering with CharliesResearch.com. We processed your application and sent you an email for activating your account. PLease click on the ";
			//."given web address for activation. If you have enabled spam filtering and did not "."receive the email please check your spam folders";
			myCars1[0]="Ok";
			myCars1[1]="goToHome()";
			showDialogBox(dialogTitle, dialogMsg, myCars1);
		}
	}
}


function validateUser(){
	emailAdd = document.getElementById('emailAddress').value;
	confirmAdd = document.getElementById('confirmEmail').value;
	mainPass = document.getElementById('mainPassword').value;
	confirmPass = document.getElementById('confirmPassword').value;
	if (!(validEmail(emailAdd))||!(validEmail(confirmAdd))){
		alert("Invalid email address");
		return false
	}
	if (emailAdd!=confirmAdd) {
		alert("Email addresses do not match");
		return false
	}
	if (((mainPass.length)<4)||((mainPass.length)<4)){
		alert("Invalid password");
		return false
	}
	if (mainPass!=confirmPass) {
		alert("Passwords do not match");
		return false
	}
	return true
}



function validEmail(str) {
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   return false
		}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		}
		if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }
		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }
		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }
		 if (str.indexOf(" ")!=-1){
		    return false
		 }
 		 return true
	}


function newCommentSave(){
	if ((((document.getElementById("fieldTitle").value) != ("type or select as you type"))&&
	((document.getElementById("fieldComment").value)!=("write feedback here, minimum 100 characters..")))&&
	((validEmail(document.getElementById("userEmailX").value))||(document.getElementById("userEmailX").value.length==0))){
//	if ((((document.getElementById("fieldTitle").value) != ("type new name or select name as you type"))&&
//	((document.getElementById("fieldComment").value)!=("write feedback here..")))&&
//	((validEmail(document.getElementById("userEmailX").value))||(document.getElementById("userEmailX").value.length==0))){
		if (document.getElementById("fieldComment").value.length>99) {
			titleX = document.getElementById("fieldTitle");
			yourEmail = document.getElementById("userEmailX");
			titleY = document.getElementsByName("pizzasize");
			rating = sayradio(document.getElementsByName("pizzasize"))
			titleY = document.getElementsByName("pizzasize");
			relationship = document.getElementById("fieldConnection");
			userComment = document.getElementById("fieldComment");
			var donkey
			var url=""
			url="?unit=ajax&country=nz&raceId="+document.getElementById("raceId").value;
			xmlHttp=GetXmlHttpObject()
			if (xmlHttp==null)
			{
				alert ("Browser does not support HTTP Request")
				return
			}
			xmlHttp.open("POST",url,false)
			xmlHttp.onreadystatechange=stateChanged1
			xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			//sendString = "x="+titleX.value+"&userComment="+userComment.value+"&rating="+rating+"&relationship="+relationship.value+"&industry="+document.getElementById("fieldIndustry").value+"&entity="+document.getElementById("fieldEntity").value+"&yourEmail="+yourEmail.value;
			sendString = "x="+titleX.value+"&userComment="+userComment.value+"&rating="+rating+"&relationship="+relationship.value+"&industry="+"&entity="+"&yourEmail="+yourEmail.value;
			//alert(sendString);
			xmlHttp.send(sendString)
			//alert (xmlHttp.responseText);
			var myCars=new Array();
			myCars[0]="ok";
			myCars[1]="hideDialogBox()";
			commentFormClose();
			showDialogBox('Your comment saved', 'Your comment has been saved, please click ok to continue', myCars);

		}else{
			tempNum = 100 - document.getElementById("fieldComment").value.length;
			alert("Your comment must be more than 100 characters. Please add another "+tempNum+" characters.")
		}
	}else{
		alert("Name and Feedback must be updated or email address must be corrected or left blank")
	}
}



function stateChanged1()
{
	response = xmlHttp.responseXML;
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
//		alert (xmlHttp.responseText);
		newCommentClear("reset");
	}
}



function sayradio(x)
{
	var x
	if (x.length==1) {
		return x[0].value
	} else {
	for (j=0;j<x.length;j++)
	{
		if (x[j].checked)
		{
			return x[j].value
        }
    }
    }
}



function GetXmlHttpObject()
{
	var xmlHttp=null;
  	try
    {
    	// Firefox, Opera 8.0+, Safari
    	xmlHttp=new XMLHttpRequest();
    }
  	catch (e)
    {
    // Internet Explorer
    try
      {
      	xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    	catch (e)
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
	}
	return xmlHttp;
}


var delay='1';
 function showForm(x) {

  oDiv1 = document.getElementById('theFormCover');
  oDiv1.style.display='block';
  oDiv1.style.top=0;
  oDiv1.style.height=document.body.clientHeight;
  oDiv1.style.left=0;
  oDiv1.style.width=document.body.clientWidth;




 if (x==null) {
  oDiv = document.getElementById('theFormDiv');
  oDiv.style.display='block';
//  alert(document.body.clientHeight);
//  alert(oDiv.style.height);
//  alert(oDiv.style.height);
  oDiv.style.top=document.body.clientHeight/2 - 200/2;
  oDiv.style.left=(document.body.clientWidth/2)- 468/2;
  theFormCover.style
//document.body.style.backgroundColor='gray';
	}

  return false;
}

function hideForm() {
  oDiv = document.getElementById('theFormDiv');
  oDiv.style.display='none';
  oDiv1 = document.getElementById('theFormCover');
  oDiv1.style.display='none';
  return false;
}



function newCommentClear(currentField){
	if (currentField=="reset") {
		fieldTitle.value="type or select as you type";
		fieldIndustry.value="select industry here";
		fieldComment.value="write feedback here, minimum 100 characters..";
		fieldEntity.value="select type";
		fieldConnection.value="your connection";
	}else{
	switch(currentField.value){
		case "type or select as you type":
			currentField.value='';
			break;
		case "select industry here":
			currentField.value='';
			break;
		case "write feedback here, minimum 100 characters..":
			currentField.value='';
			break;
		default:
			//ss;write feedback here, minimum 75 characters..
	} // switch
	}
}



/**
 *
 * @access public
 * @return void
 **/
function brandCheck(brand){
	//alert(brand);
	xmlHttp1=GetXmlHttpObject()
	//url="?unit=ajax&brand="+brand+"&rows=11";
	tempBrand = document.getElementById('fieldTitle').value
	//url="./include/unit_xml.php?unit=xml&brand="+str+"&rows="+rows+"&source="+menuSrc+"&country=NZ"
	url="./include/unit_xml.php?&brand="+tempBrand+"&rows=1&source=brand&country=NZ";
	//alert(url);
	xmlHttp1.open("POST",url,true)
	xmlHttp1.onreadystatechange=stateChanged2
	xmlHttp1.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp1.send(null)
//	document.getElementById(menuDivGlobal).innerHTML="";
//	alert (xmlHttp1.responseText);
//	alert ("ok");
}


function stateChanged2()
{
	response = xmlHttp1.responseXML;
	if (xmlHttp1.readyState==4 || xmlHttp1.readyState=="complete")
	{
//		alert ("ok1");
//		alert (xmlHttp1.responseText);
//		alert(response.getElementsByTagName("name").length)
		if (response.getElementsByTagName("name").length==0)
		{
			document.getElementById('fieldIndustry').disabled=false;
			document.getElementById('fieldEntity').disabled=false;
//			alert("enabled");
		}else{
			document.getElementById('fieldIndustry').disabled=true
			document.getElementById('fieldEntity').disabled=true
//			alert("disabled");
		}
	}
}

/**
 *
 * @access public
 * @return void
 **/
function subscribeAlert(){
	reqXML="emailAdd="+emailAddress.value+"&freqAlert="+alertFreq.value+"&alertRegion="+alertRegion.value
	callXML("?unit=subs&output=xml&task=add", reqXML)
	showForm();
}

function callXML(reqURL, reqXML){
//	alert(reqXML)
//	alert(reqURL)
	xmlHttpCI=GetXmlHttpObject()
	if (xmlHttpCI==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	xmlHttpCI.open("POST",reqURL,false)
	xmlHttpCI.onreadystatechange=stateChanged5
	xmlHttpCI.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttpCI.send(reqXML)
//	alert (xmlHttpCI.responseText);
}

/**
 *
 * @access public
 * @return void
 **/
function stateChanged5(){
//	alert('something happened')
}

function getParagraph(x)
{
	return "This is it";
}

function showDialogHelp(helpText, inElement) {
	//alert(winTitle);
	//	alert (document.body.scrollTop)
		htmlString = helpText;
  		elementCover = document.getElementById('dialogHelp');
  		elementCover.style.display='block';
  		elementCover.style.top=f_scrollTop()+60+"px";
 		elementCover.style.left=f_scrollLeft()+30+"px";
		document.getElementById('dialogHelp').innerHTML = "<div class='notice'>"+htmlString+"</div>";
		window.setTimeout('hideDialogHelp()',10000);
	}

function hideDialogHelp() {
		elementBox = document.getElementById('dialogHelp');
		elementBox.style.display='none';
}

function showContactBox() {

	//$('form#contactForm').show();
	//alert ('chalaka');
	$(function() {
		// load the modal window
		//$('a.modal').click(function(){
		$('document').ready(function(){
			// scroll to top
			//$('html, body').animate({scrollTop:0}, 'fast');
			// before showing the modal window, reset the form incase of previous use.
			//$('form#contactForm').show();
		 	/*
			// Reset all the default values in the form fields
			$('#name').val('Your name');
			$('#email').val('Your email address');
			$('#comment').val('Enter your comment here...');
 			*/
			//show the mask and contact divs
			//$('div#contact').fadeIn();
			$('#mask').show();
			//$('#mask').fadeTo('', 0.7).show();
			$('div#contact').show();
			// stop the modal link from doing its default action
			return false;
		});
		// close the modal window if close div are clicked.
		$('div#close, div#stdButton').click(function() {
		//$('div#close, div#mask').click(function() {
			//$('div#contact, div#mask').stop().fadeOut('slow');
			$('div#contact').hide();
			$('div#mask').hide();
			//$('div#mask').stop().fadeOut('slow');
		});
  		/*
		$('#contactForm input').focus(function() {
		$(this).val(' ');
		});
 		*/
	});

	}

/**
 *
 * @access public
 * @return void
 **/
function sendContact(){
		xmlHttp=GetXmlHttpObject()
		url="?unit=admtools&task=contact&output=xml";
		xmlHttp.open("POST",url,false)
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		//alert(fieldMessage.value);
		sendString = "output=xml&contactType=Chalaka&contactMsg="+document.getElementById('fieldMessage').value;
		xmlHttp.send(sendString)
		document.getElementById('contactBox').style.display='none';
		document.getElementById('contactCover').style.display='none';
//		alert(xmlHttp.responseText);
}

function hideContactBox() {
		elementBox = document.getElementById('contactCover');
		elementBox.style.display='none';
  		elementCover = document.getElementById('contactBox');
		elementCover.style.display='none';
	}

function showDialogBox(winTitle, winMsg, winOptions) {
		htmlString = '<DIV class=ciWindowsTitle style="FLOAT: left; WIDTH: 100%; POSITION: relative"><DIV style="FLOAT: left;">'+winTitle+'</DIV>';
		htmlString = htmlString + '<div style="FLOAT: right; WIDTH: 17px;TEXT-ALIGN: left;"><span onclick=hideDialogBox()>X</span></DIV>'+'</DIV>';
		htmlString = htmlString + '<div class=dialogMsg>'+winMsg+'</div>';
		htmlString = htmlString + '<div style="text-align:center">'
		for (j=0;j<winOptions.length/2; j++) {
			htmlString = htmlString + '<div onclick="'+winOptions[(j*2)+1]+'" class=dialogLinks style="left: '+(((465-(125*(winOptions.length/2)))/((winOptions.length/2)+1))*(j+1))+'px;">'+winOptions[j*2]+'</DIV>';
		}
		htmlString = htmlString + '<br><br><img src=ads/sayit.gif>';
		//alert(htmlString)
		elementBox = document.getElementById('dialogCover');
		elementBox.style.display='block';
  		elementBox.style.top=0+"px";
  		elementBox.style.left=0+"px";
		elementBox.style.height=f_offsetHeight()+"px";
  		elementBox.style.width=f_offsetWidth()+"px";
//  		alert(window.offsetHeight);
//		alert(document.body.offsetHeight);
//  		alert(elementBox.style.height);
//  		alert(elementBox.style.height);
  		elementCover = document.getElementById('dialogBox');
  		elementCover.style.display='block';
  		elementCover.style.top=(f_clientHeight()-150)/2+f_scrollTop()+"px";
  		elementCover.style.left=(f_clientWidth()-468)/2+f_scrollLeft()+"px";
//  		elementCover.style.top=(document.body.clientHeight/2) - (200/2) +document.body.scrollTop;
//  		elementCover.style.left=(document.body.clientWidth/2)- (468/2) + document.body.scrollLeft;
		document.getElementById('dialogBox').innerHTML = htmlString;
	}


	function hideDialogBox() {
		elementBox = document.getElementById('dialogCover');
		elementBox.style.display='none';
  		elementCover = document.getElementById('dialogBox');
		elementCover.style.display='none';
	}





/**
 *
 * @access public
 * @return void
 **/
function goToLogin(){
//	hideDialogBox();
	window.location = ".?unit=user&task=login"

}

/**
 *
 * @access public
 * @return void
 **/
function goToHome(){
//	hideDialogBox();
//	window.location = "."
	window.location.reload();
}

function userLogout(){
	url="?unit=user&task=userLogout&output=xml";
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	xmlHttp.open("POST",url,false)
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	sendString = "";
	xmlHttp.send(sendString)
	//alert(url);
	//alert ("X"+xmlHttp.responseText+"X");
	goToHome();
}

function userLogin(){
	url="?unit=user&task=userLogin&output=xml&country=nz";
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	xmlHttp.open("POST",url,false)
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	//alert(document.getElementById('logOnEmailAdd').value);
	sendString = "id="+document.getElementById('logOnEmailAdd').value+"&pw="+document.getElementById('passWd').value+"&rm="+document.getElementById('rememberPW').checked;
	//alert(sendString);
	xmlHttp.send(sendString)
	//alert(xmlHttp.responseText);
	if (xmlHttp.responseText=='False'){
		var myCars2=new Array();
		dialogTitle = "Login attempt failed";
		dialogMsg = "PLease try again for registerPLease try again for registerPLease try again for registerPLease try again for register";
		myCars2[0]="Ok";
		showDialogBox(dialogTitle, dialogMsg, myCars2);
	}else{
		goToHome();
	}
	//alert ("X"+xmlHttp.responseText+"X");
}

function paraSave(){
	url="?unit=admtools&task=paraSave&output=xml";
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	xmlHttp.open("POST",url,false)
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	sendString = null;
	xmlSend = "paraValue="+escape(document.getElementById("paraValue").value)+"&paraNum="+document.getElementById("paraNum").value
	xmlHttp.send(xmlSend)
	//alert(xmlHttp.responseText);
	alert("Saved");
}


function notReleased() {
	var myCars=new Array();
	myCars[0]="ok";
	myCars[1]="hideDialogBox()";
	showDialogBox("These features are to be released shortly", "These features are to be released shortly", myCars);
  }
function f_offsetWidth() {
	return f_filterResults (
		window.offsetWidth ? window.offsetWidth : 0,
		document.documentElement ? document.documentElement.scrollWidth : 0,
		document.body ? document.body.offsetWidth : 0
	);
}
function f_offsetHeight() {
	return f_filterResults (
		window.offsetHeight ? window.offsetHeight : 0,
		document.documentElement ? document.documentElement.scrollHeight : 0,
		document.body ? document.body.offsetHeight : 0
	);
}
function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}
function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}
function f_scrollLeft() {
	return f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}
function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}
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 runXML(xmlUrl, postString){
	url=xmlUrl;
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	xmlHttp.open("POST",url,false)
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	sendString = postString;
//	alert (sendString);
	sendString = escape(sendString);
	xmlHttp.send('xmlString='+sendString)
//	alert (sendString);
	return xmlHttp.responseText;
}

function callCommentForm(formTitle, refId){
	scoreDivMsg = getElementsByName_iefix('div','scoreDivMsg');
 	scoreDiv = getElementsByName_iefix('div','scoreDiv');
 	//scoreDivMsg[1].style.display='none';

// 	xmlUrl="?unit=races&task=justVote&output=xml&country=nz";
//	postString = '<xml>'+
//		'<formTitle>'+formTitle+'</formTitle>'+
//		'<raceId>'+refId+'</raceId>'+
//		'</xml>';
//	runXMLoutput = runXML(xmlUrl, postString)
    commentForm(formTitle, refId, 'raceCandidate');
 	for (j=0;j<scoreDivMsg.length;j++)
	{
		scoreDivMsg[j].style.display='none';
		scoreDiv[j].style.display='block';
    }

}


function commentForm(formTitle, refId, formOption){
	coverPage()
	/*elementCover = document.getElementById('commentCover');
	elementCover.style.display='block';
	elementCover.style.top=0+"px";
	elementCover.style.left=0+"px";
	elementCover.style.height=f_offsetHeight()+"px";
	elementCover.style.width=f_offsetWidth()+"px"; */

	xmlUrl="?unit=comments&task=ajaxForm&output=xml&country=nz";
	postString = '<xml>'+
		'<formTitle>'+formTitle+'</formTitle>'+
		'<formType>'+formOption+'</formType>'+
		'<refId>'+refId+'</refId>'+
		'</xml>'
//	alert(postString)
	elementBox = document.getElementById('commentBox');
	document.getElementById('commentBox').innerHTML = runXML(xmlUrl, postString);
	elementBox.style.display='block';
	tempHeight = document.getElementById('commentBox').offsetHeight;
	tempWidth = document.getElementById('commentBox').offsetWidth;
	elementBox.style.top=(f_clientHeight()-tempHeight)/2+f_scrollTop()+"px";
	elementBox.style.left=(f_clientWidth()-tempWidth)/2+f_scrollLeft()+"px";

}

function commentFormClose(){
	elementCover = document.getElementById('commentCover');
	elementCover.style.display='none';
	elementBox = document.getElementById('commentBox');
	elementBox.style.display='none';
	elementBox = document.getElementById('dialogHelp');
	elementBox.style.display='none';
	mainAd = document.getElementById('mainAd01');
	mainAd.style.display='block';
}

 // this is used cos getElementsByName is buggy on IE
 function getElementsByName_iefix(tag, name) {

     var elem = document.getElementsByTagName(tag);
     var arr = new Array();
     for(i = 0,iarr = 0; i < elem.length; i++) {
          att = elem[i].getAttribute("name");
          if(att == name) {
               arr[iarr] = elem[i];
               iarr++;
          }
     }
     return arr;
}

function coverPage(){
	elementCover = document.getElementById('commentCover');
	mainAd = document.getElementById('mainAd01');
	elementCover.style.display='block';
	mainAd.style.display='none';
	elementCover.style.top=0+"px";
	elementCover.style.left=0+"px";
	elementCover.style.height=f_offsetHeight()+"px";
	elementCover.style.width=f_offsetWidth()+"px";
}


function textCounter() {
	//alert("chalaka");
	document.getElementById('TxtCntr').innerHTML = document.getElementById("fieldComment").value.length;
	//document.all.TxtCntr.innerHTML = "A very cool site!";
	//if (field.value.length > maxlimit) // if too long...trim it!
	//field.value = field.value.substring(0, maxlimit);
	// otherwise, update 'characters left' counter
	//else
	//cntfield.value = maxlimit - field.value.length;
}


