/*----------------------------------------------*/
/*				Ghrs Waiting Page  				*/
/*----------------------------------------------*/

var ghrs_wait_img;

/* Function that display the waiting page usually called when button "Find" is pressed */
function ghrs_displayWaitingPage(random){
	
	var page_html = document.getElementsByTagName("html")[0];
	var page_body = document.getElementsByTagName("body")[0];
	ghrs_setAttribute(page_html, "class", "wait_page_html");
	ghrs_setAttribute(page_body, "class", "wait_page_body"); 
	
	
	// If the browser is Explorer 6 we must show the iframe.
	if(ghrs_isExplorer6()){ 
		if(!document.getElementById('iframe_wait_page_filler')){
			attributes = { 'id':'iframe_wait_page_filler', 'name':'iframe_wait_page_filler', 'src':'.' };
			var iframe = ghrs_createElementWithAttribute('iframe',attributes,null);
			document.getElementsByTagName("body")[0].appendChild(iframe);
			self.frames['iframe_wait_page_filler'].document.write(""); 
			self.frames['iframe_wait_page_filler'].document.close();
		}
		var wait_ifr = document.getElementById('iframe_wait_page_filler');
		wait_ifr.style.position="absolute";
		wait_ifr.style.height = window.document.body.scrollHeight + "px";
		wait_ifr.style.width = getWidth() + "px";
		wait_ifr.style.left="0";
		wait_ifr.style.right="0";
		wait_ifr.style.top="0";
		wait_ifr.style.bottom="0";
		wait_ifr.style.margin="0";
		wait_ifr.style.background="white";
		wait_ifr.style.display='';
		wait_ifr.style.textAlign='center';
	}
	// Setting the code and displaing the waiting page.
	if(!document.getElementById('wait_page_filler')){
		attributes = { 'id':'wait_page_filler' };
		var div = ghrs_createElementWithAttribute('div',attributes,null);
		document.getElementsByTagName("body")[0].appendChild(div);
	}
	var wait_div = document.getElementById('wait_page_filler');
	ghrs_insertDivCode(wait_div,random);
	wait_div.style.position="fixed";
	if(ghrs_isExplorer6()){
		wait_div.style.position="absolute";
		wait_div.style.height = document.body.clientHeight + "px";
		wait_div.style.width = document.body.clientWidth + "px";
	}
	else{
		wait_div.style.height="100%";
		wait_div.style.width="100%";
	}
	wait_div.style.left="0";
	wait_div.style.right="0";
	wait_div.style.top="0";
	wait_div.style.bottom="0";
	wait_div.style.margin="0";
	wait_div.style.background="white";
	wait_div.style.display='';
	wait_div.style.textAlignt='center';
	if(ghrs_isExplorer6()){
		ghrs_wait_img = document.getElementById("wait_page_img_id");
		ghrs_wait_img.style.top = "30%"; 
		wait_ifr.style.zIndex = 200
		wait_div.style.zIndex = wait_ifr.style.zIndex + 1;
	}
	else wait_div.style.zIndex = 200;
}

function ghrs_displayWaitingPageWithRedirect(random, url){
	ghrs_displayWaitingPage(random);
	if(url!='') location.href = url;
	ghrs_wait_img = document.getElementById("wait_page_img_id");
	ghrs_wait_img.src = ghrs_wait_img.src;
}


/* Function that insert the code in the waiting page div */
function ghrs_insertDivCode(div,random){
	if(typeof div == 'object'){
		div.appendChild(ghrs_wait_img);
	}
}

/* Function that set the class of the loading word changing its color */
var color = 1;
var reverse = false;

function ghrs_setColor(){
	if(window.frames['destination_list_' + ghrs_list_random].document.getElementById("loading_locs_elem")){
		if(color==4) reverse = true;
		if(color==0) reverse = false;
		var elem_iframe = window.frames['destination_list_' + ghrs_list_random];
		var set_color_elem = elem_iframe.document.getElementById("loading_locs_elem");
		ghrs_setAttribute(set_color_elem, "class", "color_"+color);
		var str = new String(set_color_elem.innerHTML);
		if(color!=0 && color!=4) str = "." + str + ".";
		else str = str.replace(/\./g,"");
		set_color_elem.innerHTML = str;
		if(reverse) color--;
		else color++;
	}
}

