function init()
{
	//photos
var imgs;
count=0; //global. JavaScript doesn't do static
imgs=document.getElementById('photo');
f=document.getElementById('phitch');
if(f)
{
button=document.createElement('input');
button.type='button';
button.value='Next photo';
button.id='next_photo';
button.onclick=function(){roll(imgs);};
f.appendChild(button);

hidden=document.createElement('input');//used in roll()
hidden.type='hidden';
hidden.value='Next photo';
f.appendChild(hidden);
}
	//navigation
var links= document.getElementById('navbar').getElementsByTagName('a');
var original=document.getElementById("submenu").innerHTML;
for(i=0;i<links.length; i++)
{
y=links[i];
y.onmouseover=function() {loadXMLDoc(this);}
if (y.parentNode.className=='active') {y.onmouseover=function() {document.getElementById("submenu").innerHTML=original;};}
}


return false;
}

function loadXMLDoc(y)
//navigation
{
	var x=y.innerHTML;
var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("submenu").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","../common/submenu.php?name="+x,true);
xmlhttp.send();

return false;
}

function roll(o)
{
	//photos
var src
var xmlhttp;
var id
var tag =document.getElementById('photo');//document.createElement("p");
count++;
o.innerHTML='Please wait...';
o.style.height='540px';
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
o.innerHTML=o.innerHTML.replace(/[\s\S]*/, xmlhttp.responseText);
}
}
id=document.getElementById('val_pass').value;
xmlhttp.open("GET","../common/ajax.php?index="+count+"&id="+id,true);
xmlhttp.send();

return false;
}
window.onload=function(){
init();
}
