var xmlHttp;
var brows=new Number(3);

function LoginUser()
{
 document.getElementById('PhotosOption').style.backgroundColor="white";
 document.getElementById('SightOption').style.backgroundColor="white";
 document.getElementById('GiveYourSight').style.backgroundColor="white";
 document.getElementById('Photos').style.backgroundColor="white";
 document.getElementById('mySelllist').style.backgroundColor="white";
 document.getElementById('MyProfile').innerHTML="";
 document.getElementById('MyProfile').innerHTML="<div id='UserConfirm'></div><div id='UserConfirmButton'></div>";
 document.getElementById('MyProfile').style.visibility ="hidden";
 document.getElementById('upload_target_user').style.visibility = "hidden";
 document.getElementById('upload_target_user').style.height = "0px";
document.getElementById('upload_target_sight').style.visibility = "hidden";
document.getElementById('upload_target_sight').style.height = "0px";

document.getElementById('upload_target_Item').style.visibility = "hidden";
document.getElementById('upload_target_Item').style.height = "0px";
document.getElementById('upload_target_photo').style.visibility = "hidden";
document.getElementById('upload_target_photo').style.height = "0px";

 document.getElementById('LogOut').innerHTML="";
 var LoginForm=document.getElementById('Registration');
 var FormFields="";
 FormFields += "<label id='nickname' type='hidden' value=''></label>"
 FormFields += "Email: </br><input id='email' type='text' name='UserEmail'/></br>"
 FormFields += "Password: </br><input id='pwd' type='password' name='UserPassword'/></br>"
 FormFields += "<input type='button' onclick='UserWelcome(0)' value='Access my account' /></br>"
 FormFields += "<input type='button' onclick='NewUser()' value='New User' /></br>"
 FormFields += "<a href='javascript:ForgotPwd_1()' style='color:#888888'>I forgot my password</a>"
 LoginForm.innerHTML=FormFields;
} 

function Unsubscribe()
 {

xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return;
 } 

  var User=document.getElementById('nickname').innerHTML;
  var Pwd=document.getElementById('pwd_check').innerHTML;

  var r=confirm("Are you sure you want to unsubscribe from Haggis Reef? If you choose OK all your records held on our website will be lost");

  if (r==true)
   {
    var url="php/unsubscribe.php";
    url=url +"?user=" +User +"&pwd=" +Pwd;
    xmlHttp.onreadystatechange=stateRefreshChanged;
    xmlHttp.open("POST",url,true);
    xmlHttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
    xmlHttp.send(url);
    
    window.location = "http://www.haggisreef.co.uk";
   }
}

function UserWelcome(a)
{ 

xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return;
 } 

document.getElementById('UserConfirm').innerHTML="";
document.getElementById('MyProfile').style.visibility = "hidden";

if(a == 0)
{
var email=document.getElementById('email').value;
var paswd=document.getElementById('pwd').value;
} else
{
var email=document.getElementById('NewUser').elements[7].value;
var paswd=document.getElementById('NewUser').elements[3].value;
}

var url="php/login.php";
url=url +"?email=" +email +"&pwd=" +paswd;
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xmlHttp.send(url);
}

function stateRefreshChanged() 
{ 
 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 {
  document.getElementById('Registration').innerHTML=xmlHttp.responseText;
 }
}

function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
  document.getElementById('Registration').innerHTML=xmlHttp.responseText;
  var UserNick=document.getElementById('nickname').innerHTML;
  var photos=document.getElementById('PhotosOption');
  var Sight=document.getElementById('SightOption');

