var obj = document.frmservice;

function advance_search()
{
	if(document.getElementById("adv_search_content").style.display == 'none')
	{
		document.getElementById("adv_search_content").style.display="block";
	}
}
function total_local_voice(fld_id,month)
{
	var fld = document.getElementById(fld_id);
	
	var tvoiceid="total_voice"+month;
	var linid="voice_incoming"+month;
	var voutid="voice_outgoing"+month;

	total=set_zero(document.getElementById(tvoiceid).value);
	inval=set_zero(document.getElementById(linid).value);
	outval=set_zero(document.getElementById(voutid).value);
	
	check_in_out_local(fld,month);
	set_total_local();
	set_long_and_grand_total(month);
}
function check_in_out_local(fld,month)
{
	var alert_adn=(month!="")?" For the month "+month:"";
	if(total>0 && (inval+outval) > total)
	{
		alert("The addition of Qustion # 2 and Question # 3 should not exceed Question # 1"+alert_adn);
		fld.value="";
	}
}
function set_total_local()
{
	if(total==0)
	{
		document.getElementById("TotalLocalCost").innerHTML = (inval+outval);
		document.getElementById("total_local_minute").value = (inval+outval);
	}
	else
	{
		document.getElementById("TotalLocalCost").innerHTML = total;
		document.getElementById("total_local_minute").value = total;
	}
}
function set_long_and_grand_total(month)
{
	var long_canada=set_zero(document.getElementById("total_long"+month).value);
	var long_us=set_zero(document.getElementById("long_us_total"+month).value);

	document.getElementById("TotalLongCost").innerHTML = (long_canada+long_us)
	//set grand total
	var total_local=set_zero(document.getElementById("total_local_minute").value);

	document.getElementById("GrandTotalCost").innerHTML = (long_canada+long_us+total_local);
	document.getElementById("grand_total_minute").value = (long_canada+long_us+total_local);
}
function check_pattern_call(selfid, twoid, thid, parent_id, parent_name)
{
	var parent_val = document.getElementById(parent_id).value;
	var fld_seval = document.getElementById(selfid).value;
	if(fld_seval=="")
		fld_seval=0;
	var fld_twval = document.getElementById(twoid).value;
	if(fld_twval=="")
		fld_twval=0;
	var fld_thval = document.getElementById(thid).value;
	if(fld_thval=="")
		fld_thval=0;
	var tval = parseInt(fld_seval) + parseInt(fld_twval) +  parseInt(fld_thval);
	if(parent_val > 0)
	{
		if(isNaN(fld_seval))
		{
			alert("Please Provide only Integer value.");
			document.getElementById(selfid).value="";
		}
		if(tval>100 || isNaN(tval))
		{
			alert("The total of Percentage should not exceed 100.");
			document.getElementById(selfid).value="";
		}
	}
	else
	{
		alert("Please Provide an amount for "+parent_name+".");
		document.getElementById(selfid).value="";
		document.getElementById(parent_id).focus();
	}
}
function total_text_message(month)
{
	var tmsgid="total_message"+month;
	var totalmv = parseInt(document.getElementById(tmsgid).value);
	if(month=="")
	{
		if(totalmv > 0)
		{
			document.getElementById("TotalMessageCost").innerHTML = totalmv;
		}
		else
		{
			document.getElementById("TotalMessageCost").innerHTML = "";		
		}
	}
	return totalmv.toFixed(2);	
}
function total_textmessage(month)
{
	total_top=total_text_message(month);

	var inmsgid="incoming_message"+month;
	var outmsgid="outgoing_message"+month;

	var incoming_message = parseInt(document.getElementById(inmsgid).value);
	var outgoing_message = parseInt(document.getElementById(outmsgid).value);
	var alert_adn=(month!="")?" For the month "+month:"";
	var chktotal=0;
	if(incoming_message>0)
	{
		chktotal+=incoming_message;
		if(total_top<chktotal)
		{
			alert("Addition of Incoming and Outgoing text should not greater than Total text"+alert_adn);
			document.getElementById(inmsgid).value="";
		}
	}
	if(outgoing_message>0)
	{
		chktotal+=outgoing_message;
		if(total_top<chktotal)
		{
			alert("Addition of Incoming and Outgoing text should not greater than Total text"+alert_adn);
			document.getElementById(outmsgid).value="";
		}
	}
}
function total_monthly_data(val)
{
	if(val == "No" || val == "")	
		document.getElementById("data_usage").style.display="none";
	else
		document.getElementById("data_usage").style.display="block";
}
function check_integer_value(fid)
{
	var fld_val=document.getElementById(fid).value;
	if(isNaN(fld_val))
	{
		alert("Please Provide only Integer value.");
		document.getElementById(fid).value="";
	}
}
function switchMenu(obj)
{
	var el = document.getElementById(obj);
	var img_div=obj+"_img";
	if ( el.style.display != 'none' )
	{
		el.style.display = 'none';
	}
	else
	{
		el.style.display = '';
	}
	
}
function set_zero(intval)
{
	if(strTrim(intval) == "")
	{
		return 0;
	}
	else
	{
		return parseInt(intval, 10);
	}
}
function check_choice(val,inid)
{
	if(val=="incoming")
	{
		document.getElementById(inid).style.display="block";
	}
	else if(val=="outgoing" || val=="na")
	{
		document.getElementById(inid).style.display="none";
	}
}
function check_profile_form()
{
	var objform=document.frm_profile
	if(strTrim(objform.pro_email.value)=="")
	{
		alert("Please Save your Profile by providing your email ID.");
		objform.pro_email.value="";
		objform.pro_email.focus();
		return false;
	}
	if(!chkEmail(strTrim(objform.pro_email.value)))
	{
		alert("Please provide a valid email ID.");
		objform.pro_email.focus();
		return false;
	}
}
function set_budget_type(val,fld,is_parent)
{
	if(is_parent==1)
	{
		var child_fld=document.getElementById('check');
		set_budget_type("",child_fld);
	}
	else if(is_parent!="")
	{
		if(is_parent=="prepaid_budget")
		{
			document.getElementById('prepaid_budget').style.display="block";
			document.getElementById('student_budget').style.display="none";
		}
		else if(is_parent=="student_budget")
		{
			document.getElementById('student_budget').style.display="block";
			document.getElementById('prepaid_budget').style.display="none";
		}
	}
	var values=fld.options;
	var fld_length=values.length;
	for(i=0;i<fld_length;i++)
	{
		var value=values[i].value;
		if(value!="" && value!="no_fee")
		{
			document.getElementById(value).style.display="none";
		}
	}
	if(val!="")
	{
		document.getElementById(val).style.display="block";
	}
}




