var xmlHttp = null;
createXmlHttp();

var tm = null;
function blysk(objID, color) {
	if(color >= 255) {
	clearTimeout(tm);
	return;
	}
var obj = document.getElementById(objID);
var cr = 'rgb('+color+','+color+','+color+')';
obj.style.backgroundColor = cr;
color+=25;
tm = setTimeout('blysk("'+objID+'",'+color+')', 60);
}



function createXmlHttp(){
xmlHttp = null;
	try {
	    xmlHttp  = new ActiveXObject("Msxml2.XMLHTTP");
	} catch(e) {
	    try {
		xmlHttp  = new ActiveXObject("Microsoft.XMLHTTP");
	    } catch(e) {
		xmlHttp  = null;
	    }
	}

	if (!xmlHttp  && typeof XMLHttpRequest != 'undefined') {
	    xmlHttp = new XMLHttpRequest();
	}
}

function ajaxStateChange() {
	if (xmlHttp.readyState == 4) {
		if(xmlHttp.status==200) {
			tab_galeria.style.display='';
			tab_galeria.style.top = window.document.body.scrollTop;
			tab_galeria.style.left = window.document.body.offsetWidth / 2 - tab_galeria.offsetWidth / 2;
			blysk(tab_galeria.id, 105);
			gal_td.innerHTML = xmlHttp.responseText;
				
		}
	}
}

function loadXMLDoc(href) {
	try{
		if(hideTooltip) {
			hideTooltip();
		}
	}catch(e){}
gal_td.innerHTML = '<span title="Czekaj" style="background-color:#FFFF66;border:1px solid #CECEC9"> Pobieranie danych... </span>';

 if (xmlHttp) {

	 if (xmlHttp.readyState != 4 && xmlHttp.readyState != 0){
		gal_td.innerHTML = '<span title="Czekaj" style="background-color:#FFFF66;border:1px solid #CECEC9">Pobieranie danych</span>';
	 return;
	 }

	try {
		if(href.substr(0,7) == 'http://') {
			path = href.substr(7);
			if (window.document.URL.substr(0, 11).toLowerCase() == 'http://www.') {
			path = 'http://www.' + path;
			}else{
			path = 'http://' + path;
			}
		} else {
			path = href;
		}

		xmlHttp.open('GET', path, true);
	     	xmlHttp.onreadystatechange = ajaxStateChange;
	     	xmlHttp.send(null);


	} catch(e) {

		gal_td = document.getElementById("gal_td");
		gal_td.innerHTML = '<span title="Błąd - XMLHTTP.readyState.2" style="background-color:#FF3333;border:1px solid #CECEC9"> Błąd  </span>';
		return;
	}
 
 }else{
	gal_td = document.getElementById("gal_td");
	gal_td.innerHTML = '<span title="Błąd - XMLHTTP.readyState" style="background-color:#FF3333;border:1px solid #CECEC9">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>';
	return;
 }
}


function ajaxGaleriaStart(objID, href) {		
loadXMLDoc(href);
}