jQuery(document).ready(function($) {
	$('.inputs').bind('focus', Function("if(this.value==this.defaultValue) this.value='';"));
	$('.inputs').bind('blur', Function("if(this.value=='') this.value=this.defaultValue; "));
	
	$('.inputs').keydown(function()
	{
			$(this).css('background-color','#FFFFFF');
			$(this).css('border-color','#A8B7BF');
	});
			
			
			
	var w = $(window).width();
	w = 1300 - w;
	i = w;
	if ( w < 0 ) { i = w * (-1); }
	if ( w > 0 ) { i = 32 - i/70; }
	if ( w < 0 ) { i = 32 + i/150; }
	$fS = i + 'px';
	$('.mainslogan').css({fontSize:$fS});	
	$(window).bind('resize', function() {
		var w = $(window).width();
		w = 1300 - w;
		i = w;
		if ( w < 0 ) { i = w * (-1); }
		if ( w > 0 ) { i = 32 - i/70; }
		if ( w < 0 ) { i = 32 + i/150; }
		$fS = i + 'px';
		$('.mainslogan').css({fontSize:$fS});
	});	
		
		
		
			
	$('#submit').click(function(){
		$ferror = 0;
		if ( $('#fname').val() == '' || $('#fname').val() == 'Ваше имя'  ) 
		{
			$('#fname').css('background-color','#FFEEEE');
			$('#fname').css('border-color','#791F56');
			$ferror = 1;
		}
		if ( $('#femail').val() == ''  || $('#femail').val() == 'Эл. почта' ) 
		{
			$('#femail').css('background-color','#FFEEEE');
			$('#femail').css('border-color','#791F56');
			$ferror = 1;
		}
		if ( $('#fquestion').val() == '' || $('#fquestion').val() == 'Сообщение' ) 
		{
			$('#fquestion').css('background-color','#FFEEEE');
			$('#fquestion').css('border-color','#791F56');
			$ferror = 1;
		}
		if ($ferror == 1)
		{
			return false;
		}
		else
		{
			$('#postform').submit();
		}
	});
	
	
	
	$('#int_link').children().click(function(){
		//$('#IntCont').animate({opacity: 0}, 700, function(){
		$('#IntCont').hide(700, function(){
				$.post("/index.php?id=16", { action:'flower'},function(data) 
				{
					//$('#IntCont').html(data).animate({opacity: 1}, 700);
					$('#IntCont').html(data).show(700);
				});
		});
		
	});
	$('#ints_link').children().click(function(){
		//$('#citecont').animate({opacity: 0}, 700, function(){
			$('#citecont').hide(700, function(){
				$.post("/index.php?id=19", { action:'flower'},function(data) 
				{
					$('#citecont').html(data);
					//$('#citecont').animate({opacity: 1}, 700);
					$('#citecont').show(700);
				});
		});
	});
	
	
	// Voting script
	$('.radio').click(function(){
		$('.radio').removeClass('active');
		$(this).addClass('active');
		$(this).children().attr('checked', true);
	});	

$('.gradientx').gradientText({
        colors: ['#2688A3', '#63A64F']
    });
    /*
$(".gradientx").pxgradient({ //произвольный селектор jQuery
   step: 10, // размер шага градиента в пикселях. Меньше шаг - больше качество, но меньше производительность
   colors: ["#2688A3","#3FA17B"], // цвета. формат - hex (#4fc05a или #333)
   dir: "x" // направление градиента. x - горизонтальное, y - вертикальное
 });
 * */
 

});



function ValidateForm()
{
	$valid = 1;
	$('input').removeClass('error_bg');
	$('textarea').removeClass('error_bg');
	$email = $('input[name$="email"]').val();
	$name = $('input[name$="name"]').val();
	$mess = $('textarea[name$="mesg"]').val();

	if ( $name == '' || $name == 'Ваше имя')	{ $('input[name$="name"]').addClass('error_bg'); $valid = 0; }
	if ( $mess == '' || $mess == 'Сообщение')	{ $('textarea[name$="mesg"]').addClass('error_bg'); $valid = 0; }
	if ( !isValidEmailAddress($email) ) { $('input[name$="email"]').addClass('error_bg'); $valid = 0; }
	if ( $valid == 1 )
	{
		//$('#eformbs').submit();
		return true;
	}
	else
	{	
		$('body').blur();
		alert('Проверьте правильность заполнения полей формы');
		return false;
		
	}
}

/* PHP Analogicus */
function strlen( mixed_var ) {   return mixed_var.length; }
// Преобразует строку в нижний регистр
function strtolower( mixed_var ) {    return mixed_var.toLowerCase();   }
// Преобразует строку в верхний регистр
function strtoupper( mixed_var ) {   return mixed_var.toUpperCase();   }
// возвращает символ находящийся на позиции pos от начала слова. Аналог $string{pos}
function letter_posion(string, position) {   return string.charAt(position);   }
// Возвращает позицию первого вхождения подстроки needle в строку haystack.
function strpos( haystack, needle, offset ) {
   if(offset) offset = offset ;
   else offset = 0 ;
   return haystack.indexOf(needle, offset);
}
// Возвращает массив строк, полученных разбиением строки string с использованием separator в качестве разделителя.
function explode(separator, string, limit) {
   return string.split (seperator , limit);
}
 /* // PHP Analogicus */

function isValidEmailAddress(emailAddress)
{
    var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
    return pattern.test(emailAddress);
}

function testKey(e)
{
  var key = (typeof e.charCode === 'undefined' ? e.keyCode : e.charCode);
  if (e.ctrlKey || e.altKey || key < 32) {return true;}
  key = String.fromCharCode(key);
  return /\w/.test(key);
}
function testFIO(e)
{
  var key = (typeof e.charCode === 'undefined' ? e.keyCode : e.charCode);
  if (e.ctrlKey || e.altKey || key < 32) {return true;}
  key = String.fromCharCode(key);
  return /^[a-zА-Яа-я]+$/i.test(key);
}
function testKeyD(e)
{
  var key = (typeof e.charCode === 'undefined' ? e.keyCode : e.charCode);
  if (e.ctrlKey || e.altKey || key < 32) {return true;}
  key = String.fromCharCode(key);
 return /[\d\.]/.test(key);
}
function testKeyTel(e)
{
  var key = (typeof e.charCode === 'undefined' ? e.keyCode : e.charCode);
  if (e.ctrlKey || e.altKey || key < 32) {  return true;}
  key = String.fromCharCode(key);
 return /[0+ .123456789 ()\-]/.test(key);
}


