
Shadowbox.loadSkin('classic', 'http://www.pkvelez.ba/images/shadowbox/skin'); // use the "classic" skin
Shadowbox.loadLanguage('en', 'http://www.pkvelez.ba/images/shadowbox/lang'); // use the English language
Shadowbox.loadPlayer(['flv', 'html', 'iframe', 'img', 'qt', 'swf', 'wmp'], 'http://www.pkvelez.ba/images/shadowbox/player'); // use img and qt players

window.onload = function(){
    Shadowbox.init();
};


//var originalBG = $("#linklist > li > a").css("background-color");


$("#anketa_rez").bind('click',function() {
		$("#pool").load(pageURL + 'index.php/pool/rezultati');
	});


function getAjaxRequest() {
	try {
		// will store the reference to the XMLHttpRequest object
		var xmlHttp;
		// this should work for all browsers except IE6 and older
		try
		{
			// try to create XMLHttpRequest object
			xmlHttp = new XMLHttpRequest();
		}
		catch(e)
		{
			// assume IE6 or older
			var XmlHttpVersions = new Array("MSXML2.XMLHTTP.6.0",
																			"MSXML2.XMLHTTP.5.0",
																			"MSXML2.XMLHTTP.4.0",
																			"MSXML2.XMLHTTP.3.0",
																			"MSXML2.XMLHTTP",
																			"Microsoft.XMLHTTP");
			// try every prog id until one works
	 
			for (var i=0; i<XmlHttpVersions.length && !xmlHttp; i++) 
			{
				try 
				{ 
					// try to create XMLHttpRequest object
					xmlHttp = new ActiveXObject(XmlHttpVersions[i]);
				} 
				catch (e) {}
			}
		}
		// return the created object or display an error message
		if (!xmlHttp)
			alert("Error creating the XMLHttpRequest object.");
		else 
			return xmlHttp;
			
	} catch (e) {
		alert(e.toString());
	}
}


function resetRandomImage() {
try {
	ajaxRequest = getAjaxRequest();
	var ajaxDisplay = document.getElementById('gallery_slika');	
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function() {
		if(ajaxRequest.readyState == 4) {
			try {
				ajaxDisplay.innerHTML = ajaxRequest.responseText;
				setTimeout('resetRandomImage()',4000);
			} catch (e)  {
				alert(e.toString());
			}
		}			
	}
	ajaxRequest.open("GET", 'http://www.pkvelez.ba/index.php/image/galRand', true);
	ajaxRequest.send(null);
	//ajaxDisplay.innerHTML = "<div style=\"text-align:center\">Loading ... </div>";
} catch (e) {
}
}

function doAjax(controller, target) {
	try {
		ajaxRequest = getAjaxRequest();
		var ajaxDisplay = document.getElementById(target);	
		ajaxDisplay.innerHTML = '';
		ajaxRequest.onreadystatechange = function() {
			if(ajaxRequest.readyState == 4) {
				try {
					//ajaxDisplay.innerHTML = ajaxRequest.responseText;
				} catch (e)  {
					alert(e.toString());
				}
			}			
		}
		ajaxRequest.open("GET", 'http://www.pkvelez.ba/index.php/'+controller, true);
		ajaxRequest.send(null);
		ajaxDisplay.innerHTML = '<div style="text-align:center"><a target="_blanc" href="http://www.pkvelez.ba/index.php/'+controller+'">Pogledajte</a></div>';
	} catch (e) {
	}
}

function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

function votePool(response,target,poolID) {
	try {
		var ajaxRequest = getAjaxRequest();
		var ajaxDisplay = target;	
		ajaxDisplay.innerHTML = '';
		ajaxRequest.onreadystatechange = function() {
			if(ajaxRequest.readyState == 4) {
				try {
					ajaxDisplay.innerHTML = ajaxRequest.responseText;
				} catch (e)  {
					alert("Result error \n " + e.toString());
				}
			}			
		}
		ajaxRequest.open("GET", 'http://www.pkvelez.ba/index.php/pool/vote/' + response + '/' + poolID, true);
		ajaxRequest.send(null);
		ajaxDisplay.innerHTML = '<div style="text-align:center">Ucitavanje u toku ... </div>';
	} catch (e) {
		alert("Result error \n " + e.toString());
	}
}



function deleteLinkConfirm(linkID, controller) {
	try {
		ajaxRequest = getAjaxRequest();

		ajaxRequest.open("GET", '/_admin/'+ controller + '/getname/' + linkID, false);

		ajaxRequest.send(null);
		if(ajaxRequest.readyState == 4) {
			try {
				if (ajaxRequest.responseText != ' --- Link ne postoji --- ')
					return confirm("Jeste li sigurni da zelite obrisati : \n " + ajaxRequest.responseText);
				else
					return alert("Link ne postoji");
			} catch (e)  {
				alert("Error 2 \n" + e.toString());
			}
		}			
	} catch (e) {
		alert("Error 1 \n" + e.toString());
	}
}

if (document.documentElement && typeof document.documentElement.style.maxHeight=="undefined")
alert("Da bi ste korektno vidjeli sadržaj web stranice morate instalirati Internet Explorer 7+,\nMozilla Firefox 1.5+ ili neki treći savremeni web preglednik")

