function str_replace ( search, replace, subject ) {	// Replace all occurrences of the search string with the replacement string
	// 
	// +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	// +   improved by: Gabriel Paderni

	if(!(replace instanceof Array)){
		replace=new Array(replace);
		if(search instanceof Array){//If search	is an array and replace	is a string, then this replacement string is used for every value of search
			while(search.length>replace.length){
				replace[replace.length]=replace[0];
			}
		}
	}

	if(!(search instanceof Array))search=new Array(search);
	while(search.length>replace.length){//If replace	has fewer values than search , then an empty string is used for the rest of replacement values
		replace[replace.length]='';
	}

	if(subject instanceof Array){//If subject is an array, then the search and replace is performed with every entry of subject , and the return value is an array as well.
		for(k in subject){
			subject[k]=str_replace(search,replace,subject[k]);
		}
		return subject;
	}

	for(var k=0; k<search.length; k++){
		var i = subject.indexOf(search[k]);
		while(i>-1){
			subject = subject.replace(search[k], replace[k]);
			i = subject.indexOf(search[k],i);
		}
	}

	return subject;

}
var flashvars = {};
var params = { };
var attributes = {allowScriptAccess:'always', wmode:'opaque'};
	swfobject.embedSWF("/include/flash/positions.swf", "positions", "242", "197", "9.0.0",flashvars, params,attributes);
//	swfobject.embedSWF("/include/flash/positions.swf", "positions", "242", "197", "9.0.0");
	$(document).ready(function(){
		//$(document).pngFix();
		// Анимация тарифов
		$("#top-banners div:not(.r-banner)").hover(function() {
			$(this).children(".description").animate({height: "125px"}, "fast");
			$(this).children(".description_title").animate({top: "35px"}, "fast");
			$(this).children(".description_text").animate({bottom: "50px"}, "fast");
			$(this).children(".description_more").animate({bottom: "7px"}, "fast");						
		}, function() {
			$(this).children(".description").animate({height: "90px"}, "fast");
			$(this).children(".description_title").animate({top: "70px"}, "fast");
			$(this).children(".description_text").animate({bottom: "15px"}, "fast");			
			$(this).children(".description_more").animate({bottom: "-30px"}, "fast");		
		});
		// Листалка отзывов
		i=2; // Первый отзыв уже на экране 
		$("#get_review").click(function() {
			// Проверки
			if(ref_txt.length<3) return false; // Если нет отзывов, или один отзыв - листать нечего
			if(ref_txt.length==i) i=1; // Дошли до конца? Начинаем с начала
			// Замена спецсимволов
			ref_txt[i] = str_replace('&quot;','"',ref_txt[i]);
			ref_txt[i] = str_replace('&laquo;','«',ref_txt[i]);
			ref_txt[i] = str_replace('&raquo;','»',ref_txt[i]);
			if(navigator.userAgent.indexOf('MSIE')!= -1) {
				// Для IE код без анимации
				$("#reviewtext").text(ref_txt[i]);
				$("#reviewimg").attr("src",ref_logo[i]);
				$("#reviewimg").attr("alt",ref_names[i]);
			} else {
					$("#reviewtext").animate({ opacity: "0" }, "slow", "", function() {
						$("#reviewtext").text(ref_txt[i-1]);
						$("#reviewtext").animate({ opacity: "1.0" }, "slow"); 
					});
					$("#reviewimg").animate({ opacity: "0" }, "slow", "", function() {
						$("#reviewimg").attr("alt",ref_names[i-1]);
						$("#reviewimg").attr("src",ref_logo[i-1]);
						$("#reviewimg").animate({ opacity: "1.0" }, "slow"); 
					});					
			}
			i++;
		});
		// Клиенты
		first = 0;
		last = 6;
		$("#clients-next").click(function(){
			if(cl_name.length-1==last) { 
				last=0;
			} else {
				last++;
			}
			//$('#logos-list').append('<li><a title="'+cl_name[last]+'" href="'+cl_url[last]+'"><img alt="'+cl_name[last]+'" src="'+cl_logo[last]+'"></a></li>');
			$('#logos-list').append('<li><img alt="'+cl_name[last]+'" src="'+cl_logo[last]+'"></li>');
			$("#clients-logos").animate({ left: "-=112px", width: "+=112px" }, "slow");
		});
		$("#clients-prev").click(function(){
			if(first==0) { 
				first=cl_name.length-1;
			} else {
				first--;
			}		
			//$('#logos-list').prepend('<li class="clients-blank-li"><a title="'+cl_name[first]+'" href="'+cl_url[first]+'"><img alt="'+cl_name[first]+'" src="'+cl_logo[first]+'"></a></li>');
			$('#logos-list').prepend('<li class="clients-blank-li"><img alt="'+cl_name[first]+'" src="'+cl_logo[first]+'"></li>');
			$('#logos-list li:first').animate({ width: "+=104px", marginLeft: "4px", marginRight: "4px" }, "slow");
		});
	});
