//here you place the ids of every element you want.
var ids=new Array('dotari','detalii','contact');

function switchid(id){	
	hideallids();
	showdiv(id);
}

function hideallids(){
	//loop through the array and hide each element by id
	for (var i=0;i<ids.length;i++){
		hidediv(ids[i]);
	}		  
}

function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showdiv(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}
jQuery(document).ready(function ($) {

$('.cs_this').change(function() {
	
	
   var sum = 0;

    $("input[type=checkbox]:checked").each(function(){
      sum += parseInt($(this).attr("rel"));
    });
    if(sum>100){
    $(this).removeAttr('checked');
	sum -= parseInt($(this).attr("rel"));
	}
    $('.response').html("Total Hours Selected<font color='red'>: "+sum+"</font> !");

 
})
function Set_Cookie( name, value, expires, path, domain, secure )
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct
expires time, the current script below will set
it for x number of days, to make it for hours,
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}

$('.shipping_options').change(function() {



var value = $("select.shipping_options option:selected").val();
var exdays = 365;

Set_Cookie( 'shipping', value, exdays, '/', '', '' );

});

jQuery('#shipping_state').change
(
  function()
  {
    var state = $(this).val();
    
    if(state != '')
    {
      $.ajax({
        'url': 'ajax.php?function=calculate_price_for_current_session&state=' + state,
        dataType: 'json',
        beforeSend: function()
        {
          
        },
        success: function(response)
        {
          if(response.code > 0)
          {
            var pr = response.data;
            
            var tax = parseFloat(pr.tax);
            
            if(tax > 0)
            {
              $('#tax_info').show();
              
              
              
              $('#span_tax').html('$' + pr.tax.toFixed(2));
              $('#span_total').html('$' + pr.total.toFixed(2));
              $('#span_shipping').html('$' + pr.shipping.toFixed(2));
            }
            else
            {
              $('#tax_info').hide();
              
              $('#span_tax').html('$' + pr.tax.toFixed(2));
              $('#span_total').html('$' + pr.total.toFixed(2));
              $('#span_shipping').html('$' + pr.shipping.toFixed(2));
            }
          }
        }
      }); 
    }
  }
);

})


function clearText(thefield){
	if (thefield.defaultValue==thefield.value) thefield.value = "";
}
function resetText(thefield){
	if (thefield.value=="") thefield.value = thefield.defaultValue;
}

function resetFormElements(oForm, sType){
	var aElems = oForm.elements;
	for (var iI=0;iI<aElems.length-3;iI++){
		if (aElems[iI].type = sType) aElems[iI].checked = false;
	}
}


