/*
* http://www.seatfortwo.com
* JS de Preguntas Frecuentes
* Codigo Depurado Para el Acordeon de Preguntas
* 02 de Febrero del 2010
* Armando Borge
*/
$(document).ready(function()
{
	// Individuals Behaviours For Main Sections Titles
	$jq('#accordion .mainHead').click(function(){
		if( $jq(this).next().css("display") != "block" ){
			$jq(this).next().slideDown();
			$jq(this).toggleClass("iconDown");
			$jq(this).toggleClass("iconUp");
			return false;				
		}
		else{
			$jq(this).next().slideUp();
			$jq(this).next().children("div.secondChild").slideUp();
			$jq(this).toggleClass("iconDown");
			$jq(this).toggleClass("iconUp");
			return false;
		}
	}).next().hide("normal");
	
	// Individuals Behaviours For Questions Titles
	$jq('#accordion .secondHead').click(function(){
		$jq(this).parent().children("div.secondChild").slideUp();
		if( $jq(this).next().css("display") != "block" ) 
			$jq(this).next().slideDown();
		return false;
	}).next().hide("normal");
												  
	// Show All Answers
	$jq("#showAll").click(function () { 
		$jq("#accordion .mainHead").removeClass("iconUp").removeClass("iconDown").addClass("iconUp");
		$jq(".mainChild").slideDown(500);
		$jq("#hideAll").toggle();
		$jq("#showAll").toggle();
		return false;
	});
	
	// Hide All Answers
	$jq("#hideAll").click(function () { 
		$jq("#accordion .mainHead").removeClass("iconUp").removeClass("iconDown").addClass("iconDown");
		$jq(".mainChild").slideUp(500);
		$jq(".mainChild").children("div.secondChild").slideUp();
		$jq("#showAll").toggle();
		$jq("#hideAll").toggle();
		return false;
	});
	
	$jq("#hideAll").hide();
});
/****************************************************************************************************/
/****************************************************************************************************/




