function str_replace(search, replace, subject, count) {
            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];
}


$(document).ready(function(){
	$("#map_burgas").hide();
	$("#map_office").hide();
		
		
	$(".js_variety img").click(function(){
		var attr_src = $(this).attr('src');
		//alert(attr_src);
		$("img.variety").attr('src', str_replace('t_', '', attr_src));
	});
	
	$(".singleNews_open h3").click(function(){
		if(!$(this).parent().parent().children(".text_hidden").is(':hidden'))
		{
			$(".text_hidden").hide('fast');
			$(".singleNews_close").addClass('singleNews_open').removeClass('singleNews_close');
		} else {
			$(".text_hidden").hide('fast');
			$(".singleNews_close").addClass('singleNews_open').removeClass('singleNews_close');
			$(this).parent().parent().children(".text_hidden").show('fast');
			$(this).parent().addClass('singleNews_close').removeClass('singleNews_open');
		}
	});
	
	$("#map_open_office").click(function(){
		$("#map_office").show();
		$("#map_burgas").hide();
		$("#map_store").hide();
	});
	
	$("#map_open_burgas").click(function(){
		$("#map_office").hide();
		$("#map_burgas").show();
		$("#map_store").hide();
	});
	
	$("#map_open_store").click(function(){
		$("#map_office").hide();
		$("#map_burgas").hide();
		$("#map_store").show();
	});
	
});
