function bgChange(){
document.getElementById('x1').style.background="url(/gfx/nameback.gif)"
document.getElementById('x2').style.background="url(/gfx/passback.gif)"
}


function createBBtag( openerTag , closerTag , areaId ) {
  if(isIE && isWin) {
    createBBtag_IE( openerTag , closerTag , areaId );
  }
  else {
    createBBtag_nav( openerTag , closerTag , areaId );
  }
  return;
}

function createBBtag_IE( openerTag , closerTag , areaId ) {
  var txtArea = document.getElementById( areaId );
  var aSelection = document.selection.createRange().text;
  var range = txtArea.createTextRange();

  if(aSelection) {
    document.selection.createRange().text = openerTag + aSelection + closerTag;
    txtArea.focus();
    range.move('textedit');
    range.select();
  }
  else {
    var oldStringLength = range.text.length + openerTag.length;
    txtArea.value += openerTag + closerTag;
    txtArea.focus();
    range.move('character',oldStringLength);
    range.collapse(false);
    range.select();
  }
  return;
}

function createBBtag_nav( openerTag , closerTag , areaId ) {
  var txtArea = document.getElementById( areaId );
  if (txtArea.selectionEnd && (txtArea.selectionEnd - txtArea.selectionStart > 0) ) {
    var preString = (txtArea.value).substring(0,txtArea.selectionStart);
    var newString = openerTag + (txtArea.value).substring(txtArea.selectionStart,txtArea.selectionEnd) + closerTag;
    var postString = (txtArea.value).substring(txtArea.selectionEnd);
    txtArea.value = preString + newString + postString;
    txtArea.focus();
  }
  else {
    var offset = txtArea.selectionStart;
    var preString = (txtArea.value).substring(0,offset);
    var newString = openerTag + closerTag;
    var postString = (txtArea.value).substring(offset);
    txtArea.value = preString + newString + postString;
    txtArea.selectionStart = offset + openerTag.length;
    txtArea.selectionEnd = offset + openerTag.length;
    txtArea.focus();
  }
  return;
}

function toggleDiv(divid){
    if(document.getElementById(divid).style.display == 'none'){
      document.getElementById(divid).style.display = 'block';
    }else{
      document.getElementById(divid).style.display = 'none';
    }
  }

function ajaxFunctionQ(commentid){
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			document.commentform.thepost.value = document.commentform.thepost.value + ajaxRequest.responseText;
		}
	}
	var queryString = "?tid=" + commentid;
	ajaxRequest.open("GET", "quotethis.php" + queryString, true);
	ajaxRequest.send(null); 
}

function ajaxFunctionTI(thid){
	var ajaxRequest;  // The variable that makes Ajax possible!
	var theid = "pl" + thid;
		document.getElementById(theid).innerHTML ='hang on...';
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
		document.getElementById(theid).style.width = '225px';
		document.getElementById(theid).innerHTML = ajaxRequest.responseText;
		}
	}
	var queryString = "?id=" + thid;
	ajaxRequest.open("GET", "ti.php" + queryString, true);
	ajaxRequest.send(null); 
}

function ajaxFunctionLEI(thid){
	var ajaxRequest;  // The variable that makes Ajax possible!
	var theid = "pl" + thid;
	var thiid = "infopop" + thid;
		document.getElementById(theid).innerHTML ='hang on...';
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
		document.getElementById(thiid).style.right = '0px';
		document.getElementById(thiid).style.width = '225px';
		document.getElementById(theid).innerHTML = ajaxRequest.responseText;
		}
	}
	var queryString = "?id=" + thid;
	ajaxRequest.open("GET", "lei.php" + queryString, true);
	ajaxRequest.send(null); 
}



function pollVote(pollid,pollId){
	var ajaxRequest;  // The variable that makes Ajax possible!
        var thatid = pollid;
        var thisId = pollId;
document.getElementById('pollWindow').innerHTML ='hang on...';
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
		document.getElementById('pollWindow').innerHTML = ajaxRequest.responseText;
		}
	}
	var queryString = "?id="+thatid+"&pollId="+thisId;
	ajaxRequest.open("GET", "/polls/castVote.php" + queryString, true);
	ajaxRequest.send(null); 
}

function getRadioCheckedValue(radio_name) {
var oRadio = document.pollForm.elements[radio_name];

for(var i = 0; i < oRadio.length; i++) {

if(oRadio[i].checked) {
return oRadio[i].value;
}

}

return '';
} 

function ajaxThis(div,script){
	var ajaxRequest;  // The variable that makes Ajax possible!
        var thisDiv = div;
        var thisScript = script;
        // document.getElementById(thisDiv).innerHTML ='hang on...';
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
		document.getElementById(thisDiv).innerHTML = ajaxRequest.responseText;
		}
	}
	
	ajaxRequest.open("GET", "/incs/"+ thisScript +".php", true);
	ajaxRequest.send(null); 
}

function yup(yid){
	var ajaxRequest;  // The variable that makes Ajax possible!
	var theyid = "rate" + yid;
		document.getElementById(theyid).innerHTML ='hang on...';
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
		document.getElementById(theyid).innerHTML = ajaxRequest.responseText;
		}
	}
	var queryString = "?id=" + yid;
	ajaxRequest.open("GET", "yle.php" + queryString, true);
	ajaxRequest.send(null); 
}

