// -------------------------------------------------------
// Браузер
// -------------------------------------------------------

//Firefox detector 2/3 by DoctorDan
FF=/a/[-1]=='a'
//Firefox 3
FF3=(function x(){})[-5]=='x'
//Firefox 2
FF2=(function x(){})[-6]=='x'
//IE
IE='\v'=='v'
//Safari
Saf=/a/.__proto__=='//'
//Chrome
Chr=/source/.test((/a/.toString+''))
//Opera
Op=/^function \(/.test([].sort)

// -------------------------------------------------------
// Утилитарные функции
// -------------------------------------------------------

function win_open(url,w,h)		
{
	window.open(url,'','directories=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no,width='+w+',height='+h+',left='+(screen.availWidth-w)/2+',top='+(screen.availHeight-h)/2);
}

function change_class(id,class_name)
{
	document.getElementById(id).className=class_name;
}
function change_display(id)
{
	if(document.getElementById(id).style.display == 'block') 
		document.getElementById(id).style.display = 'none';
	else document.getElementById(id).style.display = 'block';
}
function change_position(id)
{
	if(document.getElementById(id).style.position == 'relative') 
		document.getElementById(id).style.position = 'static';
	else document.getElementById(id).style.position = 'relative';
}
function isNum(e)
{
	var str = document.getElementById(e).value;
	var reg=/^([0-9]{1,9999})$|^([0-9]{1,9999}[\.,]{1}[0-9]{1,9999})$/;
	var result=reg.test(str);
	if(result) 
	{
		if(str != 0) return true;
		else return false;
	}
}
function getCookie(name)
{
    var p = name + "="
    var si = document.cookie.indexOf(p)
    if(si == -1) return null
    var ei = document.cookie.indexOf(";", si + p.length)
    if(ei == -1) ei = document.cookie.length
    return unescape(document.cookie.substring(si + p.length, ei))
}

$(document).ready(function() {

	$('.show_text').click(function(){
		var id = $(this).attr('el');
		$("#announce_"+id).css('display','none');
		$("#full_"+id).css('display','block');
		$(this).css('display','none');
		$('#hide_'+id).css('display','inline');
	});
	$('.hide_text').click(function(){
		var id = $(this).attr('el');
		$("#announce_"+id).css('display','block');
		$("#full_"+id).css('display','none');
		$(this).css('display','none');
		$('#show_'+id).css('display','inline');
	});
});

// -----------------------------------------------------
// functions
// -----------------------------------------------------

function moveImageLeft(section)
{
	var tvar = 0;
	$(".cont_preview").each(function(i){
		ids[tvar] = $(this).attr("id");
		tvar++;
	});
	
	$(".cont_preview").each(function(i){
		var did = $(this).attr("id");
		
		var el_class = $(this).attr("class");
		
		var reg=/cont_preview_over2/;
		var result=reg.test(el_class);
		
		if(result)
		{
			if($('#'+ids[i-1]).attr('class')!=undefined)
			{
				$(".cont_preview_over2").each(function(i){
				  	$(this).addClass("cont_preview");
		   			$(this).removeClass("cont_preview_over2");
				});
				
		   		$(".cont_preview").each(function(i){
				  	$(this).removeClass("cont_preview_over2");
				});

		    	$('#'+ids[i-1]).addClass("cont_preview_over2");
		    	
		    	$.ajax({
					  type: "POST",
					  url: "/include/common/ajax/modules/getImages.php",
					  data: "page_module="+section+"&lang={/literal}{$SITE_LANG.type}{literal}&image_file="+$('#'+ids[i-1]+' a').attr('value'),
					  success: function(msg){
					  	$("#slider_income").html(msg);
					  }
				});
			}
			return false;
		}
	});
}

function moveImageRight(section)
{
	var tvar = 0;
	$(".cont_preview").each(function(i){
		ids[tvar] = $(this).attr("id");
		tvar++;
	});
	
	$(".cont_preview").each(function(i){
		var did = $(this).attr("id");
		
		var el_class = $(this).attr("class");
		
		var reg=/cont_preview_over2/;
		var result=reg.test(el_class);
		
		if(result)
		{
			if($('#'+ids[i+1]).attr('class')!=undefined)
			{
				$(".cont_preview_over2").each(function(i){
				  	$(this).addClass("cont_preview");
		   			$(this).removeClass("cont_preview_over2");
				});
				
		   		$(".cont_preview").each(function(i){
				  	$(this).removeClass("cont_preview_over2");
				});

		    	$('#'+ids[i+1]).addClass("cont_preview_over2");
		    	
		    	$.ajax({
					  type: "POST",
					  url: "/include/common/ajax/modules/getImages.php",
					  data: "page_module="+section+"&lang={/literal}{$SITE_LANG.type}{literal}&image_file="+$('#'+ids[i+1]+' a').attr('value'),
					  success: function(msg){
					  	$("#slider_income").html(msg);
					  }
				});
			}
			return false;
		}
	});
}
