(function( $ ){
  // define the initialValue() function
  $.fn.initialValue = function(value) {
    if (value) {
      return this.attr('initial-value', value);
    } else {
      return this.attr('initial-value');
    }
  };
  
  $.fn.clearInput = function() {
    return this
      .focus(function(){
        if (this.value == $(this).initialValue()) {
          this.value = '';
        }
      })
      .blur(function(){
        if (this.value == '') {
          this.value = $(this).initialValue();
        }
      })
      .each(function(index, elt) {
        $(this).initialValue(this.value);
      });
  };

  // apply plugin to all inputs with class ".clear-input"
  $(function() {
    $('input.clear-input').clearInput();
  });
})( jQuery );




$(document).ready( function(){
 
 $('.tab').click(function(){
                        $(this).next().toggle('slow'); 
			if ($(this).attr("mOpen")==1) {
				$(this).css({'background-image' : 'url(/upload/m_close.png)'});
				$(this).attr("mOpen", "0");
                                
			} else {
				$(this).css({'background-image' : 'url(/upload/m_open.png)'});
				$(this).attr("mOpen", "1");
                                
			}
			return false;
	}).next().hide();


$('.tab_opened').click(function(){
                        
			if ($(this).attr("mOpen")==1) {
                                
                                $(this).next().show('slow');
                                $(this).attr("mOpen", "0");
                                $(this).css({'background-image' : 'url(/upload/m_open.png)'});
            } else {
                                
                $(this).next().hide('slow');
                                $(this).attr("mOpen", "1");
                                $(this).css({'background-image' : 'url(/upload/m_close.png)'});
            }
            return false;

	});



            if ($(window).width()<1001)          
                        {$(".two #container").css("width","1000px"); }
                        else {$(".two #container").css("width","100%");}
           



         $(window).resize(function(){
		 


        
            if ($(window).width()<1001)          
                        {$(".two #container").css("width","1000px");}
              else {$(".two #container").css("width","100%");}
            

            });



  /*----Drag picture---*/

$('.drag').hide();

$('.drag').click(function(){

             if   ($(this).attr("mDrag")!=1)
                   {
                     $(this).hide();
                   }
             else  {
                     $(this).attr("mDrag", "0");
		   }
                    } );

$('.with_big').click(function(){

			if ($(this).attr("mOpen")==0) {
                                $(this).next('.drag').hide();
                                $(this).attr("mOpen", "1");


			} else {
                                $(this).next('.drag').css('margin-left',  '-'+$(this).next('.drag').innerWidth()/2+'px');

                                $(this).next('.drag').show();
                                $(this).next('.drag').width($(this).next('.drag').children('img').width());
                                $(this).next('.drag').height($(this).next('.drag').children('img').height());


			}
			return false;
	});



});

$(function() { $('.drag').draggable({stop: function(event, ui) { $(this).attr("mDrag", "1"); }});



});






