var giftWrapedpoped;
$(document).ready(function () {

	 $(".checkboxgiftwrap").each(   
		function() {  
		if($('input', this).is(':checked')){ 
			 yesgift(this)
		}
	 }  
	 ); 
	 
	 $(".addgiftnote").click(function(e){
		$('.giftcardnote').css("top",e.pageY - 150);
		$('.giftcardnote').css("left",e.pageX - 350);
		 
		 
	 });
	 
	 $(".giftNoteRollover").hover(
      function () {
       $(this).attr("src",$(this).attr("xsrc"));

      }, 
      function () {
         $(this).attr("src",$(this).attr("bsrc"));
          
      }
    );
	 
	 
});

 

				 
					

function popupgiftnotemes(who){

	$(who).fadeIn('slow')

}

function addGiftWrap(who){
	
	if($('input', who).is(':checked')){
	 
		nogift(who);
	}
	else{
		 
		yesgift(who)

	}
}
function addgiftwrap(who){


	yesgift(giftWrapedpoped);
	showDivNearClick(who, null, null)

}
function nogift(who){
 
	$('input', who).attr('checked', false);
	$(who).parent( ).removeClass('addgiftnotebtn')
	$('.giftText', who).html(textold);
	 $(who).parent( ).removeClass('nodetails')

}

function yesgift(who){
	 
	textold = $('.giftText', who).html();
	$(who).parent( ).addClass('nodetails')
	$('input', who).attr('checked', true);
	 
	$(who).parent( ).addClass('addgiftnotebtn')
	$('.giftText', who).html('<img alt="This Item will be gift wraped" src="/images/buttons/addGift_selected.gif"/><br /><br /><u><a>Remove Gift Wrap</a></u><br /><br />');

}

function showDivNearClick(who, whoclicked, returnAdd){
	giftWrapedpoped = returnAdd;
	if($(who).css("display") == "none"){
		$(who).fadeIn('slow')
		if(whoclicked != null){
			$(who).css("left",$(whoclicked).position().left- 350);
			$(who).css("top",$(whoclicked).position().top - 50);
		}
	}else{
		$(who).fadeOut('slow')
	}

}