var site_url = 'http://www.vanzarianvelope.ro/';

var xmlhttp

function getOrase(str)
{
if (str.length==0)
  {
  document.getElementById("ors_select").innerHTML="";
  return;
  }
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Your browser does not support XMLHTTP!");
  return;
  }
var url=site_url;
url=url+"?index.php&type=getCities&id="+str;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function stateChanged()
{
if (xmlhttp.readyState==4)
  {
  document.getElementById("ors_select").innerHTML=xmlhttp.responseText;
  }
}

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;
}

var xmlhttp

function getOrase1(str)
{
if (str.length==0)
  {
  document.getElementById("ors_select1").innerHTML="";
  return;
  }
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Your browser does not support XMLHTTP!");
  return;
  }
var url=site_url;
url=url+"?index.php&type=getCities1&id="+str;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged1;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function stateChanged1()
{
if (xmlhttp.readyState==4)
  {
  document.getElementById("ors_select1").innerHTML=xmlhttp.responseText;
  }
}

var xmlhttp

function promotii(codprodus, str)
{
if (str.length==0)
  {
  document.getElementById("promoajax").innerHTML="";
  return;
  }
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Your browser does not support XMLHTTP!");
  return;
  }
var url=site_url;
url=url+"?index.php&type=getPromotiiAjax&cantitate="+str;
url=url+"&codprodus="+codprodus
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged5;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function stateChanged5()
{
if (xmlhttp.readyState==4)
  {
  document.getElementById("promoajax").innerHTML=xmlhttp.responseText;
  }
}


//alte javascripturi scoase din header

//accordion initializare
$(document).ready(function() {
		$(".view-items").accordion({
			alwaysOpen: false,
			autoheight: false,
			header: 'a.expand',
			active: '.selected',
      selectedClass: 'active',
			clearStyle: true
		});
	});


//carusel - promo din home initializare
function mycarousel_initCallback(carousel)
	{
	    carousel.clip.hover(function() {
	        carousel.stopAuto();
	    }, function() {
	        carousel.startAuto();
	    });
	};
	jQuery(document).ready(function() {
	    jQuery('#slider').jcarousel({
	        auto: 3,
			scroll: 1,
	        wrap: 'last',
	        initCallback: mycarousel_initCallback
	    });
	});


//tooltip initializare
        $(function() {
        $('.item *').tooltip();
        });

//afisare ascundere cos cumparaturi
$(document).ready(function() {
	  $('#cartright1').click(function() {
		$('#content #cartbox').fadeIn("slow");
		$('#cartright').fadeOut("slow");
	    return false;
	  });
	  $('#closecart').click(function() {
		$('#cartright').fadeIn("slow");
		$('#content #cartbox').fadeOut("slow");
	    return false;
	  });
  });

  //ascundere pagina eroare dupa 4 secunde
  $(function() {
    setTimeout(function() {
        $("#errorbox").fadeOut('slow')
    }, 4000);
  });