document.getElementById('GiveYourSight').style.backgroundColor="#CBC3C1";
document.getElementById('Photos').style.backgroundColor="#CBC3C1";
document.getElementById('mySelllist').style.backgroundColor="#CBC3C1";
  
    if (UserNick != '')
      {
       document.getElementById('LogOut').innerHTML="<a href='http://www.haggisreef.co.uk' style='color: #888888'>Logout</a>";
        
        var choice_str="";
        choice_str += "</br><i>I have checked the waves in: </i></br>"
        choice_str += "<select onclick='NewSight()' id='YourSight'>"
        choice_str += "<option>Aberdeen Footdee</option>"
        choice_str += "<option>Aberdeen Nigg Bay</option>"
        choice_str += "<option>Aberdeen Tunnel</option>"
        choice_str += "<option>Brora</option>"
        choice_str += "<option>Cruden Bay</option>"
        choice_str += "<option>Fraserburgh</option>"
        choice_str += "<option>Golspie</option>"
        choice_str += "<option>Lossiemouth</option>"
        choice_str += "<option>Newquay Fistral</option>"
        choice_str += "<option>Sandend</option>"
        choice_str += "<option>Stonehaven</option>"
        choice_str += "<option>Thurso East</option>"
        choice_str += "</select></br>"

        Sight.innerHTML=choice_str;

       var sell=document.getElementById('mySell');
       var sell_str="";
          sell_str += "<br><input type='button' value='My Shop' onclick='ViewMyItems()' /><br><br><i>I want to sell my:</i></br><select onclick='AddIt_test()' id='selllist'>"
	  sell_str += "<option>Long board</option>"
	  sell_str += "<option>Medium board</option>"
	  sell_str += "<option>Short board</option>"
	  sell_str += "<option>Male Wetsuit</option>"
	  sell_str += "<option>Female Wetsuit</option>"
          sell_str += "<option>Gloves</option>"
	  sell_str += "<option>Boots</option>"
	  sell_str += "<option>Hoods</option>"
	  sell_str += "<option>Miscellaneous</option>"
	  sell_str += "</select>"
          sell.innerHTML=sell_str;

          photos.innerHTML="<i>Upload my photo (.jpg) from:</i><br><select id='PhotoBeaches' onclick='UploadNewPhoto()'><option>Aberdeen Footdee</option><option>Aberdeen Nigg Bay</option><option>Aberdeen Tunnel</option><option>Brora</option><option>Cruden Bay</option><option>Fraserburgh</option><option>Golspie</option><option>Lossiemouth</option><option>Newquay Fistral</option><option>Sandend</option><option>Stonehaven</option><option>Thurso East</option></select>";
       }
 } 
}  

function NewUser()
{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return;
 }

  var User=document.getElementById('Registration');
  var outputForm=document.getElementById('mySelllist');
  document.getElementById('UserConfirm').innerHTML="";
  
  document.getElementById('MyProfile').style.backgroundColor = "white";
  document.getElementById('LogOut').innerHTML="<a href='http://www.haggisreef.co.uk' style='color:#888888'>Back to login</a>";

      var user_field="";
      user_field += "<form  id='NewUser' name='NewUser' action='php/NewUser.php' method='post' target='upload_target_user' enctype='multipart/form-data' >";
      user_field += "Choose a Username <br><input type='text' name='NewSurfer' /><br>";
      user_field += "<input type='hidden' id='nickname' value='' />";
      user_field += "Choose a password <br><input type='password' name='pwd' /><br>";
      user_field += "Repeat password <br><input type='password' name='pwd2' /><br>";
      user_field += "<input type='hidden' name='UserBeach' />";
      user_field += "Choose the spot where you surf<br><select id='Beaches' onclick='SetBeach()'><option>Aberdeen Footdee</option><option>Aberdeen Nigg Bay</option><option>Aberdeen Tunnel</option><option>Brora</option><option>Cruden Bay</option><option>Fraserburgh</option><option>Golspie</option><option>Lossiemouth</option><option>Newquay Fistral</option><option>Sandend</option><option>Stonehaven</option><option>Thurso East</option></select><br>";
      user_field += "Enter your postcode <br><input type='text' name='PostCode' /><br>";
      user_field += "Enter Email <br><input type='text' name='email' align='left'/><br>";
      user_field += "Enter Mobile with national code - eg 0044 1234567851 (optional) <br><input type='text' name='mobile' align='left'/><br>";
      user_field += "Choose a profile picture <br><input type='file' name='photo' /><br><br>";
      user_field += "<input type='submit' onclick='UserStatus()' value='Create your account' />";
      user_field += "</form>";
      User.innerHTML=user_field;
}

