/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*Clear field on click*/
function clickclear(field, defval) {
    if (field.value == defval)
      field.value = '';
}

/*Count the number of character and display it in box*/
function charcount(field, maxlimit) {
  var cnt = field.value.length;
  if (cnt > maxlimit) // if too long trim text
    field.value = field.value.substring(0, maxlimit);
  else{
    document.getElementById("count").value = cnt+ " out of 140 characters";
  }
}

/*Set action before submiting*/
function formsubmit(method){
    document.sendForm.action.value=method;
    document.sendForm.submit();
}

function resetForm(){
	alert("reset");
    document.sendForm.country_name.value='Select Country';
	document.sendForm.from.value='Number/Name';
	document.sendForm.to.value='10-Digit Number';
	document.sendForm.message.value='Type message here';
}

/*Count word in text field*/
function wordcount(count) {
	var cnt;
	var words = count.value.split(/\s/);
	cnt = words.length;
	var ele = document.getElementById('count');
	ele.value = cnt;
}

/*Set default value when field is empty*/
function restoredefault(field, defval){
  if(field.value=='')
      field.value=defval;
}

function setAsHome(element){
	var browserName=navigator.appName; 
	if (browserName=="Netscape")
	{ 
		window.location = "../make_home.php";
	}
	if (browserName=="Microsoft Internet Explorer")
	{
		element.style.behavior='url(#default#homepage)';
		element.setHomePage('http://www.wetextfree.com');
	}
}

function adjustBrowser(){
	var browserName=navigator.appName; 
	if (browserName=="Netscape")
	{ 
		document.sendForm.message.cols=34;
	}
}

// Block user display scripts
function hideblockMessage() {
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById("blockMessage").style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.blockMessage.display = 'none';
		}
		else { // IE 4
			document.all.blockMessage.style.display = 'none';
		}
	}
}

function sebrandon(id){
	var ele = document.getElementById(id)

	if(ele.value == ""){
		ele.style.background = "url(http://www.google.com/coop/images/google_custom_search_watermark.gif) no-repeat 0 2px";
	}
}

function sebrandoff(id){
	document.getElementById(id).style.background = "";
}


function checkmemory(){
	
	document.getElementById("memory").checked = !document.getElementById("memory").checked;

	if (document.getElementById("memory").checked==true){
		document.getElementById("memoryDiv").style.background = "url('../images/memory.gif') no-repeat 0 -25px";
	}else{
		document.getElementById("memoryDiv").style.background = "url('../images/memory.gif') no-repeat 0 -2px";
		removeCookie();

	}
}

function hoverOnMemory(){
	document.getElementById("memoryDiv").style.background = "url('../images/memory.gif') no-repeat 0 -49px";
}

function hoverOffMemory(){
	if (document.getElementById("memory").checked==true){
		document.getElementById("memoryDiv").style.background = "url('../images/memory.gif') no-repeat 0 -25px";
	}else{
		document.getElementById("memoryDiv").style.background = "url('../images/memory.gif') no-repeat 0 -2px";
	}
}