// JavaScript Document

    var catL1no=0;
    function setFrameSrc(url)
     {
      document.getElementById('loadFrame').src=url;
     }
    
    var newwindow = '';
    
    function addToCart(id)
     {
      var url='cart/changeCart.php?id='+id+'&quantity=1';
      setFrameSrc(url);
     }
    
    function openPopUp(url,width,height)
     {
      if ((!newwindow.closed) && newwindow.location) newwindow.location.href = url;
       else
        {
         newwindow=window.open(url,'name','height='+height+',width='+width+',status=no,scrollbars=yes');
         if (!newwindow.opener) newwindow.opener = self;
        }
       if (window.focus) {newwindow.focus()}
       if (newwindow.name==null) alert('Popup blocker pornit! Nu putem deschide pagina.');
       return false;
     }
    
    function getElementTop(Elem) {
            if(document.getElementById) {
                var elem = document.getElementById(Elem);
            } else if (document.all) {
                var elem = document.all[Elem];
            }
            yPos = elem.offsetTop;
            tempEl = elem.offsetParent;
            while (tempEl != null) {
                yPos += tempEl.offsetTop;
                tempEl = tempEl.offsetParent;
            }
            return yPos;
    }
    
    function restoreAdd()
        {
             document.getElementById('selectors').style.display="block";
             document.getElementById('results').style.display="none";
             parent.document.getElementById('cartBlock').style.color="#808080";
        }
    
    function focusCart()
        {
             FaT.setFocus("cartBlock", true, true);
        }
    

function addProductToCart()
 {
  if (document.getElementById('attribute_hidden'))
   var attribute=document.getElementById('attribute_hidden').value;
  else if (document.getElementById('attribute'))
   var attribute=document.getElementById('attribute').options[document.getElementById('attribute').selectedIndex].value;
  var quantity=document.getElementById('quantity').value;
  var product=document.getElementById('product').value;

  if (attribute!='')
   {
    if (quantity!='' && quantity>0)
	 {
	  var url='cart/changeCart.php?id='+product+'&aid='+attribute+'&quantity='+quantity+'&location=details';
	  setFrameSrc(url);
	 }else alert('Va rog introduceti o cantitate!');
   }else alert('Va rog alegeti un atribut!');
 }

function toggleElement(action, element)
	{
	tElement = document.getElementById(element);
	if (tElement)
	 {
 	  if (action == "show" && tElement)
	  	  tElement.style.display="block";
	  else
	 	  tElement.style.display="none";
	 }
	}

$(document).ready(function() {

	/* This is basic - uses default settings */
	var fancyOptions = new Array();
	fancyOptions = {
		'cyclic'		:	true,
		'speedIn'		:	700, 
		'speedOut'		:	200, 
		'overlayShow'	:	false,
		'transitionIn'  :	'elastic',
		'transitionOut' :	'elastic',
		'hideOnContentClick': true
	};
	
	$("a[rel=gallery]").fancybox(fancyOptions);
	$("a#single_image").fancybox(fancyOptions);
	$("div.thumbid").fancybox(fancyOptions);
});


