// JavaScript Document

//function frame(xx) {
		//var put = xx
		//window.location = '/forum/';		
		//window.frames[frame].location = '/forum/';
		//frames(xx);
		//document.getElementById('frame').src = xx;
		//alert(document.getElementById('frame'))
		//document.getElementById('iframe_id').src = xx;
		//alert(document.getElementById('frame'))
		//call()
		//document.getElementById('frame').contentWindow.xx;
		
//}

function frame(b) {
	//alert(b)
	if ( b != ''){
		b ='/phpBB2/';		
	};
document.getElementById('f').innerHTML = 
 '<iframe  name="frame" id="frame" frameborder="0" align="middle" width="100%" height="800" scrolling="auto" src="'+b+'"></iframe>';
	return b;
}

//////////////////////----------------------dorp down menu------------------------//////////////////////////////
var timeout	= 500;
var closetimer	= 0;
var ddmenuitem	= 0;

// open hidden layer
function mopen(id)
{	
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';

}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// close layer when click-out
document.onclick = mclose; 
//////////////////////----------------------dorp down menu------------------------//////////////////////////////



//////////////////////----------------------Campe site Drop down------------------------//////////////////////////////


// Javascript function to go to a new page defined by a SELECT element

function goToPage( id ) {

  var node = document.getElementById( id );
  
  // Check to see if valid node and if node is a SELECT form control
  
  if( node &&
    node.tagName == "SELECT" ) {

    // Go to web page defined by the VALUE attribute of the OPTION element

    window.location.href = node.options[node.selectedIndex].value;
    
  } // endif
  
  
}
//////////////////////----------------------Campe site Drop down------------------------//////////////////////////////

//////////////////////----------------------Pop ups------------------------//////////////////////////////

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//////////////////////----------------------Pop ups------------------------//////////////////////////////


function show_resort_details(rid){
	var r = document.getElementById('resort_row_' + rid);
	var c = document.getElementById('resort_cell_' + rid);
	var n = document.getElementById('name_' + rid);
	
	if(r.style.visibility == 'hidden'){
		r.style.display = 'block';
		r.style.visibility = 'visible';
		
		n.style.font = '11px;';
		//c.style.display = 'block';
		//c.style.visibility = 'visible';
		c.innerHTML = GETitforme('?show_resort_details=' + rid);		
	}else{
		c.innerHTML = '';
		r.style.display = 'none';
		r.style.visibility = 'hidden';
		
		n.style.font = '11px;';
		
		//c.style.display = 'none';
		//c.style.visibility = 'hidden';		
	}	
}

function GETitforme(gstring){
	loadXMLDoc('data.php'+gstring);
}

//ajax functions START __________
	var xmlhttp;
	function loadXMLDoc(url){
		if (window.XMLHttpRequest){// code for Mozilla, etc.
		  xmlhttp=new XMLHttpRequest();
		  xmlhttp.onreadystatechange=xmlhttpChange;
		  //alert(url);
		  xmlhttp.open("GET",url,true);
		  xmlhttp.send(null);
		}else if (window.ActiveXObject){// code for IE
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		    if (xmlhttp){
			    xmlhttp.onreadystatechange=xmlhttpChange;
			    xmlhttp.open("GET",url,true);
			    xmlhttp.send(null);
		    }
		}
	}
	function postXMLDoc(url,formname){
		if (window.XMLHttpRequest){// code for Mozilla, etc.
		  xmlhttp=new XMLHttpRequest();
		    if (xmlhttp){
				var fields = new Array();
		    	if(formname){
		      		var ajax = formname;
		    	}
		    	//loop through form elements and retrieve field NAMEs and Values
		    	for (var x = 0; x < eval("document."+ajax+".elements.length"); x++){
		     		// join them into a string.
		 			eval("fields.push(document."+ajax+".elements[x].name+'='+document."+ajax+".elements[x].value)");
		    	}
		    	elem = 'errors';
		    	//sendf looks like "username=myusername&password=mypass"
		    	var sendf = fields.join('&');
		    	
		    	
		    	xmlhttp.open("POST", url, true);
		    	xmlhttp.onreadystatechange=xmlhttpChange;
		    	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	//	    	xmlhttp.setRequestHeader('Content-Type', 'multipart/form-data');
		    	xmlhttp.send(sendf);   			    
		    }
		}else if (window.ActiveXObject){// code for IE
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		    if (xmlhttp){
				var fields = new Array();
		    	if(formname){
		      		var ajax = formname;
		    	}
		    	//loop through form elements and retrieve field NAMEs and Values
		    	for (var x = 0; x < eval("document."+ajax+".elements.length"); x++){
		     		// join them into a string.
		 			eval("fields.push(document."+ajax+".elements[x].name+'='+document."+ajax+".elements[x].value)");
		    	}
		    	elem = 'errors';
		    	//sendf looks like "username=myusername&password=mypass"
		    	var sendf = fields.join('&');
		    	
		    	
		    	xmlhttp.open("POST", url, true);
		    	xmlhttp.onreadystatechange=xmlhttpChange;
		    	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	//	    	xmlhttp.setRequestHeader('Content-Type', 'multipart/x-www-form-urlencoded');
	
		    	
		    	xmlhttp.send(sendf);   			    
		    }
		}
}	
	function xmlhttpChange(){
		//alert(xmlhttp.status);
		if (xmlhttp.readyState==4){// if xmlhttp shows "loaded"
		  	if (xmlhttp.status==200){// if "OK"
		  		//alert(xmlhttp.responseText);	  		
		  		//eval(xmlhttp.responseText);
		  		var temp = new Array();
		  		temp = xmlhttp.responseText.split('|');
		  		
		  		//alert(temp[0]);
		  		if(temp[1]){
		  			document.getElementById(temp[0]).innerHTML= temp[1];
		  		}
		  		if(temp[2]){		  		
		  			eval(temp[2]);
		  		}
	    	}else{
	    		alert("Problem retrieving data")
	    	}
	  	}
	}	
	
	//ajax functions END __________