function UserStatus()
{


var outputForm=document.getElementById('mySelllist');
var User=document.getElementById('Registration');
document.getElementById('upload_target_user').contentWindow.document.write("Uploading! please wait...");
document.getElementById('upload_target_user').style.visibility = "visible";
document.getElementById('upload_target_user').style.height = "300px";
document.getElementById('UserConfirm').innerHTML="";

}

function PrintUserOutput()
{
document.getElementById('upload_target_user').contentWindow.document.write("Uploading! please wait...");
document.getElementById('upload_target_user').style.visibility = "visible";
document.getElementById('upload_target_user').style.height = "100px";
}

function NewSight()
{

          var outputForm=document.getElementById('GiveYourSight');
          var UserNick=document.getElementById('nickname').innerHTML;
          var select=document.getElementById('YourSight');
          var beach=select.options[select.selectedIndex].innerHTML;
          document.getElementById('upload_target_sight').style.visibility = "hidden";
          document.getElementById('upload_target_sight').style.height = "0px";
          
          var sight_field="";
          sight_field += "<form  id='AddSight' name='AddSight' action='php/AddSight.php' method='post' target='upload_target_sight' enctype='multipart/form-data' >"
          sight_field += "<input type='hidden' name='SelectedSightBeach' value='" +beach +"' />"
          sight_field += "<input type='hidden' name='usernick' value='" +UserNick +"' />"
          sight_field += "Waves description (max 160 characters): <textarea name='Descript' align='left' rows='3' cols='20' maxlength='160'></textarea></br>"
          sight_field += "<label for='file'>Picture (.jpg)</label></br>"
          sight_field += "<input type='file' name='photo' /></br>"
          sight_field += "<input type='submit' onclick='SightOutput()' value='Upload' />"
          sight_field += "</form>"
          outputForm.innerHTML=sight_field;
}

function SightOutput()
{ 
  document.getElementById('upload_target_sight').contentWindow.document.write("Uploading! please wait...");
  document.getElementById('upload_target_sight').style.visibility = "visible";
  document.getElementById('upload_target_sight').style.height = "80px";
}

function ViewSights(last,first,direction)
{
  xmlHttp=GetXmlHttpObject();
  if (xmlHttp==null)
    {
     alert ("Browser does not support HTTP Request")
     return;
    }
var beach=document.getElementById('Sights').options[document.getElementById('Sights').selectedIndex].innerHTML;

try
   {
   var url="php/ViewSights.php";
   url=url +"?beach=" +beach +"&last=" +last +"&first=" +first +"&direction=" +direction;
   xmlHttp.onreadystatechange=ViewSightsList;
   xmlHttp.open("POST",url,true);
   xmlHttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
   xmlHttp.send(url);
   }
   catch(err)
   {
   txt="There was an error on this page.\n\n";
   txt+="Error description: " + err.description + "\n\n";
   txt+="Click OK to continue.\n\n";
   alert(txt);
  }
}

function ViewSightsList()
 {
  if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
  { 
   document.getElementById('list_div').innerHTML=xmlHttp.responseText;
  }
 }

function ViewPhotos(last,first,direction)
{

xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return;
 }

  var beach=document.getElementById('PhotosFrom').options[document.getElementById('PhotosFrom').selectedIndex].innerHTML;

   var url="php/ViewPhotos.php";
   url=url +"?beach=" +beach +"&last=" +last +"&first=" +first +"&direction=" +direction;
   xmlHttp.onreadystatechange=ViewPhotosList;
   xmlHttp.open("POST",url,true);
   xmlHttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
   xmlHttp.send(url);

}

