var xmlhttp
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
 try {
  xmlhttp = new XMLHttpRequest();
 } catch (e) {
  xmlhttp=false
 }
}
function myXMLHttpRequest() {
  var xmlhttplocal;
  try {
    xmlhttplocal= new ActiveXObject("Msxml2.XMLHTTP")
 } catch (e) {
  try {
    xmlhttplocal= new ActiveXObject("Microsoft.XMLHTTP")
  } catch (E) {
    xmlhttplocal=false;
  }
 }

if (!xmlhttplocal && typeof XMLHttpRequest!='undefined') {
 try {
  var xmlhttplocal = new XMLHttpRequest();
 } catch (e) {
  var xmlhttplocal=false;
  alert('couldn\'t create xmlhttp object');
 }
}
return(xmlhttplocal);
}
function sndRequest(vote,id_num,ip_num,content,cond) {
	var element = document.getElementById('unit_long'+id_num);
	var gallery=content;
	//new Effect.Fade(element);
    element.innerHTML = '<div id="loading" class="loading"><img src="plugin/rating/image/loading.gif" /> </div>';
    xmlhttp.open('get','plugin/rating/rpc.php?j='+vote+'&q='+id_num+'&t='+ip_num+'&c='+content);
    xmlhttp.onreadystatechange = handleResponse;
    xmlhttp.send(null);
	if(content=='meta_gallery_img' || content=='meta_gallery_cat')
		re_load(content,cond);
}
function handleResponse() {
    if(xmlhttp.readyState == 4){
		if (xmlhttp.status == 200){
        var response = xmlhttp.responseText;
        var update = new Array();
        if(response.indexOf('|') != -1) {
            update = response.split('|');
            changeText(update[0], update[1]);
        }
		else if(xmlhttp.status==404)
		{
			alert("fail");
		}
		}
    }
}

function changeText( div2show, text ) {
    // Detect Browser
    var IE = (document.all) ? 1 : 0;
    var DOM = 0; 
    if (parseInt(navigator.appVersion) >=5) {DOM=1};

    // Grab the content from the requested "div" and show it in the "container"

    if (DOM) {
        var viewer = document.getElementById(div2show)
        viewer.innerHTML=text
    }
    else if(IE) {
        document.all[div2show].innerHTML=text
    }
}
//carousel gallery slide deer rating heregle bgaa ued ene methodiig ahisglaha carouseliig ul.tei n butneern duudaj bga
function re_load(str,cond)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }
 var url;
  if(str=='meta_gallery_cat')
		url="modules/mod_show_gallery/show_cat.php"; 
	else 
		url="modules/mod_show_gallery/show_gallery.php"; 
url=url+"?q="+str;
url=url+"&condition="+cond;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
function stateChanged()
{
if (xmlhttp.readyState==4)
{
document.getElementById("calling").innerHTML=xmlhttp.responseText;
button();

}
}
function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}
function button(){
	$(function() {
		$(".slider").jCarouselLite({
			btnNext: ".next",
			btnPrev: ".prev",
			visible: 4,
			auto: 0,
			wrap: 'last',
			circular: true,
		});
		
	});	

}


