$(document).ready(function(){
	
	//console.log($('body').width());
	
	$(window).resize(function () { 
		if ( $('body').width() < 1250 ) {
			$('#outsearch').hide();
		}
		if ( $('body').width() > 1250 ) {
			$('#outsearch').show();
		}
	});
	
    $(".mo_images").click(function(){
        $("#current").attr("src",$(this).attr('id'));
        return false;
    });
        $("input[name=street_ishome]").change(function(){
            if ($(this).attr("checked")==true) {
                $(this).attr('value','');
                $("input[name=street_room]").attr('disabled',true);
                return;
            }else{
                $("input[name=street_room]").attr('disabled',false);
                $(this).attr("checked",false);
                return;
            }
        });
		
	$("a.bash_h3").click(function(){
			var el = $("#"+$(this).attr('rel'));
			if( el.css('display')=='none' ){
				el.show('slow');
			}else{
				el.hide('slow');
			}
			
			return false;
		});
	
	
	if($('input[name="shipping"]').length){
		//$('input[name="shipping"]').attr('checked', 'checked');
	}
	if($('input[name="payment"]').length){
		$('input[name="payment"]').attr('checked', 'checked');
	}

    $("#send_mail_form").submit(function(){
        //jQuery('#send_mail_form').preventDoubleSubmit();
        $.post("mail_sender.php", { email: $('#reg_fr_mail').val() },
            function(data) {
                //alert("Data Loaded: " + data);
                $("#send_mail_td").html(data);

            });
        return false;
    });


    
	
});


function chng_tow(id, id2)
{
	if(document.getElementById(id).className=='off'){
		document.getElementById(id).className = 'on';
		//document.getElementById(id2).className = 'nodash';
	}else{
		document.getElementById(id).className = 'off';
		//document.getElementById(id2).className = 'dash';
	}
}

function del_from_card(tow_id)
{
	document.getElementById('del'+tow_id).checked = 'checked';
	document.getElementById('cart_quantity').submit();
	return false;
}

jQuery.fn.preventDoubleSubmit = function() {
  jQuery(this).submit(function() {
    if (this.beenSubmitted)
      return false;
    else
      this.beenSubmitted = true;
  });
};