function ViewPhotosList()
 {
  if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
  { 
   document.getElementById('list_div').innerHTML=xmlHttp.responseText;
  }
 }

function ViewVideoClips(type)
{
  xmlHttp=GetXmlHttpObject();
  if (xmlHttp==null)
    {
     alert ("Browser does not support HTTP Request")
     return;
    }
var VideoType=document.getElementById('SurfVideoClips').options[document.getElementById('SurfVideoClips').selectedIndex].innerHTML;

try
   {
   var url="php/SurfVideoClips.php";
   url=url +"?VideoType=" +VideoType;
   xmlHttp.onreadystatechange=ViewVideoClipsList;
   xmlHttp.open("POST",url,true);
   xmlHttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
   xmlHttp.send(url);
   }
   catch(err)
   {
   txt="There was an error on this page.\n\n";
   txt+="Error description: " + err.description + "\n\n";
   txt+="Click OK to continue.\n\n";
   alert(txt);
  }
}

function ViewVideoClipsList()
 {
  if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
  { 
   document.getElementById('list_div').innerHTML=xmlHttp.responseText;
  }
 }

function UpdateProfilePhoto()
{

          var outputForm=document.getElementById('ProfilePhoto');
          var UserNick=document.getElementById('nickname').innerHTML;

          var pict_field="";
          pict_field += "<form  id='NewProfilePhoto' name='NewProfilePhoto' action='php/ChangePhoto.php' method='post' target='upload_target_user' enctype='multipart/form-data' >";
          pict_field += "<input type='hidden' id='usernick' name='usernick' value='" +UserNick +"' />";
          pict_field += "<label for='file'><b>Picture</b></label><br>";
          pict_field += "<input type='file' name='photo' /><br>";
          pict_field += "<input type='submit' onclick='PrintUserOutput()'  value='Change Photo' />";
          pict_field += "</form>";
          outputForm.innerHTML=pict_field;
}

function UploadNewPhoto()
{
          var outputForm=document.getElementById('Photos');
          var select=document.getElementById('PhotoBeaches');
          var UserNick=document.getElementById('nickname').innerHTML;
          document.getElementById('upload_target_photo').style.visibility = "hidden";
          document.getElementById('upload_target_photo').style.height = "0px";

          var pict_field="";
          pict_field += "<form  id='NewPhoto' action='php/AddPhoto.php' method='post' target='upload_target_photo' enctype='multipart/form-data' >"
          pict_field += "<input type='hidden' name='SelectedPhotoBeach' value='" +select.options[select.selectedIndex].innerHTML +"' />"
          pict_field += "<input type='hidden' name='usernick' value='" +UserNick +"' />"
          pict_field += "<input type='file' name='photo' />"
          pict_field += "</br><input type='submit' onclick='PhotoOutput()'  value='Upload Photo' />"
          pict_field += "</form>"
          outputForm.innerHTML=pict_field;
}

function PhotoOutput()
{ 
  document.getElementById('upload_target_photo').contentWindow.document.write("Uploading! please wait...");
  document.getElementById('upload_target_photo').style.visibility = "visible";
  document.getElementById('upload_target_photo').style.height = "80px";
}

function GetMap()
{ 
 document.getElementById('upload_map').style.height = "338px";
 document.getElementById('upload_map').style.width = "520px";
 document.getElementById('upload_map').style.visibility = "visible";
}

function BigMap()
{
document.getElementById('list_div').innerHTML="<table><tbody><tr><td align=center></br><b>WHERE TO SURF</b></br></br><p class='light' align='center' line-height='80%'>Is the place where you surf missing?<br>Let us know where it is and we add it on the list!</p> <a href='mailto:queries@haggisreef.co.uk' style='color:#888888'>click here</a><br><iframe id='upload_map' name='upload_map' style='border:0px' height='556px' width='471px'></iframe><br></td></tr></tbody></table>";
}

