var drag = false;
jQuery.noConflict();
jQuery(function($){

	
$('#hero>#gallery').cycle({
					timeout:4000,
					height:       'auto', // container height
					delay:3000
					});
if(drag)
{
$( "#gallery-map li,.personalbox" ).draggable({
	   stop: function(event, ui) {
	   var Stoppos = $(this).position();
	   
		alert("top:"+Stoppos.top + "px;" + "left:"+Stoppos.left+"px;");
	   }
	});
}
	

/*  menu */
	 var config = {    
         sensitivity: 4,
         interval: 100, 
         over: down,   
         out: up    
         };
    
    function down() {
    //alert('down');
        $('ul',this).slideDown(250,'linear');
    }
    
    function up() {
        $('ul',this).slideUp(250,'linear');
    }
 
    $(".primary li").hoverIntent(config);


	var liH = $('.primary .sub-menu li').css('line-height');
	
    $('.primary .sub-menu').each(function(idx, item) {  
        var h = $(item).children().length;
        $(item).css("height",h*(parseInt(liH)+1));
    });
    
    $(".primary .sub-menu").each(function() { // Loop through all the menu items that got submenu items
    var Widest=0; // We want to find the widest LI... start at zero
    var ThisWidth=0; // Initiate the temporary width variable (it will hold the width as an integer)

    $($(this).children()).each(function() { // Loop through all the children LIs in order to find the widest
      ThisWidth=parseInt($(this).css('width')); // Grab the width of the current LI

      if (ThisWidth>Widest) { // Is this LI the widest?
        Widest=ThisWidth; // We got a new widest value
      }
    });

    Widest+='px'; // Add the unit

    //$(this).parent().css('width',Widest);
    $(this).children().css('width',Widest);
  });
	
	$(".thumbnails li a").stop().animate({"opacity": ".6"}, 0);
	$(".thumbnails li a").hover(
	function() {
	$(this).stop().animate({"opacity": "1"}, "slow");
	},
	function() {
	$(this).stop().animate({"opacity": ".6"}, "slow");
	});
	
	
	$('.default-value').each(function() {
	   var default_value = this.value;

	   $(this).focus(function(){
			   if(this.value == default_value) {
					   this.value = '';
			   }
	   });

	   $(this).blur(function(){
			   if(this.value == '') {
					   this.value = default_value;
			   }
	   });
	});
	
	$('form.wp-cart-button-form').submit(function(event){
		//event.preventDefault();
		//alert("heynow");
		var personal =$("input[name$=personal]").val();
		
		if ($('.personalbox').is(':visible')) {
			var ser = $(this).serialize();
			if(personal != "Enter text here"){
			var name = $("input[name$=product]",this).val();
			//$(this).attr("name",name+':To scott with love');
			$("input[name$=product]",this).val(name+" : "+personal);
			}
			$('.personalbox').fadeOut();
		}else{
			event.preventDefault();
			$('.personalbox').fadeIn();
			return false;
		}
	});
		
	
	
});

