// ################################################## //
// ===============JavaScript Document================ //
// The belo functions handles modalbox form actions //
// ========created by santrooper@gmail.com=========== //
// ################################################## //

//var owbroot = getDomain();

function submitForm(formId){
	$(document).ready(function(){
		$('#'+formId).submit();
	});
}



function changeFormDivDisplay(oType, oId){
	$(document).ready(function(){
		//alert(oId);

		var divFromRegx = /^div_from_(pin|air|sea)$/;
		var divToRegx   = /^div_to_(pin|air|sea)$/;
		
		if(oType=='from' && oId!=''){
			curRegex    = new RegExp(divFromRegx);
			$('#fromlocradid').val(oId);
		}
		else if(oType=='to' && oId!=''){
			curRegex    = new RegExp(divToRegx);
			$('#tolocradid').val(oId);
		}
		else{
			curRegex    = '';
		}
		
		//alert(curRegex);
		if(curRegex!='' && oId!=''){
			oContainerDivId = 'div_'+oType+'_container';
			oTargetDivId    = 'div_'+oType+'_'+oId;

 			//oTargetFldId    = oType+'_'+oId;
			//alert(oContainerDivId+'  '+oTargetDivId+'  '+oTargetFldId);
                        //alert(curDivId);


			$('#'+oContainerDivId+' div').each(function() {
			//$('#'+oContainerDivId).each(function() {
				 //alert("oContainerDivId : " + oContainerDivId)

                                 //curDivId  = jstrim($(this).attr('id')); (**** Not picking up jstrim ***)
                                 curDivId  = $(this).attr('id');
				 //alert(curDivId);

				 if( curRegex.test(curDivId) ){
					$('#'+curDivId).removeClass('shown_form_div');
					$('#'+curDivId).addClass('hodden_form_div');
				 }
			});
			
			$('#'+oTargetDivId).removeClass('hodden_form_div');
			$('#'+oTargetDivId).addClass('shown_form_div');
		}
		
	});
}


function changeDropOffDateDisplay(oId){
	$(document).ready(function(){
		//alert(oId);
		crVal = jstrim($('#'+oId).val());
		//alert(crVal);
		if(crVal=='1'){
			$('#div_dropoff').removeClass('shown_form_div');
			$('#div_dropoff').addClass('hodden_form_div');
		}
		else{
			$('#div_dropoff').removeClass('hodden_form_div');
			$('#div_dropoff').addClass('shown_form_div');
		}
	});
}

function changeCardDetailDisplay(oId){
	$(document).ready(function(){
		//alert(oId);
		crVal  = jstrim($('#'+oId).val());
		netVal = jstrim($('#netamtpay').val());
		//alert(crVal);
		if(crVal=='card'){
			$('#div_carddetails').removeClass('shown_form_div');
			$('#div_carddetails').addClass('hodden_form_div');
			$('#netchargefin').val(parseFloat(netVal)+parseFloat(10));
		}
		else if(crVal=='cash'){
			$('#div_carddetails').removeClass('hodden_form_div');
			$('#div_carddetails').addClass('shown_form_div');
			$('#netchargefin').val(netVal);
		}
		else{
			$('#div_carddetails').removeClass('shown_form_div');
			$('#div_carddetails').addClass('hodden_form_div');
			$('#netchargefin').val(netVal);
		}
	});
}

// ################################################## //

function togolSlideDiv(divId){
	$(document).ready(function(){
		$('#'+divId).slideToggle("slow"); 
	});
}


