$(function(){
    $('a[href*=#]').click(function() {
        if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
            var $target = $(this.hash);
            $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
            if ($target.length) {
                var targetOffset = $target.offset().top;
                $('html,body').animate({scrollTop: targetOffset}, 1000);
                return false;
            }
        }
    });
    
    if(petal){
   		$("#rose-wrp").hide();
	    if(!$.browser.msie){
	    	$("#rose-wrp").css("opacity", 0)
	    }else{
	    	$("#rose-wrp").css("width", $(document).width());
	    }
    }
   
});

(function($) {
	
	$.rose = function(obj, id){
		
		var rose = $('<img />');
		rose.attr('src', obj.file);
		rose.attr('width', obj.w);
		rose.attr('height', obj.h);
		rose.attr('id', obj.file.split("/").pop().split(".")[0]);
		rose.addClass('iepngfix');
		rose.addClass('rose');
		
		rose.css('position', 'absolute');
		if(Boolean(obj.y)){
			rose.css('top', obj.y);
		}else{
			rose.css('bottom', obj.b);
		}
		rose.css('left', obj.x);
		rose.css('z-index', 1000);
		
		if(petal){
			rose.appendTo('#rose-wrp');
		}else{
			rose.appendTo('#wrp');
		}
	};
	
	$.roses = function(){
		//
		var body_h = $('#wrp').height();
		var body_b = 50;
		
		if($.browser.msie && (parseInt($.browser.version) >= 6 && parseInt($.browser.version) < 8)){
			body_h -= 30;
			body_b += 30
		}
		
		var obj;
		if($('body').attr('id') == "about"){
			$.rose({x:30,y:body_h - 330,w:205,h:232, file:'/slobe/common/img/rose205.png'});
			$.rose({x:850,y:380,w:117,h:132, file:'/slobe/common/img/rose117.png'});
		}else if($('body').attr('id') == "index"){			
			$.rose({x:300,y:600,w:205,h:232, file:'/slobe/common/img/rose205.png'});
			$.rose({x:850,y:380,w:117,h:132, file:'/slobe/common/img/rose117.png'});
			$.rose({x:-30,y:100,w:162,h:182, file:'/slobe/common/img/rose162.png'});
			$.rose({x:580,y:1120,w:136,h:154, file:'/slobe/common/img/rose136.png'});
		}else{
			$.rose({x:220,b:body_b,w:152,h:172, file:'/slobe/common/img/rose152.png'});
			$.rose({x:850,y:380,w:117,h:132, file:'/slobe/common/img/rose117.png'});
		}
		
	}
	
	$.resetRoses = function(){
	}
	
})(jQuery);

window.onload = function(){
	$.roses();
	
	if(!petal){
		$("#rose-wrp").show();
		$("#rose-wrp").fadeTo(10000, 100)
	}
}

var petal = 0;