
HTTP_GET_VARS=new Array();
strGET=document.location.search.substr(1,document.location.search.length);
if(strGET!='')
    {
    gArr=strGET.split('&');
    for(i=0;i<gArr.length;++i)
        {
        v='';vArr=gArr[i].split('=');
        if(vArr.length>1){v=vArr[1];}
        HTTP_GET_VARS[unescape(vArr[0])]=unescape(v);
        }
    }

function get(v)
{
if(!HTTP_GET_VARS[v]){return 'undefined';}
return HTTP_GET_VARS[v];
}

function popup(url, title, width, height) {
window.open( url, title, "status = 1, height = "+height+", width = "+width+", resizable = 0" )
}

function toggleAddTable(id) {
var e = document.getElementById(id);
        if(e.style.display == 'block') {
            e.style.display = 'none';
        }
        else {
            e.style.display = 'block';
        }


}

function formHelpPopup(form_id, thename) {
 fenster = window.open('../../form_help_popup.php?form_id=' + form_id + '&name=' + thename, "", "width=300,height=200,status=no,scrollbars=no,resizable=no");
 fenster.focus();
}

function showErrorPopup(title, text, confirm_button) {
	Fadein('disable_div');
    document.getElementById('warning_popup').style.display = 'block';
    document.getElementById('warning_title').innerHTML = title;
    document.getElementById('warning_text').innerHTML = text;
    document.getElementById('warning_popup_confirm').innerHTML = confirm_button;
}

function showErrorPopup2(title, text, confirm_button) {
	Fadein('disable_div');
    document.getElementById('warning_popup2').style.display = 'block';
    document.getElementById('warning_title2').innerHTML = title;
    document.getElementById('warning_text2').innerHTML = text;
    document.getElementById('warning_popup_confirm2').innerHTML = confirm_button;
}


function performAction(url) {
	performeDeleteAction(url);
    hideErrorPopup();
}

function performAction2(url) {
    window.location = url;
}

function hideErrorPopup() {
	Fadeout('disable_div');
    document.getElementById('warning_popup').style.display = 'none';
}

function performeDeleteAction(url) {
    row = parseURL(url).params.row;
    $.get(url, function() { $('#tablerow' + row).hide('blind'); });
}

function hideErrorPopup2() {
	Fadeout('disable_div');
    document.getElementById('warning_popup2').style.display = 'none';
}

function numericVal(obj)   {

    var tam = obj.value.length;
    var numeric = false;

    for(var i=0;i<tam;i++)

        {
        caracter = obj.value.charCodeAt(i);

        if((caracter >= 40 && caracter <= 57) || caracter == 32)
        numeric = true;
        else

            {
            obj.value=obj.value.substring(0,tam-1);
            numericVal(obj);
        }

    }

}

// sub wizard price ranges
function addPriceRangeIndividuals() {
	document.getElementById('more_fee_ranges').innerHTML = '<tr><td><input type="text" name="age_from_1" id="age_from_1" size="2" /></td><td><input type="text" name="age_to_1" id="age_to_1" size="2" /></td><td><input type="text" name="fee1" id="fee_1" size="4" /></td></tr>';
	
}

function toggleBibRangeCategorySelects(v) {
	if(v == 'Teams') { document.getElementById('category_select_teams').style.display = 'table-row';  document.getElementById('category_select_individuals').style.display = 'none'; }	
	if(v == 'Individuals') { document.getElementById('category_select_individuals').style.display = 'table-row';  document.getElementById('category_select_teams').style.display = 'none'; }	
	if(v == '') { document.getElementById('category_select_individuals').style.display = 'none';  document.getElementById('category_select_teams').style.display = 'none'; }
}

function toggleCreateRegLimitFields() { 

	if($("input:radio[name=individuals_registration]:checked").val() == 'Yes') { $('#ind_reg_limit').fadeIn('slow'); } else { $('#ind_reg_limit').fadeOut('slow');  }
	
	if($("input:radio[name=teams_registration]:checked").val() == 'Yes') {
		 $('#team_reg_limit').fadeIn('slow'); 

		 	if($("input:radio[name=bibnr_allocation]:checked").val() == 'Yes') { $('#bibnr_team_mode').fadeIn('slow'); } else { $('#bibnr_team_mode').fadeOut('slow'); } 
		 
		 } else { 
		 
		 $('#team_reg_limit').fadeOut('slow'); $('#bibnr_team_mode').fadeOut('slow'); }
}

function toggleCreateRegEmirate() {
	if($("#event_country").val() == 218) { $('#event_emirate_tr').fadeIn('slow'); } else { $('#event_emirate_tr').fadeOut('slow');  }	
}

function toggleCreateRegStore() {
	if($("input:radio[name=extras_registration]:checked").val() == 'Yes') { 
		$('#store_open_date').val($('#event_registration_start_date').val()); 
		$('#store_closure_date').val($('#event_registration_closure_date').val()); 
		$('#store_open_date_tr').fadeIn('slow'); 
		$('#store_closure_date_tr').fadeIn('slow');
	} else {
		$('#store__date_tr').fadeOut('slow');
		$('#store_closure_date_tr').fadeOut('slow');  
	}
}

function toogleRegFeeIncOther() {
	if( $('#reg_fee_other_chkbx').attr('checked')) { $('#registration_fee_includes_other_div').fadeIn('slow'); } else { $('#registration_fee_includes_other_div').fadeOut('slow');  }	
}

function toggleCreateCCTimed() {
	
	if($('#timing').val() != '' && $('#timing').val() != 'Self Timing') { $('#time_certificates_tr').fadeIn('slow');  } else { $('#time_certificates_tr').fadeOut('slow');  }
		
	if($('#timing').val() == 'Chip Timing') { $('#cc_timed_event_tr').fadeIn('slow'); $("#cc_timed_yes").attr('checked', false); $("#cc_timed_no").attr('checked', false); }  else { $('#cc_timed_event_tr').fadeOut('slow'); }
	
}

function sendOffregCode(code) {
	 $('#send_code_table').fadeIn('slow');
	 $('#send_code').html(code);	
	 $('#input_code').val(code);	
}
