function checkCellNumber(cellNumber){
	var regExp=/^\d{10}$/;
	if(cellNumber.search(regExp) == -1){
		alert("Please enter a valid 10 digit Mobile Number.");
		return false;
	}
	return true;
}
   
function checkRechargeAmount(offerPrice){
	var regExp=/^\d+$/;
	if(offerPrice.search(regExp) == -1 || offerPrice == '0'){
		alert("Please enter a valid Recharge Amount.");
		return false;
	}
	return true;	
	
}

function homeRechargeSubmit(element,formName,cellNumber,offerPrice){
	if(checkCellNumber(cellNumber) && checkRechargeAmount(offerPrice)){
		//document.HomeRechargeForm.submit();
                
		$(element).parents("form[name='"+formName+"']").submit();
	}
}


function rechargeBalanceCheckSubmit(paymenType){
	if((paymenType=="Option1") || (paymenType=="Option2") || (paymenType=="Option3") || (paymenType=="Option4") || (paymenType=="Option5")){

        document.paymentFlowAuthenticatedInit.submit();
    }
    else
    {
        alert("Please select one valid Payment Option and then click 'Pay'");

    }
}



function homeRechargeSubmitSpecial(element,formName,cellNumber,offerPrice,direct){
	if(checkCellNumber(cellNumber) && checkRechargeAmount(offerPrice)){
		//document.HomeRechargeForm.submit();
                if (direct==0)
                document.getElementById('direction').value='rechargeoption';
                else
                document.getElementById('direction').value='rechargedirect';
                
		$(element).parents("form[name='"+formName+"']").submit();
	}
}

function setSelectedCircleAndOperator(code,circleId,operatorId){
	  code = code.substr(0,4);
	  var operator = "";
	  var circle = "";
	  	$.ajax({
	        type: "GET",
	        url: "views/code_config.xml",
	        dataType: "xml",
	        async:false,
	        success: function(xml) {
	            $(xml).find('location').each(function(){
	                circle = $(this).attr('value');
	                $(this).find('code').each(function(){
		                	if($(this).text().indexOf(code) != -1){  
		                	$("#"+circleId).val(circle);
		                	$("#"+operatorId).val($(this).attr('operator'));
							return false;
	                   	}
	                });
	            });
	        }
	    });
}

function applyComboSkin(skin){
	 $('.'+skin).combobox({
		comboboxContainerClass: "comboboxContainer",
		comboboxValueContentContainerClass: "comboboxValueContainer",
		comboboxValueContentClass: "comboboxValueContent",
		comboboxDropDownClass: "comboboxDropDownContainer",
		comboboxDropDownButtonClass: "comboboxDropDownButton",
		comboboxDropDownItemClass: "comboboxItem",
		comboboxDropDownItemHoverClass: "comboboxItemHover",
		comboboxDropDownGroupItemHeaderClass: "comboboxGroupItemHeader",
		comboboxDropDownGroupItemContainerClass: "comboboxGroupItemContainer"
	},
	{                           
		animationType: "slide",
		width: 120                                
	 });	
}

function setOperatorAndCircle(code,circleId,operatorId){
	  code = code.substr(0,4);
	  var operator = "";
	  var circle = "";
	  	$.ajax({
	        type: "GET",
	        url: "views/code_config.xml",
	        dataType: "xml",
	        async:false,
	        success: function(xml) {
	            $(xml).find('location').each(function(){
	                circle = $(this).attr('value');
	                $(this).find('code').each(function(){
		                	if($(this).text().indexOf(code) != -1){  
		                	$("#"+circleId).val(circle);
		                	$("#"+operatorId).val($(this).attr('operator'));
							return false;
	                   	}
	                });
	            });
	        }
	    });
}