function GetXmlHttpObject()
{
var xmlHttp=null;

try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
brows=2;
 }
catch (e)
 {
 // Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  brows=1;
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}


function AddIt_test()
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return;
 }

var select=document.getElementById('selllist');
var outputForm=document.getElementById('mySelllist');
document.getElementById('upload_target_Item').style.visibility = "hidden";
document.getElementById('upload_target_Item').style.height = "0px";

          var UserNick=document.getElementById("nickname").innerHTML;
          var sell_field="";
          sell_field += "<form  name='ItemForm' action='php/AddObject.php' method='post' target='upload_target_Item' enctype='multipart/form-data'>"
          sell_field += "<input type='hidden' name='usernick' value='" +UserNick +"' />"
          sell_field += "<input type='hidden' name='itemtype' value='" +select.options[select.selectedIndex].innerHTML +"' />"
	  sell_field += "Size <input type='text' name='size' align='left' /><br>"
          sell_field += "Brand <input type='text' name='brand' align='left' /><br>"
          sell_field += "Price (&#163)<input type='text' name='price' align='left' /><br>"
          sell_field += "Description <input type='text' name='descript' align='left' /><br>"
          sell_field += "<label for='file'>Picture (.jpg)</label></br>"
          sell_field += "<input type='file' name='photo' ><br>"
          sell_field += "<input type='submit' onclick='ItemOutput()'  value='Upload item' />"
          sell_field += "</form>"
          outputForm.innerHTML=sell_field;
}


function ItemOutput()
{ 
  document.getElementById('upload_target_Item').contentWindow.document.write("Uploading! please wait...");
  document.getElementById('upload_target_Item').style.visibility = "visible";
  document.getElementById('upload_target_Item').style.height = "80px";
}

function ViewMyItems()
{ 

xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return;
 }

var User=document.getElementById('nickname').innerHTML;
var url="php/ViewMyObject.php";
url=url +"?usernick=" +User;
xmlHttp.onreadystatechange=ItemsOut;
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xmlHttp.send(url);
}

function ItemsOut()
 {
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
  document.getElementById('list_div').innerHTML=xmlHttp.responseText;
 } 
}

function Refresh()
 {

if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 var User=document.getElementById('nickname').innerHTML;

 var url = "php/ViewMyObject.php";
 url=url +"usernick=" +User;
 xmlHttp.onreadystatechange=ItemsOut;
 xmlHttp.open("POST",url,true);
 xmlHttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
 xmlHttp.send(url);
}

}


function DeleteIt(ItId)
 {

var del="delete";
var User=document.getElementById('nickname').innerHTML;
var url="php/deleteItem.php";
url=url +"?cmd=" +del +"&id=" +ItId +"&user=" +User;
xmlHttp.onreadystatechange=Refresh;
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xmlHttp.send(url);

ViewMyItems();

}

function SetBeach()
{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return;
 }

var select=document.getElementById('NewUser').elements[5];
document.getElementById('NewUser').elements[4].value=select.options[select.selectedIndex].innerHTML;
}

function ViewProfile()
 {
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
  document.getElementById('MyProfile').innerHTML=xmlHttp.responseText;
 } 
}

function EditProfile()
 {

xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return;
 } 


document.getElementById('MyProfile').style.visibility = "visible";
document.getElementById('LogOut').innerHTML="";
document.getElementById('upload_target_user').style.height = "100px";

var User=document.getElementById('nickname').innerHTML;
var url="php/ViewMyProfile.php";
url=url +"?usernick=" +User;
xmlHttp.onreadystatechange=ViewProfile;
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xmlHttp.send(url);
}

function RefreshProfile()
{ 

xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return;
 } 

