$(document).ready(function(){
	$('img').ifixpng();
	$('div#sidebar').ifixpng();
	
	$('.photos').lightbox();
	
	$('.floor_plans').hide();
	$('.floor_plans:first').show();
	
	$('.tab_content').hide();
	$('.tab_content:first').show();
	
	$('.contact_link:first').click(function(){
		$('#tab_content_2').hide();
		$('#tab_content_1').show();
		
		return false;
		
	});
	
	$("#rnm_logo").css("bottom",50);
	$("#rnm_logo").show();
	
	var date = new Date();
	$(".months").hide();
	if($.browser.msie)
		var element = "#month_"+(date.getYear())+""+(date.getMonth() + 1);
	else
		var element = "#month_"+(date.getYear()+1900)+""+(date.getMonth() + 1);
	
	$(element).show();
	
	$(".prev_month").click(function(){
		var date = new Date();
		var visible_element = $(".months:visible"); //date.getMonth() + 1;
		
		if($(visible_element).prev().attr("id") && $(visible_element).prev().attr("id").slice(0,5) == 'month'){
			$(".months").hide();
			$(visible_element).prev().show();
		}
		
		return false;
	});
	
	$(".next_month").click(function(){
		var date = new Date();
		var visible_element = $(".months:visible"); //date.getMonth() + 1;
		
		if($(visible_element).next().attr("id") && $(visible_element).next().attr("id").slice(0,5) == 'month'){
			$(".months").hide();
			$(visible_element).next().show();
		}
		
		return false;
	});
	
	$('.news').hide();
	$('.news:first').show();
	$('.news_link:first').hide();
	
	$('.news_link').click(function(){
		$('.news_link').show();
		$(this).hide();
		
		var element = "#news_"+$(this).attr("id").slice(10);
		
		$('.news').slideUp("fast");
		$(element).slideDown("fast");
		
		return false;
	});
	
	//$('.shop_list').hide();
	$('.shop_list:first').show();
	
	$('.shop_info').hide();
	$('.shop_info:first').show();
	
	$('.shop_link').click(function(){
		var element = "#shop_info_"+$(this).attr("id").slice(10);
		
		$('.shop_info').hide();
		$(element).show();
		
		return false;
	});
	
	$('.floor_pointer').click(function(){
		$('.floor_plans').hide();
		var element = "#floor_"+$(this).attr("id").slice(14);
		$(element).show();
		
		var element = "#shop_list_"+$(this).attr("id").slice(14);
		$('.shop_list').hide();
		$(element).show();
		
		$('.shop_info').hide();
		$(element+' > ul:first > li:first > a:first').click();
		
		return false;
	});
	
	$('#floor_pointer_1').click();
	
	$("#mdate").hide();
	$("select[name='marital_status']").change(function(){
        if($("select[name='marital_status']").attr("value") == '2')
        {
            $("#mdate").show();
        }
        else
        {
            $("#mdate").hide();
        }
    });
});

function str_replace(search, replace, subject, count) {
	var i = 0, j = 0, temp = '', repl = '', sl = 0, fl = 0,
		f = [].concat(search),
		r = [].concat(replace),
		s = subject,
		ra = r instanceof Array, sa = s instanceof Array;
	s = [].concat(s);
	if (count) {
	    this.window[count] = 0;
	}
	
	for (i=0, sl=s.length; i < sl; i++) {
		if (s[i] === '') {
		    continue;
		}
		for (j=0, fl=f.length; j < fl; j++) {
		    temp = s[i]+'';
		    repl = ra ? (r[j] !== undefined ? r[j] : '') : r[0];
		    s[i] = (temp).split(f[j]).join(repl);
		    if (count && s[i] !== temp) {
		        this.window[count] += (temp.length-s[i].length)/f[j].length;}
		}
	}
	return sa ? s : s[0];
}


function replace_chars(chars_array, sstring){
	for(cchar in chars_array){
		alert(chars_array[cchar]);
		sstring = sstring.replace(chars_array[cchar],' ');
	}
	
	return sstring;
}
