// Multiway
/* ============================================================== mediabox */
var mdbactual = null;
var mdblast = null;
var mdbinc = 0;
var mdbitens = 0;
var mdbinterval = null;
var mdbintervaltime = 5000;
var mdbtrans = false;
var mdblinkactive = null;
$(document).ready(function(){
		if($('#mediabox').length > 0)
		{
			mdbitens = $('#mediabox ul li').size();
			for(i = 3; i>mdbitens-1 ;i--)
			{
				$('#controls ol li').eq(i).children('a').addClass('inactive');
			}
			$('#controls ol li a').click(function(obj){
					obj.preventDefault();
					if(!$(this).hasClass('inactive'))
					{
						if($(this).parents('li').index() != mdbactual && !mdbtrans )
						{
							mdbTransition($(this).parents('li').index());
						}
					}
				});
			$('#controls a.nav').click(function(obj){
					obj.preventDefault();
					if(!mdbtrans)
					{
						switch($(this).attr('id'))
						{
							case "mdbnext" : 
							mdbNext();
							break;
							case "mdbprevious" : 
							mdbPrevious();
							break;
						}
					}
				});
			mdbinterval = setInterval("mdbTransition(0)", 1000);
		}
	});
function autoChange()
{
	mdbinc < mdbitens - 1 ? mdbinc++ : mdbinc = 0;
	mdbTransition(mdbinc);
}
function mdbTransition(index)
{
	mdbinc = index;
	mdbtrans = true;
	mdbactual = $('#mediabox ul li').eq(index).css('display', 'block');
	if(mdblinkactive!=null)
	{
		mdblinkactive.removeClass('active');
	}
	mdblinkactive = $('#controls ol li').eq(index).children('a').addClass('active');
	if(mdblast!=null)
	{ 
		mdbTransitionOut();
	}
	mdbTransitionIn();
}
function mdbTransitionIn()
{
	if(mdbinterval!=null)
	{
		clearInterval(mdbinterval);
	}
	mdbactual.children('div.thumb').children('img').animate({marginTop:'0px'}, 1000, function(){
		mdbactual.children('div.info').children('h3, p').animate({marginLeft:'0px'}, 500);
		mdbactual.children('div.info').children('a.more').animate({marginLeft:'0px'}, 500, function(){
				mdblast = mdbactual;
				if(mdbitens > 1)
				{
					mdbinterval = setInterval("autoChange()", mdbintervaltime);
				}
				mdbtrans = false;
			});
		});
}
function mdbTransitionOut()
{
	mdblast.children('div.thumb').children('img').animate({marginTop:'226px'}, 950, function(){
		mdblast.children('div.info').children('h3, p, a.more').animate({marginLeft:'352px'}, 450, function(){
				mdblast.children('div.info').children('h3, p, a.more').css('marginLeft', '-352px');
				mdblast.children('div.thumb').children('img').css('marginTop', '-226px');
				if(mdblast !=null)
				{
					mdblast.css('display', 'none');
				}
				
			});
		});
}
function mdbPrevious()
{
	mdbinc > 0 ? mdbinc-- : mdbinc = mdbitens -1;
	mdbTransition(mdbinc);
}
function mdbNext()
{
	mdbinc < mdbitens-1 ? mdbinc++ : mdbinc = 0;
	mdbTransition(mdbinc);
}
/* ============================================================== mediabox */

/* ============================================================== contato */

$(document).ready(function(){
		if($('#form-content').length > 0 && $('#map-content').length > 0)
		{
			$('.page-contato .blocks a.more').click(function(obj){
					obj.preventDefault();
					switch($(this).attr('id'))
					{
						case 'showform' : 
						$.scrollTo($('#form-content'), 500);
						break;
						case 'showmap' : 
						$.scrollTo($('#map-content'), 500);
						break;
					}
				});
		}
	});

/* ============================================================== contato */

/* ============================================================== depoimentos */

$(document).ready(function(){
		if($('ul.content-wrapper.inner.testimonials').length>0)
		{
			$('ul.content-wrapper.inner.testimonials li .info a.more').click(function(obj){
				obj.preventDefault();
					$(this).parents('div').eq(0).children('div').eq(0).slideToggle();
				});
		}
	});

/* ============================================================== depoimentos */

/* ============================================================== video */