/***********************************************************************/
// videos overlay code begin here
/* component Upload Photo Tips javascript */
function loaderClose(div) {
	var movie = div;
	if (movie.PercentLoaded() == 100) { $jq(".loaderIcon").hide(); clearTimeout(videotime);}
}
var currDiv;
var currLink;
function swapimageclose_pt(img) { $jq('.swap_img_pt').attr('src',img); }
function Init_faq1(div,divLink) { currDiv=div; currLink=divLink; Jabo_FAQ1.init(640,480); }
var InnerCode_faq1;
Jabo_FAQ1={
	options:{'animationSpeed':'fast', 'padding':40, 'opacity':0.60},
	init:function(){Jabo_FAQ1.open();$jq(window).scroll(function(){Jabo_FAQ1.centerPicture();});$jq(window).resize(function(){Jabo_FAQ1.centerPicture();})},
	open:function(caller){Jabo_FAQ1.buildOverlay(Jabo_FAQ1.isSet);Jabo_FAQ1.centerPicture();objectCreate();checkLoader();},
	centerPicture:function(){if($jq('div.pictureHolder_tips_'+currDiv).size()>0){var scrollPos=Jabo_FAQ1.getScroll();if($jq.browser.opera){windowHeight=window.innerHeight;windowWidth=window.innerWidth;}else{windowHeight=$jq(window).height();windowWidth=$jq(window).width();};$jq('div.pictureHolder_tips_'+currDiv).css({'top':(windowHeight/2)+scrollPos['scrollTop']-($jq('div.pictureHolder_tips_'+currDiv).height()/2),'left':(windowWidth/2)+scrollPos['scrollLeft']-($jq('div.pictureHolder_tips_'+currDiv).width()/2)});};},
	buildOverlay:function(){
		
		backgroundDiv = "<div class='prettyPhotoOverlay_tips'></div>";
		$jq('body').append(backgroundDiv);
		$jq('div.prettyPhotoOverlay_tips').css('height',$jq(document).height());
		$jq('.prettyPhotoOverlay_tips').bind('click',function(){Jabo_FAQ1.close();});
		
		InnerCode_faq1 = $jq('#'+currDiv).html();
		$jq('#'+currDiv).empty();
		
		// Basic HTML for the picture holder
		pictureHolder_tips = '<div class="pictureHolder_tips_'+currDiv+'"><div class="loaderIcon" id="loaderBg_'+currDiv+'"></div><div class="content_tips">'+InnerCode_faq1+'</div></div>';
		
		$jq('body').append(pictureHolder_tips);
		// Then fade it in
		$jq('div.prettyPhotoOverlay_tips').css('opacity',0);
		$jq('div.prettyPhotoOverlay_tips').fadeTo(Jabo_FAQ1.options['animationSpeed'],Jabo_FAQ1.options['opacity'], function(){
			$jq('div.pictureHolder_tips_'+currDiv).fadeTo(Jabo_FAQ1.options['animationSpeed'],1,function(){
				// To fix an IE bug
				$jq('div.pictureHolder_tips_'+currDiv).attr('style','left:'+$jq('div.pictureHolder_tips_'+currDiv).css('left')+';top:'+$jq('div.pictureHolder_tips_'+currDiv).css('top')+';');
			});
		});
		$jq('.loaderIcon').show();
	},
	getScroll : function(){
		scrollTop = window.pageYOffset || document.documentElement.scrollTop || 0;
		scrollLeft = window.pageXOffset || document.documentElement.scrollLeft || 0;
		return {scrollTop:scrollTop,scrollLeft:scrollLeft};
	},
	resize : function(width,height){
			
			contentHeight = parseFloat($jq('div.pictureHolder_tips_'+currDiv+' .details').height()) + parseFloat($jq('div.pictureHolder_tips_'+currDiv+' .details').css('margin-top')) + parseFloat($jq('div.pictureHolder_tips_'+currDiv+' .details').css('margin-bottom'));
			containerHeight = contentHeight + parseFloat($jq('div.pictureHolder_tips_'+currDiv+' .top').height()) + parseFloat($jq('div.pictureHolder_tips_'+currDiv+' .bottom').height());
			containerWidth = parseFloat($jq('div.pictureHolder_tips_'+currDiv+' .content_tips').css("padding-left")) + parseFloat($jq('div.pictureHolder_tips_'+currDiv+' .content_tips').css("padding-right")) + Jabo_FAQ1.options['padding'];
			
			var newWidth = width;
			var newHeight = height;
			if($jq.browser.opera) {
				windowHeight = window.innerHeight;
				windowWidth = window.innerWidth;
			}else{
				windowHeight = $jq(window).height();
				windowWidth = $jq(window).width();
			};
			
			if((containerWidth + width) > windowWidth || (containerHeight + height) > windowHeight) {
				// Get the original geometry and calculate scales
				var xscale=(width+containerWidth + 100)/windowWidth;
				var yscale=(height+containerHeight + 100)/windowHeight;
			
				// Recalculate new size with default ratio
				if (yscale>xscale){
					newWidth = Math.round(width * (1/yscale));
					newHeight = Math.round(height * (1/yscale));
				} else {
					newWidth = Math.round(width * (1/xscale));
					newHeight = Math.round(height * (1/xscale));
				};
			};
			// Get the container size, to resize the holder to the right dimensions
			containerHeight += newHeight;
			contentHeight += newHeight;
			containerWidth += newWidth;
			return {
				width:newWidth,
				height:newHeight,
				containerHeight:containerHeight,
				containerWidth:containerWidth,
				contentHeight:contentHeight
			};
		},
	close : function()
	{
		swapimageclose_pt('layouts/ng/img/prettyPhoto/btnClose.gif');
		$jq('div.pictureHolder_tips_'+currDiv).fadeTo(Jabo_FAQ1.options['animationSpeed'],0,function(){
			$jq('div.prettyPhotoOverlay_tips').fadeTo(Jabo_FAQ1.options['animationSpeed'],0,function(){
				$jq('div.prettyPhotoOverlay_tips').remove();
				$jq('div.pictureHolder_tips_'+currDiv).remove();
				
				$jq('#'+currDiv).html(InnerCode_faq1);
				
				// To fix the bug with IE select boxes
				if($jq.browser.msie && $jq.browser.version == 6){
					$jq('select').css('visibility','visible');
				};
			});
		});
		swfobject.removeSWF(currDiv+"Video");
	}
}

function swapimageTut(img,imgId) 
{  
	document.getElementById(imgId).src = img; 
}

