$(function() {
  var tabs = $("#tabs").tabs();
  var num_tab = getVariable("tab");
  tabs.tabs('select', num_tab);
  

	// Automatically calculates the editor base path based on the _samples directory.
	// This is usefull only for these samples. A real application should use something like this:
	var oFCKeditor = new FCKeditor( 'text_quote' );
	oFCKeditor.BasePath = '/libs/fckeditor/';
	oFCKeditor.Height = 300;
	oFCKeditor.ToolbarSet = "Basic";
	//oFCKeditor.Config['CustomConfigurationsPath'] = "/main.config.js?" + ( new Date() * 1 ) ;
	oFCKeditor.ReplaceTextarea();
	
	
  $("#submit_quote").click(function(){
	
	var captcha_response = $('#recaptcha_response_field').val();
	$('input[name=captcha_response]').val(captcha_response);
	
	var captcha_response = $('#recaptcha_challenge_field').val();
	$('input[name=captcha_challenge]').val(captcha_response);
	
    var tabs = $('#tabs').tabs();
    var selected = tabs.tabs('option', 'selected'); // => 0
	switch (selected)
	{
	  case 0:
		document.getElementById('form_quote').submit();
		break;
	  case 1:
		document.getElementById('form_file').submit();
		break;
	  case 2:
		document.getElementById('form_video').submit();
		break;
	};
  });  	
  
});


// get GET-variable
function getVariable(varName){
    var arg=location.search.substring(1).split('&')
    var variable=""
    var i
    for(i=0;i<arg.length;i++){
            if(arg[i].split('=')[0]==varName){
                    if(arg[i].split('=').length>1){
                            variable=arg[i].split('=')[1]
                    }
                    return variable
            }
    }
    return ""
};

