//------------------------------------
//------------------------------------
//------------------------------------
//-------CUSTOM TEMPLATE FUNCTIONS----
//------------------------------------
//------------------------------------
//------------------------------------

function initQuestions(){
	$('#question1').show();
	$('#header_title1').show();	
}


function nextQuestion(question_id,isloader){
	
	if ( question_id == 4 )
	{
		/*if (profile.age == '13')
		{
			/*if (profile.gender == 'F')
			{
				$('#result_offer').attr('href', teen_girl );
			}
			else
			{
				$('#result_offer').attr('href', teen_boy );
			}
			
			$('#result_offer').attr('href', 'http://www.javachatrooms.net/chatrooms/free-teen-chat?age=' );
		}
		else 
		{
			if (profile.gender == 'F')
			{
				if ( profile.orient == 'G' )
				{
					$('#result_offer').attr('href', lesbi_offer );
				}
				if ( profile.orient == 'S' )
				{
					$('#result_offer').attr('href', strt_female );
				}
			}
			else
			{
				if ( profile.orient == 'G')
				{
					$('#result_offer').attr('href', gay_offer );
				}
				
				if (profile.orient == 'S' && profile.age == '25' )
				{
					$('#result_offer').attr('href', straight_adult );
				}	
			}
		}
		*/
		
		if (profile.age == '13')
		{
			$('#result_offer').attr('href', 'http://www.javachatrooms.net/chatrooms/free-teen-chat?age=' );
		}
		else 
		{
			if (profile.gender == 'F')
			{
				if (profile.orient == 'S' && profile.age == '18')
				{
					$('#result_offer').attr('href', strt_female );
				}
				else
				{
					if ( profile.orient != 'G' )
					{
						$('#result_offer').attr('href', speeddate25 );
					}
				}
			}
			else
			{
				if ( profile.orient == 'G')
				{
					$('#result_offer').attr('href', gay_offer );
				}
				
				if (profile.orient == 'S' && profile.age == '25' )
				{
					$('#result_offer').attr('href', straight_adult );
				}	
			}
		}

		
		link = $('#result_offer').attr('href');
		$('#result_offer').attr('href', link + profile.age );
	}
	
	if (isloader!=undefined)
	{
	setTimeout(function(){nextQuestion(question_id+1);},1000);
	}

	fadeTransition('#question'+(question_id -1),'#question'+question_id,400);
	fadeTransition('#header_title'+(question_id -1),'#header_title'+question_id,400);
	progress(question_id);
}

//------------------------------------
//------------------------------------
//---------Common Functions-----------
//------------------------------------
//------------------------------------

function fadeTransition(from,target,time){
	$(from).fadeOut(time,function(){
		$(target).fadeIn(time);
	});
}

function checkRadio(obj){
	$(obj).parent().find('input').attr('checked', 'checked');
}

function collectAnswer(name,answer,formID){
	$(formID).prepend('<input type="hidden" value="'+answer+'" name="'+name+'"/>');
}

function progress(question_id){

	$('.survey_progress').removeClass('survey_progress'+(question_id -1));
	$('.survey_progress').addClass('survey_progress'+(question_id));
	
	}



$('document').ready(function(){

initQuestions();

$('.nav li a').mouseover(function(){
	$(this).stop().animate({
	"padding-top":"38px",
	"padding-bottom":"7px",
	"color":"#ff8e34"
	},200);
	
});

$('.nav li a').mouseout(function(){
	$(this).stop().animate({
	"padding-top":"45px",
	"padding-bottom":"0px",
	"color":"#ffffff"
	},200);
	
});


})