function objectCreate () 
{
	var req = swfobject.hasFlashPlayerVersion("9.0.115");

	if ( req )
	{	
		if ((currDiv=='faq1')||(currDiv=='faq3')||(currDiv=='faq4')||(currDiv=='faq6')||(currDiv=='faq9'))
		{
			var flashvars  = { };
		
			var params     = { menu:"false", quality:"best", wmode:"transparent" ,scale:"noorder" , salign:"transparent" };
		
			var attributes = { };
		
			swfobject.embedSWF( currLink+'/'+currDiv+'.swf', currDiv+"Video", "390", "228", "6.0.0","",flashvars, params, attributes);
		}
		else
		{
			var flashvars  = { };
		
			var params     = { quality:"best", allowfullscreen:"true" ,scale:"showall" , allowscriptaccess:"always", salign:"transparent" , wmode:"transparent"};
		
			var attributes = { };
		
			swfobject.embedSWF( currLink+'/'+currDiv+'.swf', currDiv+"Video", "640", "505", "9.0.115 ",currLink+"/expressInstall.swf",flashvars, params, attributes);
		
		}
	}
}

function checkLoader () 
{
	switch(currDiv)
	{
		case 'faq1':
			var movie = window.document.faq1Video;
			break;
		case 'faq3':
			var movie = window.document.faq3Video;
			break;
		case 'faq4':
			var movie = window.document.faq4Video;
			break;
		case 'faq6':
			var movie = window.document.faq6Video;
			break;
		case 'faq8':
			var movie = window.document.faq8Video;
			break;
		case 'faq9':
			var movie = window.document.faq9Video;
			break;
		case 'faq10':
			var movie = window.document.faq10Video;
			break;
		case 'faq11':
			var movie = window.document.faq11Video;
			break;    
		case 'faq13':
			var movie = window.document.faq13Video;
			break;
		case 'faq13p':
			var movie = window.document.faq13pVideo;
			break;
		case 'faq41':
			var movie = window.document.faq41Video;
			break;
		case 'faq40':
			var movie = window.document.faq40Video;
			break;
		case 'faq44':
			var movie = window.document.faq44Video;
			break;
		case 'faq39':
			var movie = window.document.faq39Video;
			break;
		case 'faq38':
			var movie = window.document.faq38Video;
			break;
		case 'faq18':
			var movie = window.document.faq18Video;
			break;    
		case 'faq19':
			var movie = window.document.faq19Video;
			break;
		case 'faq20':
			var movie = window.document.faq20Video;
			break;    
		case 'faq20p':
			var movie = window.document.faq20pVideo;
			break;
		case 'faq21':
			var movie = window.document.faq21Video;
			break;    
		case 'faq25':
			var movie = window.document.faq25Video;
			break;
		case 'faq26':
			var movie = window.document.faq26Video;
			break;
		case 'faq27':
			var movie = window.document.faq27Video;
			break;
		case 'faq28':
			var movie = window.document.faq28Video;
			break;
		case 'faq29':
			var movie = window.document.faq29Video;
			break;
		case 'faq30':
			var movie = window.document.faq30Video;
			break;
		case 'faq51':
			var movie = window.document.faq51Video;
			break;
		case 'faq52':
			var movie = window.document.faq52Video;
			break;
		case 'faq53':
			var movie = window.document.faq53Video;
			break;
		case 'faq54':
			var movie = window.document.faq54Video;
			break;
			case 'faq56':
			var movie = window.document.faq56Video;
			break;
		case 'faq71':
			var movie = window.document.faq71Video;
			break;
	}
	var iconVar;
	try
		{
			if (movie.PercentLoaded() == 100) 
			{
				clearTimeout(iconVar);
				$jq('.loaderIcon').css('display','none');
			}
			else
			{
				iconVar=setTimeout("checkLoader()",1000);
			}
		}
	catch(err)
	{
		iconVar=setTimeout("checkLoader()",100);
	}
}

function checkFaqVideo (faqNum,faqLink)
{
	var faqVar;
	try
		{
			if ($jq('#'+faqNum).css('display') != undefined)
			{
				clearTimeout(faqVar);
				Init_faq1( faqNum, faqLink );
			}
			else
			{
				faqVar=setTimeout("checkFaqVideo('"+faqNum+"','"+faqLink+"')",1000);
			}
		}
	catch(err)
		{
			faqVar=setTimeout("checkFaqVideo(faqNum,faqLink)",100);
		}
}