function showobj(myobj) {

if (document.getElementById(myobj) != null) {
	
	document.getElementById(myobj).style.display='block';
}
	
}


function hideobj(myobj) {

if (document.getElementById(myobj) != null) {
	
	document.getElementById(myobj).style.display='none';
}
	
}

	
function viewmorewebcam(myid, myobj)
{


	
//extract our id
var myidarray = myid.split('_');
var realid = myidarray[1];	
	
if (document.getElementById(myid) != null && document.getElementById('loading_'+myid) != null) {

document.getElementById(myid).style.display = 'none';
document.getElementById('loading_'+myid).style.display = 'block';

}
	

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)
    {
		
		
		if (xmlhttp.responseText.length > 1 ) {
			
    	 	if (document.getElementById('webcam_wrapper_'+realid) != null) {
				
				myobj.style.position = 'relative';
				
				var loadwrapparent = myobj.parentNode.parentNode;
				
				loadwrapparent.style.display = 'none';
				
				document.getElementById('loading_'+myid).style.display = 'none';
				document.getElementById('webcam_wrapper_'+realid).innerHTML += xmlhttp.responseText;
				fleXenv.updateScrollBars();
				Shadowbox.init({ skipSetup: true }); Shadowbox.setup(); 
				
			}
			
		} else {
			
			document.getElementById('loading_'+myid).style.display = 'none';
			
		}
    

	
	}
  }
  
  
  //alert(myid);
xmlhttp.open("GET","morewebcams.php?id="+myid,true);
xmlhttp.send();
}


function addwebcam() {
	
	showobj('add-laoding');
	
	if (document.getElementById('webcam-select-id') != null) {
		
		var s = document.getElementById('webcam-select-id');
		
		//now lets sha boogey
		 var thisvalue = s.options[s.selectedIndex].value;
		 
		 //now lets send off the request
		
		
	}
	
	
	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)
    {
		
		hideobj('add-laoding');
		if (xmlhttp.responseText.length > 1 ) {
			
			if (document.getElementById('webcam-list') != null) {
				
				//we want to append to the dom
				
				
				
				newDiv = document.getElementById('webcam-list');
				var divTag = document.createElement("div");
       		
				divTag.innerHTML = xmlhttp.responseText;
				newDiv.appendChild(divTag);
				
				fleXenv.initByClass("flexcroll");
				Shadowbox.init({ skipSetup: true }); Shadowbox.setup();
				
			}
			
		}
		
	}
	
  }
	
	if (thisvalue != '' && thisvalue != null) {
	
	//alert("addwebcams.php?id="+thisvalue);
xmlhttp.open("GET","addwebcams.php?id="+thisvalue,true);
xmlhttp.send();
	}
}


function remove_webcam(myObj, webcam) {
	
	
	var mydiv = myObj.parentNode.parentNode;
	
	mydiv.parentNode.removeChild(mydiv);
	
		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)
    {
		
		
		if (xmlhttp.responseText.length > 1 ) {
			
			
			}
			
		}
		
	}
	
  
	
xmlhttp.open("GET","removewebcam.php?id="+webcam,true);
xmlhttp.send();
	
}


function requestwebcam() {
	
	
	showobj('request-laoding');
	
	if (document.getElementById('webcam-request-ti') != null) {
		
		var ourvalue = document.getElementById('webcam-request-ti').value;
		
	}
	
	if (document.getElementById('webcam-request-success') != null) {
				
				document.getElementById('webcam-request-success').innerHTML = '';
				
			}
	
	
			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)
    {
		
		
		if (xmlhttp.responseText.length > 1 ) {
			
			document.getElementById('webcam-request-ti').value = '';
			
			if (document.getElementById('webcam-request-form') != null) {
				
				document.getElementById('webcam-request-form').style.display = 'none';
				
			}
			
			if (document.getElementById('webcam-request-success') != null) {
				
				document.getElementById('webcam-request-success').innerHTML = 'Your request has been sent!';
				
			}
				
				
			}//end response
			
			}
			
		}
		
	
	
	
xmlhttp.open("GET","requestwebcam.php?value="+ourvalue,true);
xmlhttp.send();
	
}
