
	function next_page(obj)
				{
				var i=obj.attr("rel");
				
				var mar=(i-1)*(-900);
				
				$("#slider").animate({marginLeft: mar+"px"},1000);
				
				$("#paginator .active").removeClass("active");
				obj.addClass("active");
				
				return false;
				}


function load_portfolio(obj,h)
	{
	var adr=obj.attr("href");
	
	//$("#portfolio .wrap").animate({pacity:0},500);
	$('#portfolio').animate({height:h+'px'},500,function(){
	
				$("#portfolio .wrap").css({opacity : 0});
				
				$.get(adr , {"no_header" : "true"} , function(data){
					$("#portfolio").html(data);
					$("#portfolio .wrap").animate({opacity:1},900)
					$.scrollTo($("#portfolio"), 500 );
					})
				
				
				}) ; 
				
	
	return false;
	}


function load_page(obj)
	{
	var adr=obj.attr("href");
	

	$('#text').animate({opacity:0},500,function(){
				
				$.get(adr , {"no_header" : "true"} , function(data){
					$("#text").html(data);
					
					$("#text").animate({opacity:1},300)
					$.scrollTo($("#content"), 500 );
					show_services()
					})
				
				}) ; 
	
	
	
	return false;
	}





function show_services()
	{
	$(".one_service").each(function(){
				var obj=$(this);
				var h = obj.height();
				
				obj.height(150);
				
				
				$(this).children(".service").click(function(){
								
								if (!obj.hasClass("expanded"))
									{
									$(this).animate({color:"#FFCC00"},500);
									$(".expanded").animate({height:"150px" , color:"#666666"},500).removeClass("expanded").children(".service").animate({color:"#FFFFFF"},500);
									
									obj.animate({height:h , color:"#FFFFFF"},500,function(){
											$.scrollTo( obj, 500 )
											obj.addClass("expanded");
											});
									
									}
								else 
									{
									$(this).animate({color:"#FFFFFF"},500);
									obj.animate({height:"150px" ,color :"#666666"},500,function(){
											obj.removeClass("expanded");
											})
									}
								return false;
								
								})
				})
	}





function send_form()
	{
	var options = { 
        success: showResponse  
    	}; 
 

    $('#contact form').ajaxSubmit(options); 
 	
	}

function send_form2()
	{
	var options = { 
        success: showResponse2  
    	}; 
 

    $('#popup1 form').ajaxSubmit(options); 
 	
	}

function showResponse2(responseText, statusText, xhr, $form)  {
	
	
	if (responseText==1) 
	{
		
		var message = "Thank you. You will recive shortly an answer.";
		
	    $("#modal2").fadeOut("slow");
	
	    setTimeout(function()
        {
			
			$("#modal2").fadeOut("slow");$("#popup1").fadeOut("slow");
			
			$('#fade , .popup_block').fadeOut(function() {
			$('#fade, a.close').remove();  
	}); //fade them both out
					},4000);
			
			
			
	} 
		
		else if(responseText==3) {var message = "Error. Please check progress"; }
		
		else if(responseText==4) {var message = "Error. Please check Top"; }
		
		else {var message = "Error. Please complete all the fields"; }
		
	
	var h=getPageHeight() /2 -50
	$("#modal2").show("explode",{pieces: 16 },500);
	$("#msg2").text(message);
	$("#modal2").animate({top: h + "px"},1000)
	

	
	
	
}

function showResponse(responseText, statusText, xhr, $form)  { 
	var h=getPageHeight() /2 -50
	
	$("#msg").text(responseText);
	$("#modal").animate({top: h + "px"},1000)

}





function change_thumb(obj)
	{
	var adr=obj.attr('src');
	adr=adr.replace("/thumb","");
	
	$("#main_photo").attr({src : adr});
	}




$(document).ready(function(){
   
   var l=getPageWidth() /2 -120;
   var h=getPageHeight() /2 -50
   
   $("#modal").css({left: l +"px" , top:"-200px"});
  
   $("a[rel=close]").click(function(){
				var pid=$(this).parent("div").attr("id");
				var t=$("#"+pid).css("top");
				
				t=t.replace("px","");
				x=t*1 + 20 ;
				
				$("#"+pid).animate({top: x + "px"},200).animate({top: "-400px"},1400);
				return false;
				})

  var poz1=getPageWidth() /2 - 655;
  var poz2=getPageWidth() /2 + 510;
  
  $("#word_1").css({"left" : poz1})
  $("#word_2").css({"left" : poz2})
  
  })




function getPageWidth() 
{
	var windowWidth;

	if( self.innerWidth )
		windowWidth = self.innerWidth;

	else if( document.documentElement && document.documentElement.clientWidth )
		windowWidth = document.documentElement.clientWidth;

	else if( document.body )
		windowWidth = document.body.clientWidth;

	return windowWidth;
}


function getPageHeight() 
{
	var windowHeight;

	if( self.innerHeight )
		windowHeight = self.innerHeight;

	else if( document.documentElement && document.documentElement.clientHeight )
		windowHeight = document.documentElement.clientHeight;

	else if( document.body )
		windowHeight = document.body.clientHeight;

	return windowHeight;
}