document.getElementById('MyProfile').innerHTML="";
document.getElementById('MyProfile').innerHTML="<div id='UserConfirm'></div><div id='UserConfirmButton'></div>";
document.getElementById('MyProfile').style.visibility ="hidden";
document.getElementById('upload_target_user').style.visibility = "hidden";
document.getElementById('upload_target_user').style.height = "0px";

var User=document.getElementById('nickname').innerHTML;
var url="php/RefreshLogin.php";
url=url +"?usernick=" +User;
xmlHttp.onreadystatechange=stateRefreshChanged;
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xmlHttp.send(url);
}

function ChangePwdOutput()
 {
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
  document.getElementById('PwdWarning').innerHTML=xmlHttp.responseText;
 } 
}

function ChangePwd()
{

xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return;
 }

var paswd1=document.getElementById('pwd1').value;
var paswd2=document.getElementById('pwd2').value;
var User=document.getElementById('nickname').innerHTML;

  if (paswd1 == paswd2)
  {
   var url="php/ChangePwd.php";
   url=url +"?usernick=" +User +"&NewPwd=" +paswd2;
   xmlHttp.onreadystatechange=ChangePwdOutput;
   xmlHttp.open("POST",url,true);
   xmlHttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
   xmlHttp.send(url);
  }
  else
  {
   document.getElementById('PwdWarning').innerHTML="Your passwords dont match!";
  }
}

function ChangeEmailOutput()
 {
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
  document.getElementById("EmailWarning").innerHTML=xmlHttp.responseText;
 } 
}

function ChangeEmail()
{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return;
 }

var email=document.getElementById('NewEmail').value;
var User=document.getElementById('nickname').innerHTML;

  if (email != "")
  {
   var url="php/ChangeEmail.php";
   url=url +"?usernick=" +User +"&email=" +email;
   xmlHttp.onreadystatechange=ChangeEmailOutput;
   xmlHttp.open("POST",url,true);
   xmlHttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
   xmlHttp.send(url);
  }
  else
  {
   document.getElementById('EmailWarning').innerHTML="Retype your email!";
  }
}

function ChangeMobileOutput()
 {
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
  document.getElementById('MobileWarning').innerHTML=xmlHttp.responseText;
 } 
}

function ChangeMobile()
{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return;
 }

var mobile=document.getElementById('NewMobile').value;
var User=document.getElementById('nickname').innerHTML;

  if (mobile != "")
  {
   var url="php/ChangeMobile.php";
   url=url +"?usernick=" +User +"&mobile=" +mobile;
   xmlHttp.onreadystatechange=ChangeMobileOutput;
   xmlHttp.open("POST",url,true);
   xmlHttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
   xmlHttp.send(url);
  }
  else
  {
   document.getElementById('MobileWarning').innerHTML="Retype your mobile number!";
  }

}

function ChangePhoto()
{
 document.getElementById('upload_target_user').style.visibility = "visible";
} 

function ItemInformation()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
  document.getElementById('list_div').innerHTML=xmlHttp.responseText;
 } 
}

function display_item(last,first,direction)
{ 

xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return;
 }

        var User=document.getElementById('nickname').innerHTML;
        var select=document.getElementById('Shopitems');
        var item=select.options[select.selectedIndex].innerHTML;

if(item == "- Any surfboard -")
{type='0';}

if(item == "Long board")
{type='1';}

if(item == "Short board")
{type='2';}

if(item == "Medium board")
{type='3';}

if(item == "- Wetsuits -")
{type='4';}

if(item == "Male")
{type='5';}

if(item == "Female")
{type='6';}

if(item == "- Tools -")
{type='7';}

if(item == "Gloves")
{type='8';}

if(item == "Boots")
{type='9';}

if(item == "Hoods")
{type='10';}

if(item == "- Miscellaneous -")
{type='11';}


             var url="php/ViewItems.php";
             url=url +"?type=" +type +"&usernick=" +User +"&last=" +last +"&first=" +first +"&direction=" +direction;
             xmlHttp.onreadystatechange=ItemInformation;
             xmlHttp.open("POST",url,true);
             xmlHttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
             xmlHttp.send(url);
             SurfBannerOut();
}    

