function clearText(thefield)
{
	if (thefield.defaultValue==thefield.value)
	{
	thefield.value = "";
	}
}
function clearmsg(thefield)
{
	//thefield.message.value="Message"
	//thefield.name.value = "Name";
}
function clearMessage(thefield)
{	
	t = setTimeout(clearmsg(thefield),10000);
}
function tagPost(thefield)
{
	thefield.tagSubmit.disabled=true;
	b = setTimeout("document.tagboard.tagSubmit.disabled=false", 5000);
	thefield.name.value = thefield.text_name.value;
	thefield.message.value = thefield.text_message.value;
	thefield.captcha.value = thefield.text_captcha.value;
	thefield.text_captcha.value = "<- Copy (Click to Refresh)";
	
}
function refreshCaptcha(theItem)
{
	r=Math.floor(Math.random()*1000)
	theItem.src="/captcha.php?r=" + r;
}
function checkPass(thefield)
{
	if(thefield.pass.value != thefield.pass2.value)
	{
		alert("Your passwords do not match!");
	}
	else
	{
		thefield.submit();
	}
}

function checkSame(item1, item2, name, formName)
{
	alert(document.formName.item1.value + " " + document.formName.item2.value);
	if(item1.value == item2.value)
	{
		document.formName.submit();
	}
	else
	{
		alert("Your " + name + "s do not match!");
	}
}

function openForums()
{
	pos = (screen.width - 815)/2;
	forums = window.open("/forums", "shear_forums", "width=815, scrollbars=1, toolbar=1, resizable=1, location=1, menubar=1");
	forums.moveTo(pos,0);
	forums.resizeTo(815,screen.height);
	forums.focus();
}

function showLogin(){

if (document.all||document.getElementById){
element=document.getElementById? document.getElementById("loginarea"):document.all.descriptions;
element.innerHTML=login_form;
}
else if (document.layers){
document.l1.document.l2.document.write(login_form)
document.l1.document.l2.document.close()
}

}

//////////////////////////////////////
//			TAGBOARD AJAX			//
//////////////////////////////////////
var timeout;
var refreshRate = 2000;
var rand	= Math.random();

function ajax() 
{
    if (navigator.appName == "Netscape") 
    {
        return new XMLHttpRequest();
    } 
    else if (navigator.appName == "Microsoft Internet Explorer") 
    {
        try 
        {
            return new ActiveXObject("Msxml2.XMLHTTP");
        } 
        catch(ex) 
        {
            return new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
}
function showLoad()
{
    var loading = "<div align='center' style='height:100%;width:100%;margin-top:75;'><embed src='load.swf' menu='false' quality='best' bgcolor='#c3cfdf' width='25' height='25' name='load' align='middle' allowScriptAccess='sameDomain' allowFullScreen='false' type='application/x-shockwave-flash' pluginspage='http://www.adobe.com/go/getflashplayer' /><br>Loading</div>";
    board = document.getElementById("board");
    board.innerHTML = loading;
}

function getNew()
{
	rand++;
	window.clearTimeout(timeout);
	timeout = window.setTimeout( "getNew()", refreshRate );
	
    url = 'tag.php?'+rand;
    req = ajax();
    
    req.onreadystatechange = function(){
    
        if( req.readyState == 4 && req.status == 200 ) {
            document.getElementById('board').innerHTML = req.responseText;

        }
    }
    
    req.open( 'GET', url , true );
    req.send( null );
}
function postTag()
{
    tag_nameel = document.getElementById('tag_name').value;
    tag_messageel = document.getElementById("tag_message").value;
    url = 'tag.php?a=post&n=' + tag_nameel + '&m=' + tag_messageel + '&' + rand;
    
    req = ajax();
    req.open( 'GET', url, true );
    req.send( null );
    req.onreadystatechange = function()
    {
        if( req.readyState == 4 && req.status == 200 ) 
        {
            getNew();
        }
    }
}
