function showLogin()
{
    if (document.getElementById('login_div'))
    {
        document.getElementById('login_div').style.display = 'block';
        document.getElementById('login_refresh').style.display = 'none';
    }
}

function hideDiv(thediv)
{
    document.getElementById(thediv).style.display = 'none';
}

function showDiv(thediv)
{
    document.getElementById(thediv).style.display = 'block';
}

function setInnerHTML(thediv, tempHTML)
{
    document.getElementById(thediv).innerHTML = tempHTML;
}

function showMessage(body)
{
    bdy = new String(body);
    bdy = bdy.replace(/~/g,"'");
    document.getElementById('messgdiv').innerHTML = "<h2>Message</h2><a href=\"javascript:hideDiv('messgdiv')\" class='main'>Close this message</a><p/>";
    document.getElementById('messgdiv').innerHTML = document.getElementById('messgdiv').innerHTML + bdy;
    document.getElementById('messgdiv').style.display = 'block';
}

function popreplay(lid,gid,hid,vid)
{
        var thelink = "lgReplay.aspx?lgid=" + lid + "&sid=" + gid + "&hid=" + hid + "&vid=" + vid;
        window.open(thelink,'statspop','width=735,height=585,directories=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=yes,screenX=25,screenY=25,top=25,left=25')
}

function countChar(txtId, divId)
{
    if(document.getElementById)
	{
	var div_id = document.getElementById(divId);
	var txt_id = document.getElementById(txtId)
	var s = txt_id.value;
	div_id.innerHTML = "Current character count: " + s.length + " of 1000 allowed";
	}
}

function showIPhoneLoading()
{
    if(isIPhone)
    {
        showDiv('iphoneLoading');
    }
}    

function alertIPhone()
{
	
		
    if(isIPhone)
    {
	pastalert = getCookie('didalert');
	if(pastalert == "0")
	{
		setCookie('didalert','1','2');
		alert("iPhone users, you can also use the native app available in the App Store (search for PENNANT CHASE) or the web app at pennantchase.com/iphone");
	}
        
    }
}

//cookies
function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "0";
}



var fsv_a = Math.floor(Math.random()*9999999999+1) 
var random_number = fsv_a; 
var isIPhone = (navigator.userAgent.toLowerCase().indexOf('iphone') != -1);

//show login if ads never load
if(!isIPhone)
{
    window.setTimeout("showLogin()", 1500);
}

//place the IPhone loading on all HREFs
function loadIPhoneHREFs()
{
    atags = document.getElementsByTagName('a');
    numTags = atags.length;  

    for (var a = 0; a < numTags; ++a) { 
    
        atags[a].setAttribute('onlick','showIPhoneLoading()');    

    }
}