function findPos(obj) {

	var curleft = curtop = 0;

	if ( obj && obj.offsetParent) {

		curleft = obj.offsetLeft

		curtop = obj.offsetTop

		while (obj = obj.offsetParent) {

			curleft += obj.offsetLeft

			curtop += obj.offsetTop

		}

	}

	return [curleft,curtop];

}



var nr_ie = 0;

var c_width = 0;

var c_height = 0;

var isOnCat = 0;







$(function()

{

	$("#searchForm1").submit(function(){

			var t = $("#searchText1");

			if( t.val() == "" ){

				alert("Introduceti cuvantul cautat");

				t.focus();

				return false;

			};

			window.location = $("#searchForm1").attr("action") + "?s=" + t.val();

			return false;

		});

	$("#prodlist").click(function(){

		var t = jQuery(this);

		if( t.hasClass("h") ){

			isOnCat = 0;

			hideMyCats();

		}

		else{

			showMyCats();

		}

		return false;

	});

	$("#prodlist").hover(

		function(){

			//do nothing...

		},

		function(){

			setTimeout("hideMyCats()", 500);

		}

	);

	//$("#lista").css("opacity", "0");

	$("#lista").hover(

		function(){

			isOnCat = 1;

		},

		function(){

			isOnCat = 0;

			hideMyCatsT();

			setTimeout("hideMyCats()", 500);

		}

	);

	

	

});



function hideMyCatsT(){

}



function hideMyCats(){

	if( isOnCat == 1 ) return ;

	

	if ($.browser.msie)

		{

			if ($.browser.version.number > 6)

				{

					$("#lista").stop().animate({"opacity": "0"}, 500, function(){  $("#lista").css("display", "none"); });

				}

				else 

				{

					$("#lista").css("display", "none");

				}

		}

		else {$("#lista").stop().animate({"opacity": "0"}, 500, function(){  $("#lista").css("display", "none"); });}

	$("#prodlist").removeClass("h");

	isOnCat = 0;

}

function showMyCats(){

	

	if ($.browser.msie)

		{

			if ($.browser.version.number > 6)

				{

					$("#lista").stop().css("display", "block").animate({"opacity": 1}, 500);

				}

				else 

				{

					$("#lista").css("display", "block");

				}

		}

		else {$("#lista").stop().css("display", "block").animate({"opacity": 1}, 500);}





	

	

	$("#prodlist").addClass("h");

}



jQuery.fn.newsletter = function(){

return this.each(function (){

	 var t = jQuery(this);

	 t.submit(function(){

		 if( checkEmailAddress( document.getElementById( $("#"+t.attr("id")+ " input[name='newsemail']:first" ).attr("id") ), 'Y' ) == false ){

			 return false;

		 }

	 });

});

}



jQuery.fn.hint = function () {

  return this.each(function (){

    /* get jQuery version of 'this'*/

    var t = jQuery(this); 

    /* get it once since it won't change*/

    var title = t.attr('alt'); 

    /* only apply logic if the element has the attribute*/

    if (title) { 

      /* on blur, set value to title attr if text is blank*/

      t.blur(function (){

        if ($.trim(t.val()) == '') {

          t.val(title);

        }

      });

      /* on focus, set value to blank if current value */

      /* matches title attr*/

      t.focus(function (){

        if (t.val() == title) {

          t.val('');

        }

      });



      /* clear the pre-defined text when form is submitted*/

      t.parents('form:first()').submit(function(){

          if (t.val() == title) {

              t.val('');

          }

      });



      /* now change all inputs to title */

      t.blur();

    }

  });

}



$(function()

{

	$('input:text').hint();
	//$(".continut a img").css({"margin":"3px","padding":"3px","border":"2px solid #f2f2f4"});
	$(".continut a img").parent().fancybox({'overlayShow': true ,'overlayOpacity':0.9});


	$("#newsletteremail").submit(function(){

		var t = $("#searchText1");

		if( t.val() == "" ){

			alert("Introduceti cuvantul cautat");

			t.focus();

			return false;

		};

		window.location = $("#searchForm1").attr("action") + "?q=" + t.val();

		return false;

	});

	$("#searchForm2").submit(function(){

		var t = $("#searchText2");

		if( t.val() == "" ){

			alert("Introduceti cuvantul cautat");

			t.focus();

			return false;

		};

		window.location = $("#searchForm2").attr("action") + "?q=" + t.val();

		return false;

	});

	$("#arataToate").click(function(){

		var t = jQuery(this);

		if( t.hasClass("h") ){

			isOnCat = 0;

			hideMyCats();

		}

		else{

			showMyCats();

		}

		return false;

	});

	$("#arataToate").hover(

		function(){

			//do nothing...

		},

		function(){

			setTimeout("hideMyCats()", 500);

		}

	);

	if ( $.browser.msie ){

		$('input:checkbox').css('border', 'none');

		$('input:radio').css('border', 'none');

	}

});