
function toggleField(form,field,defaultvalue) {
	if (document.forms[form].elements[field].value==defaultvalue) {
		document.forms[form].elements[field].value="";
		document.getElementById(field).className="";
	}
	else if (document.forms[form].elements[field].value=="") {
		document.forms[form].elements[field].value=defaultvalue;
		document.getElementById(field).className="grey";
	}
	//alert(document.forms['login'].elements['email'].value);
}
function togglePasswordfield(form,field,defaultvalue) {
	if (document.forms[form].elements[field].value==defaultvalue) {
		document.forms[form].elements[field].value="";
		document.getElementById(field).className="";
		document.getElementById(field).type="password";
	}
	else if (document.forms[form].elements[field].value=="") {
		document.forms[form].elements[field].value=defaultvalue;
		document.getElementById(field).className="grey";
		document.getElementById(field).type="text";
	}
	//alert(document.forms[form].elements['email'].value);
}


// CHECK ACOUNT USER NAME \\
function checkAccount(site) {
	
	if (site=="pshoot") { domain="pshoot.com"; }
	else { domain="typomania.co.uk"; }
	
	proposed_account_name=document.forms['registrationform'].elements['account_name'].value;
	
	proposed_account_name=proposed_account_name.replace(/[^a-zA-Z0-9]/g,"");
	proposed_account_name=proposed_account_name.toLowerCase();
	
	document.forms['registrationform'].elements['account_name'].value=proposed_account_name;	
	proposed_account_address="Your account address will be '<b>"+proposed_account_name+"."+domain+"</b>'";
	document.getElementById('accountaddress').innerHTML =proposed_account_address;
		
}


function redirect (uri) {
	//alert(uri);
	document.location=uri;
}


// MJB TABS \\

function showTab(tab) {
	if (document.getElementById(tab)) {
		// hide all
		
		var tabsarray=document.getElementsByClassName('tab');
		for(var i=0; i<tabsarray.length; i++) {
			tabsarray[i].style.display="none";
			tabsarray[i].style.visibility="hidden";
		}
		
		document.getElementById(tab).style.display="block";
		document.getElementById(tab).style.visibility="visible";

		document.getElementById(tab).style.filter = "alpha(opacity=100)";
		document.getElementById(tab).style.KhtmlOpacity = 100; 
		document.getElementById(tab).style.MozOpacity = 100;
		document.getElementById(tab).style.opacity = 100;
		
	}
}


function changeheadingSize(paragraph_heading_size) {
	
	newclassName="h"+paragraph_heading_size.value;
	//alert(paragraph_heading_size.value);
	document.getElementById("pheading").className=newclassName;
}

function deleteItem(item_type,item_id,url) {
	var display_item_type = item_type.replace("_", " ");
	var r=confirm("Are you sure you want to delete this "+display_item_type+"?");
	if (r==true) {
		newlocation=url+"&delete_"+item_type+"_id="+item_id;
		//alert(newlocation);
		document.location=newlocation;
	}
	else {
		return false;
	}
}

