$(document).ready(function()
{
    
	var div_empty;
	$('div.hide_empty').each(function(i){
		div_empty = $(this);
		div_empty.children('div.inner').each(function(i){
			var inner_html = $(this).html();
			//alert('Box '+inner_html);
			var inner_html_trimmed = inner_html.replace(/^\s+|\s+$/g, '');
			if (inner_html_trimmed == '')
			{
				div_empty.remove();
			} else {
			    div_empty.show();
			}
		});
	});
	
    /* jquery tabs */
    var snippet_tabs = $('#snippet_tabs');
    if (snippet_tabs.length > 0) {
        //snippet_tabs.children('ul').wrap('<div class="box_outer"><div class="box"></div></div>').tabs();
        snippet_tabs.children('ul').tabs();
    }
	
    $('div.box').wrap('<div class="box_outer"></div>');
    $('div.box').corner("round 7px");
    $('div.box_outer').css('padding', '1px').corner("round 7px");      
    
/*
	var div_box;
	$('div.box_outer').each(function(i){
		div_box = $(this);
		div_box.children('div.box').children('div.inner').each(function(i){
			var inner_html = $(this).html();
			//alert('Box '+inner_html);
			var inner_html_trimmed = inner_html.replace(/^\s+|\s+$/g, '');
			if (inner_html_trimmed == '')
			{
				div_box.hide();
			}
		});
	});
*/

});
function clearValue(clearInput, defaultValue)
{
    if (clearInput.value == defaultValue) clearInput.value = '';
}
function showHide (showOrHide, elementToChange) {
    if (showOrHide == 'show')
    {
        $('#'+elementToChange).show();
    }
    else
    {
        $('#'+elementToChange).hide();
    }
}

function openUrl(url)
{
	window.open(url, '_self');
}
function openUrlFromSelect(select)
{
	var url = select.options[select.options.selectedIndex].value;
	openUrl(url);
}
function submitOnChange(idForm)
{
    $('#' + idForm).submit();
}


function ccTypeSelectShowHide(selectOrValue)
{
    if (typeof(selectOrValue) == 'string') {
        var val = selectOrValue;
    } else if (selectOrValue != undefined) {
        var val = selectOrValue.options[selectOrValue.options.selectedIndex].value;
    } else {
        var val = 'rubbish';
    }

    if (
        val == 'Solo'
        || val == 'Switch'
        || val == 'American Express'
    ) {
        $('#ecom_cc_extra').show();
        if (val != 'American Express') {
            $('#ecom_cc_extra_issue').show();
        } else {
            $('#ecom_cc_extra_issue').hide();
        }
    } else {
        $('#ecom_cc_extra_issue').hide();
        $('#ecom_cc_extra').hide();
    }
}
