$(document).ready(function()
{                            
	
    $('div.video a').fancyZoom();

// var s1 = new swfobject("/swf/player-viral.swf","ply","500","400","9","#FFFFFF");
//		var s1 = new SWFObject("/swf/player-viral.swf","ply","500","400","9","#FFFFFF");
/*		s1.addParam("allowfullscreen","true");
		s1.addParam("allownetworking","all");
		s1.addParam("allowscriptaccess","always");
		s1.addParam("flashvars","file=/flv/video.flv&image=/img/r_img.jpg");
		s1.write("show_video");*/
//		var so = new SWFObject("/swf/player-viral.swf", "vid","500","400","9", "#FFFFFF");
//		alert(so);   
		
	swfobject.embedSWF("/swf/player-viral.swf","video_container", "500", "400", "9", "", {file: "/flv/video.flv", image: "/img/r_img.jpg"});
	
	
	
	//if (!$.noCloneEvent)
	//{
	$("#contact_button").click(function(event)
	{
	   window.location = '/contacts' 
	}); 

   // }             
	
	$('a.submit').click(function(event)
	{
		var form = $(this).attr('rel'); 
		
  		if (checkForm(form))
		{
			$("#"+form).submit();       
		}
		else
		{
			alert('Для отправки заполните поля');
		}
		event.preventDefault();  
	}); 
               
	$('#gallery_next').click(function(event)
	{
		var thumbs = $('li.thumbs:visible');
		var first =  $(thumbs[0]);
		var last = $(thumbs[thumbs.length-1]);

		if (last.next() && last.next().is(':hidden'))
		{
			first.hide();
			last.next().show();
		}

		event.preventDefault(); 
	});     


	$('#gallery_prev').click(function(event)
	{
		var thumbs = $('li.thumbs:visible');
		var first =  $(thumbs[0]);
		var last = $(thumbs[thumbs.length-1]);

		if (first.prev() && first.prev().is(':hidden'))
		{
			last.hide();
			first.prev().show();
		}

		event.preventDefault(); 
	}); 


	moveHeader();    

	$(window).bind('resize', function() 
	{          
		moveHeader();
	});


});        
                

function checkForm(id)
{        
	var checker = eval("formForCheck." + id);
	if(checker)
	{
		return checker();
	}  
	else
	{
		return true;
	}
}


var formForCheck =
{
	message_form:function()
	{
		return $("#message_title").attr('value') != ""  && $("#message_body").attr('value') != ""
	}
};


function moveHeader()
{
	var width = $(window).width();
	var offset = "-120";
    if (width < 1050)
    {
    	offset = "-250"
	}                
	else if (width < 1300)
	{
		offset = "-160"
	}                   
	else if (width < 1500)
	{
		offset = "-90"
	}               
	else if (width < 1601)
	{
		offset = "0"
	}
                            
	//alert(offset + "px 0px");
  	$('#header').css({backgroundPosition:  offset + "px 0px"});	
}
