// JavaScript Document

/***********************************************
* Dynamic Ajax Content- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
function change_sredina(diva,urla) {
	//fade('test');
	document.getElementById(diva).style.opacity=0.3;
//document.getElementById(diva).innerHTML='<img src="images/loading.gif">';
//var newImage='url(images/loading.gif)';
//document.getElementById('menu_under_line').style.backgroundImage = newImage;

//document.getElementById('loader').style.display = 'block';
//document.getElementById(diva).className='loading';
load_pagea(urla)



var xmlHttpa
function load_pagea(urla)
{
xmlHttpa=GetXmlHttpObjecta()
if (xmlHttpa==null)
  {
  alert ("Browser does not support HTTP Request")
  return
  }
var urla=urla
xmlHttpa.onreadystatechange=stateChangeda
xmlHttpa.open("GET",urla,true)
xmlHttpa.send(null)
} 

function stateChangeda() 
{ 
if (xmlHttpa.readyState==4 || xmlHttpa.readyState=="complete")
 { // if "OK"
  if (xmlHttpa.status==200)
    {
	//fade('test');
 	document.getElementById(diva).innerHTML=xmlHttpa.responseText;
	
	document.getElementById(diva).style.opacity=1;
	//document.getElementById('loader').style.display = 'none';
    }
  else
    {
	//fade('test');
	document.getElementById(diva).innerHTML='E R R O R';
	document.getElementById(diva).style.opacity=1;
    //alert("Problem retrieving data:" + xmlhttp.statusText);
    }
 } 
}

function GetXmlHttpObjecta()
{
var xmlHttpa=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttpa=new XMLHttpRequest();
 }
catch (e)
 {
 // Internet Explorer
 try
  {
  xmlHttpa=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttpa=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttpa;
}


}


var last_hash="";





















		function CheckForHash(){
			if(document.location.hash && window.location.href!=last_hash){
				var HashLocationName = document.location.hash;
				URL=window.location.href;
				hash=window.location.href.split("#");
				hash=hash[1];
				HashLocationName = HashLocationName.replace("#","");
				having_containerid=hash.match("_N_");
					if (having_containerid) {
						new_hash=hash.split("_N_")
						//ajaxpage(new_hash[1], new_hash[0]);
						change_sredina(new_hash[0], new_hash[1]);
					}
					else
					//document.getElementById('Intructions').innerHTML="NE MAM container u <b>"+HashLocationName+"</b>";
					/*
					if (HashLocationName.search(/i_i/i)) {
						new_hash=HashLocationName.split("=>")
						ajaxpage(new_hash[1], new_hash[0]);
					}
					*/
				//document.getElementById(HashLocationName).style.display='block';
				//document.getElementById('Intructions').innerHTML="DIV: "+ new_hash[0]+"<br/>PAGE: "+new_hash[1]+"  ("+HashLocationName+")";
				for(var a=0; a<5; a++){
					if(HashLocationName != ('Show' +(a+1))){
						//document.getElementById('Show'+(a+1)).style.display='none';
					}
				}
			}else{
				//document.getElementById('Intructions').style.display='block';
				for(var a=0; a<5; a++){
					//document.getElementById('Show'+(a+1)).style.display='none';
				}
			}
			last_hash=window.location.href;
		}
/*
		function RenameAnchor(anchorid, anchorname){
			document.getElementById(anchorid).name = anchorname; //this renames the anchor
		}
		function RedirectLocation(anchorid, anchorname, HashName){
			RenameAnchor(anchorid, anchorname);
			document.location = HashName;
		}
*/
		var HashCheckInterval = setInterval("CheckForHash()", 500);
		//window.onload = CheckForHash;


function load_page(target_page, target_div) {
	//ajaxpage(target_page, target_div);
	document.location = "#"+target_div+"_N_"+target_page;
	return false;
}