$(document).ready(function(){
		if($('a#open-video').length>0)
		{
			$('a#open-video').click(function(obj){
					//obj.preventDefault();
				});
		}
	});

/* ============================================================== video */

/* =================================== window */
function reposContent(content, useWindow)
{
	if($(content).length>0)
	{
		//var ww = $(content).parent().width();
		var ww = $(window).width();
		var w1w = $(content).width();
		//var wh = $(content).parent().height();
		var wh = $(window).height();
		var w1h = $(content).height();
		$(content).css('marginLeft', (ww / 2) - (w1w/2) + 'px');
		if(useWindow=null)
		{
		$(content).css('marginTop', (wh/2) - (w1h/2) + 'px');
		}
		else
		{
		$('#newWindow').css('marginTop', ($(document).scrollTop() + ($(window).height()/2)-($('#newWindow').height()/2))+'px');
		}
	}
}
function configureNewWindow()
{
	if($('#newWindow').length > 0)
	{
		/*$('#newWindow div.container').jScrollPane(
		{
			showArrows:false,
			autoReinitialise:true
		});*/
		reposContent('#newWindow');
	}
}
function cfOpenNewWindow(_width, _height, _class, callBack)
{
	configureNewWindow();
	if($('#newWindow').length>0)
	{
		_width != null ? $('#newWindow').css('width', (_width)+'px') : void(0);
		_height != null ? $('#newWindow').css('height', (_height)+'px') : void(0);
		_class !=null ? $('#newWindow').addClass(_class) : void(0);
		reposContent('#newWindow');
		$('#newWindow').fadeIn('slow', callBack != null ? eval(callBack) : void(0));
	}
	
}
function cfCloseNewWindow(callBack)
{
	if($('#newWindow').length>0)
	{
		$('#newWindow').fadeOut('slow', callBack !=null ? eval(callBack) : void(0));
	}
}
function cfResetNewWindow()
	{
		if($('#newWindow').length>0)
		{
			$('#newWindow').css('width', '570px');
			$('#newWindow').css('height', '330px');
			$('#newWindow').css('backgroundColor', '#ffffff');
		}
	}
$(window).scroll(function(){
		reposContent('#newWindow', 'true');
	});
$(window).resize(function(){
		reposContent('#newWindow', 'true');
	});
/* =================================== window */
var windowContent = "<!--video--><div id=\"newWindow\"><div class=\"container\"><h3>Vídeo Institucional</h3><object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\"510\" height=\"287\" id=\"video-player\" title=\"Player de Vídeo\"><param name=\"movie\" value=\"<?php bloginfo('stylesheet_directory'); ?>/objects/videoplayer.swf\" /><param name=\"quality\" value=\"high\" /><param name=\"wmode\" value=\"opaque\" /><param name=\"swfversion\" value=\"6.0.65.0\" /><param name=\"expressinstall\" value=\"<?php bloginfo('stylesheet_directory'); ?>/js/expressInstall.swf\" /><param name=\"allowfullscreen\" value=\"true\" /><param name=\"flashvars\" value=\"provider=osmf&video=http://www.multiway.net/wp-content/themes/multiway/media/multiway_02.flv\" /><!--[if !IE]>--><object type=\"application/x-shockwave-flash\" data=\"<?php bloginfo('stylesheet_directory'); ?>/objects/videoplayer.swf\" width=\"510\" height=\"287\"><!--<![endif]--><param name=\"quality\" value=\"high\" /><param name=\"wmode\" value=\"opaque\" /><param name=\"swfversion\" value=\"6.0.65.0\" /><param name=\"expressinstall\" value=\"<?php bloginfo('stylesheet_directory'); ?>/js/expressInstall.swf\" /><param name=\"allowfullscreen\" value=\"true\" /><param name=\"flashvars\" value=\"provider=osmf&video=http://www.multiway.net/wp-content/themes/multiway/media/multiway_02.flv\" /><div><h4>Content on this page requires a newer version of Adobe Flash Player.</h4><p><a href=\"http://www.adobe.com/go/getflashplayer\"><img src=\"http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif\" alt=\"Get Adobe Flash player\" width=\"112\" height=\"33\" /></a></p></div><!--[if !IE]>--></object><!--<![endif]--></object><p>Você também pode visualizar em tela cheia.<br /><a href=\"javascript:cfCloseNewWindow();\" title=\"Fechar\">Clique aqui</a> para fechar a janela.</p></div></div><!--video-->";