function ChangePrice(ItId)
 {

var price=document.getElementById(ItId).value;
var User=document.getElementById('nickname').innerHTML;
var url="php/ChangePrice.php";
url=url +"?id=" +ItId +"&price=" +price;
xmlHttp.onreadystatechange=Refresh;
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xmlHttp.send(url);

ViewMyItems();

}

function PwdStatus()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
  document.getElementById('UserConfirm').innerHTML=xmlHttp.responseText;
 } 
}

function BeachStatus()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
  document.getElementById('BeachWarning').innerHTML=xmlHttp.responseText;
 } 
}

function ChangeBeach()
{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return;
 }

var User=document.getElementById('nickname').innerHTML;
var selectedBeach=document.getElementById('Beaches');

var url="php/ChangeBeach.php";
url=url +"?Beach=" +selectedBeach.options[selectedBeach.selectedIndex].value +"&usernick=" +User;
xmlHttp.onreadystatechange=BeachStatus;
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xmlHttp.send(url);
}

function ChangePostCodeOutput()
 {
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
  document.getElementById('PostCodeWarning').innerHTML=xmlHttp.responseText;
 } 
}

function ChangePostCode()
{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return;
 }

var User=document.getElementById('nickname').innerHTML;
var NewPostCode=document.getElementById('NewPostCode').value;

var url="php/ChangePostCode.php";
url=url +"?PostCode=" +NewPostCode +"&usernick=" +User;
xmlHttp.onreadystatechange=ChangePostCodeOutput;
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xmlHttp.send(url);
}

function ForgotPwd_1()
{
document.getElementById('MyProfile').style.visibility = "visible";
document.getElementById('UserConfirm').innerHTML="<i>Insert your email and click <a href='javascript:ForgotPwd_2()' style='color:blue'>here</a></i>";
}

function ForgotPwd_2()
{

xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return;
 } 

document.getElementById('MyProfile').style.visibility = "visible";
var email=document.getElementById('email').value;

var url="php/ForgotPwd.php";
url=url +"?email=" + email;
xmlHttp.onreadystatechange=PwdStatus;
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xmlHttp.send(url);
}

function LinksOut()
 {
  if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
  { 
   document.getElementById('list_div').innerHTML=xmlHttp.responseText;
  } 
}

function TextServiceOut()
 {
  if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
  { 
   document.getElementById('list_div').innerHTML=xmlHttp.responseText;
  } 
}

function GetTextService()
{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return;
 }

var url="php/textservice.php";
xmlHttp.onreadystatechange=TextServiceOut;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function GetLinks()
{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return;
 }

var url="../../php/links.php";
xmlHttp.onreadystatechange=LinksOut;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function IntrOut()
 {
  if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
  { 
   document.getElementById('list_div').innerHTML=xmlHttp.responseText;
  } 
}

function GetIntro()
{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return;
 }

var url="php/intro.php";
xmlHttp.onreadystatechange=IntrOut;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function GetRules()
{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return;
 }

var url="php/houserules.php";
xmlHttp.onreadystatechange=IntrOut;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function ComingUpOut()
 {
  if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
  { 
   document.getElementById('list_div').innerHTML=xmlHttp.responseText;
  } 
}

function GetComingUp()
{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return;
 }

var url="php/comingup.php";
xmlHttp.onreadystatechange=ComingUpOut;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function SurfBannerOut()
 {
   document.getElementById('surf_banner').innerHTML="<script type='text/javascript'><!-- google_ad_client = 'pub-7895505224380217'; /* 468x60, SurfShopLinks */ google_ad_slot = '9503195599'; google_ad_width = 468; google_ad_height = 60; //--></script><script type='text/javascript' src='http://pagead2.googlesyndication.com/pagead/show_ads.js'></script>";
}
