// JScript File
var txt = "";
function CountryChange()
{
    var ddlCountry     = document.getElementById("ctl00_cphmain_ddlCountry");
    var DdlState       = document.getElementById("ctl00_cphmain_ddlStates");
    var tddrpState     = document.getElementById("ctl00_cphmain_tddrpState");
    var tdTextState    = document.getElementById("ctl00_cphmain_tdTextState");
    if(ddlCountry.value != "IND" && ddlCountry.value != "US" && ddlCountry.value != "CA")
    {
        tdTextState.style.display = "block";
        tddrpState.style.display = "none";
    }
    else
    {
        tdTextState.style.display = "none";
        tddrpState.style.display = "block";
    }
}
function Validate()
{
    var result = true;
    var StrMsg          = "<strong style=\"color:red;\">" + "!Oops Fields Missing" + "</strong><br /><br />";
    var txtEmailid      = GetElement("ctl00_cphmain_txtEmailID");
    var txtPwd          = GetElement("ctl00_cphmain_txtPwd");
    var txtConfirm      = GetElement("ctl00_cphmain_txtConfirmPwd");
    var txtConfirmEmail = GetElement("ctl00_cphmain_txtConfirmEmailID");
    var txtFirstName    = GetElement("ctl00_cphmain_txtFirstName");
    var txtAddr1        = GetElement("ctl00_cphmain_txtAddr1");
    var txtCity         = GetElement("ctl00_cphmain_txtCity");
    var txtZip          = GetElement("ctl00_cphmain_txtZip");
    var txtPhno         = GetElement("ctl00_cphmain_txtPhoneNo");
    var ddlState        = GetElement("ctl00_cphmain_ddlStates");
    var ddlCountry      = GetElement("ctl00_cphmain_ddlCountry");
    var chkPrivacy      = GetElement("ctl00_cphmain_chkAgree");
    var chkEmail        = GetElement("ctl00_cphmain_chkMail");
    var txtState        = GetElement("ctl00_cphmain_txtState");
    if(trimAll(txtEmailid.value).length == 0)
    {
        StrMsg += " Email ID is Empty.<br />";
        if(result == true)
        {
            txtEmailid.focus();
        }
        result = false;    
    }
    else
    {
        if(!validateEmail(trimAll(txtEmailid.value)))
        {
            StrMsg += " Valid Email ID<br />";
            if(result == true)
            {
                txtEmailid.focus();
            }
            result = false;            
        }
    }
    if(trimAll(txtConfirmEmail.value).length == 0)
    {
        StrMsg += " Confirm Email ID is Empty.<br />";
        if(result == true)
        {
            txtConfirmEmail.focus();
        }
        result = false;    
    }
    if(txtEmailid.value != txtConfirmEmail.value)
    {
        StrMsg += "Email ID and Confirm Email ID should be same.<br />";
        result = false;
    }
    if(trimAll(txtPwd.value).length == 0)
    {
        StrMsg += " Password is Empty.<br />";
        if(result == true)
        {
            txtPwd.focus();
        }
        result = false;    
    }
    else if(trimAll(txtPwd.value).length < 6)
    {
        StrMsg += " Password must be atleast 6 characters.<br />";
        if(result == true)
        {
            txtPwd.focus();
        }
        result = false;
    }
    if(trimAll(txtConfirm.value).length == 0)
    {
        StrMsg += " Confirm Password is Empty.<br />";
        if(result == true)
        {
            txtConfirm.focus();
        }
        result = false;    
    }
    if(txtPwd.value != txtConfirm.value)
    {
        StrMsg += "Password and ConfirmPassword should be same.<br />";
        result = false;
    }
    if(trimAll(txtFirstName.value).length == 0)
    {
        StrMsg += " First Name is Empty.<br />";
        if(result == true)
        {
            txtFirstName.focus();
        }
        result = false;    
    }
    if(trimAll(txtAddr1.value).length == 0)
    {
        StrMsg += " Address1 is Empty.<br />";
        if(result == true)
        {
            txtAddr1.focus();
        }
        result = false;    
    }
    if(trimAll(txtCity.value).length == 0)
    {
        StrMsg += " City is Empty.<br />";
        if(result == true)
        {
            txtCity.focus();
        }
        result = false;    
    }
    if(ddlCountry.selectedIndex == 0)
    {
        StrMsg += " Country is Empty.<br />";
        if(result == true)
        {
            ddlCountry.focus();
        }
        result = false;
    }
    if(ddlCountry.value == "IND" || ddlCountry.value == "US" || ddlCountry.value == "CA")
    {
        if(ddlState.selectedIndex == 0)
        {
            StrMsg += " State is Empty.<br />";
            if(result == true)
            {
                ddlState.focus();
            }
            result = false;
        }
    }
    else
    {
        if(trimAll(txtState.value).length == 0)
        {
            StrMsg += " State is Empty.<br />";
            if(result == true)
            {
                txtState.focus();
            }
            result = false;
        }
    }        
    if(trimAll(txtPhno.value).length == 0)
    {
        StrMsg += " Phone Number is Empty.<br />";
        if(result == true)
        {
            txtPhno.focus();
        }
        result = false;    
    }
//    else
//    {
//        if(!validatePhone(trimAll(txtPhno.value)))
//        {
//            StrMsg += " Valid Phone Number.<br />";
//            if(result == true)
//            {
//                txtPhno.focus();
//            }
//            result = false;            
//        }
//    }
    if(trimAll(txtZip.value).length == 0)
    {
        StrMsg += " Zip is Empty.<br />";
        if(result == true)
        {
            txtZip.focus();
        }
        result = false;    
    }
    if(chkPrivacy.checked == false)
    {
        StrMsg += " Please Check the Agreement.<br />";
        result = false;
    }
//    if(chkEmail.checked == false)
//    {
//        StrMsg += " Please Check the Receive Mails.<br />";
//        result = false;
//    }
    if(!result)
    {
        document.getElementById("ctl00_lblErrMsg").innerHTML = StrMsg;
        document.getElementById("ctl00_btnHidden").click();
    }
    else
    {
        document.getElementById("ctl00_cphmain_pnlUserInfo").style.display = "none";
        document.getElementById("ctl00_cphmain_pnlPackageInfo").style.display = "block";
        return false;
    }
    return result;
}
function cancelPnlPackage()
{
    document.getElementById("ctl00_cphmain_pnlUserInfo").style.display = "block";
    document.getElementById("ctl00_cphmain_pnlPackageInfo").style.display = "none";
    return false;
}
//function validatePackage()
//{
//    var result = true;
//    var StrMsg = "<strong style=\"color:red;\">" + "!Oops Fields Missing" + "</strong><br /><br />";
//    var ddlSType =  GetElement("ctl00_cphmain_rbtnSubscribeType");
//    var Count = chlCount();
//    if(Count == 0)
//    {
//        StrMsg += "Please Select atleast one channel.<br />";
//        result = false;
//    }
//    if(ddlSType.selectedIndex == 0)
//    {
//        StrMsg += "Please select the Subscription Type.<br />";
//        result = false;
//    }
//    if(!result)
//    {
//        document.getElementById("ctl00_lblErrMsg").innerHTML = StrMsg;
//        document.getElementById("ctl00_btnHidden").click();
//    }
//    return result;
//}
function validatePackage()
{
    var result = true;
    var StrMsg = "<strong style=\"color:red;\">" + "!Oops Fields Missing" + "</strong><br /><br />";
    var ddlSType =  GetElement("ctl00_cphmain_rbtnSubscribeType");
    var Count = chlCount();
    var txtEmailid      = GetElement("ctl00_cphmain_txtEmailID");
    var txtPwd          = GetElement("ctl00_cphmain_txtPwd");
    var txtConfirm      = GetElement("ctl00_cphmain_txtConfirmPwd");
    var txtConfirmEmail = GetElement("ctl00_cphmain_txtConfirmEmailID");
    var txtFirstName    = GetElement("ctl00_cphmain_txtFirstName");
    var txtAddr1        = GetElement("ctl00_cphmain_txtAddr1");
    var txtCity         = GetElement("ctl00_cphmain_txtCity");
    var txtZip          = GetElement("ctl00_cphmain_txtZip");
    var txtPhno         = GetElement("ctl00_cphmain_txtPhoneNo");
    var ddlState        = GetElement("ctl00_cphmain_ddlStates");
    var ddlCountry      = GetElement("ctl00_cphmain_ddlCountry");
    var chkPrivacy      = GetElement("ctl00_cphmain_chkAgree");
    var chkEmail        = GetElement("ctl00_cphmain_chkMail");
    var txtState        = GetElement("ctl00_cphmain_txtState");
    if(trimAll(txtEmailid.value).length == 0)
    {
        StrMsg += " Email ID is Empty.<br />";
        if(result == true)
        {
            txtEmailid.focus();
        }
        result = false;    
    }
    else
    {
        if(!validateEmail(trimAll(txtEmailid.value)))
        {
            StrMsg += " Valid Email ID<br />";
            if(result == true)
            {
                txtEmailid.focus();
            }
            result = false;            
        }
    }
    if(trimAll(txtConfirmEmail.value).length == 0)
    {
        StrMsg += " Confirm Email ID is Empty.<br />";
        if(result == true)
        {
            txtConfirmEmail.focus();
        }
        result = false;    
    }
    if(txtEmailid.value != txtConfirmEmail.value)
    {
        StrMsg += "Email ID and Confirm Email ID should be same.<br />";
        result = false;
    }
    if(trimAll(txtPwd.value).length == 0)
    {
        StrMsg += " Password is Empty.<br />";
        if(result == true)
        {
            txtPwd.focus();
        }
        result = false;    
    }
    else if(trimAll(txtPwd.value).length < 6)
    {
        StrMsg += " Password must be atleast 6 characters.<br />";
        if(result == true)
        {
            txtPwd.focus();
        }
        result = false;
    }
    if(trimAll(txtConfirm.value).length == 0)
    {
        StrMsg += " Confirm Password is Empty.<br />";
        if(result == true)
        {
            txtConfirm.focus();
        }
        result = false;    
    }
    if(txtPwd.value != txtConfirm.value)
    {
        StrMsg += "Password and ConfirmPassword should be same.<br />";
        result = false;
    }
    if(trimAll(txtFirstName.value).length == 0)
    {
        StrMsg += " First Name is Empty.<br />";
        if(result == true)
        {
            txtFirstName.focus();
        }
        result = false;    
    }
    if(trimAll(txtAddr1.value).length == 0)
    {
        StrMsg += " Address1 is Empty.<br />";
        if(result == true)
        {
            txtAddr1.focus();
        }
        result = false;    
    }
    if(trimAll(txtCity.value).length == 0)
    {
        StrMsg += " City is Empty.<br />";
        if(result == true)
        {
            txtCity.focus();
        }
        result = false;    
    }
    if(ddlCountry.selectedIndex == 0)
    {
        StrMsg += " Country is Empty.<br />";
        if(result == true)
        {
            ddlCountry.focus();
        }
        result = false;
    }
    if(ddlCountry.value == "IND" || ddlCountry.value == "US" || ddlCountry.value == "CA")
    {
        if(ddlState.selectedIndex == 0)
        {
            StrMsg += " State is Empty.<br />";
            if(result == true)
            {
                ddlState.focus();
            }
            result = false;
        }
    }
    else
    {
        if(trimAll(txtState.value).length == 0)
        {
            StrMsg += " State is Empty.<br />";
            if(result == true)
            {
                txtState.focus();
            }
            result = false;
        }
    }        
    if(trimAll(txtPhno.value).length == 0)
    {
        StrMsg += " Phone Number is Empty.<br />";
        if(result == true)
        {
            txtPhno.focus();
        }
        result = false;    
    }
//    else
//    {
//        if(!validatePhone(trimAll(txtPhno.value)))
//        {
//            StrMsg += " Valid Phone Number.<br />";
//            if(result == true)
//            {
//                txtPhno.focus();
//            }
//            result = false;            
//        }
//    }
    if(trimAll(txtZip.value).length == 0)
    {
        StrMsg += " Zip is Empty.<br />";
        if(result == true)
        {
            txtZip.focus();
        }
        result = false;    
    }
    if(chkPrivacy.checked == false)
    {
        StrMsg += " Please Check the Agreement.<br />";
        result = false;
    }
    if(document.getElementById("ctl00_cphmain_lblSubTotal") != null)
    {
        var splCount = splChlCount();
        if(Count == 0 || splCount == 0)
        {
            if(Count == 0)
            {
                StrMsg += "Please Select atleast one channel.<br />";
                result = false;
            }
        }
            if(ddlSType.selectedIndex == 0)
            {
                StrMsg += "Please select the Subscription Type.<br />";
                result = false;
            }
//        if(Count == 0 || splCount == 0)
//        {
//            StrMsg += "Please Select atleast one channel.<br />";
//            result = false;
//        }
//        if(Count > 0 && splCount == 0 && ddlSType.selectedIndex == 0 || Count == 0 && splCount == 0 && ddlSType.selectedIndex == 0)
//        {
//            StrMsg += "Please select the Subscription Type.<br />";
//            result = false;
//        }
    }
    else
    {
        if(Count == 0)
        {
            StrMsg += "Please Select atleast one channel.<br />";
            result = false;
        }
        if(ddlSType.selectedIndex == 0)
        {
            StrMsg += "Please select the Subscription Type.<br />";
            result = false;
        }
    }
    if(!result)
    {
        document.getElementById("ctl00_lblErrMsg").innerHTML = StrMsg;
        document.getElementById("ctl00_btnHidden").click();
    }
    return result;
}
function cancelPnlBilling()
{
    document.getElementById("ctl00_cphmain_hdnButton1").click();
    document.getElementById("ctl00_cphmain_hdnButton2").click();
    return false;
}
function Confirm()
{
    var result = true;
    if(document.getElementById("ctl00_cphmain_lblTotalPrice").innerHTML != "0")
    {
        return confirm("Please Return to Telugulive.com after payment to update your packages immediately.Also check your EmailAddress for Activation.");
    }
    return result;
}
function fillStates(obj,strSubStateId)
{
    var opt;
    var xmlhttp;
    var tddrpState     = document.getElementById("ctl00_cphmain_tddrpState");
    var tdTextState    = document.getElementById("ctl00_cphmain_tdTextState");
    var intSelectedIndex = document.getElementById(obj).selectedIndex;
	if (intSelectedIndex > 0)
	{
	    var code = document.getElementById(obj).options[intSelectedIndex].value;
	    if(code == "IND" || code == "US" || code == "CA")
	    {
	        tddrpState.style.display = "block";
            tdTextState.style.display = "none";
            if(-1 != navigator.userAgent.indexOf("MSIE"))
            {               
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
            else //if(-1 != navigator.userAgent.indexOf("Firefox"))
            {      
                xmlhttp = new XMLHttpRequest();
                xmlhttp.overrideMimeType('text/xml');
            }  
		    xmlhttp.open('POST','CatchEtv.aspx?Id=' + document.getElementById(obj).options[intSelectedIndex].value,false);
		    xmlhttp.send('');
		    var strSubStates = xmlhttp.responseText;
		    strSubStates = strSubStates.replace(strSubStates.substring(strSubStates.indexOf("<!DOC")-2),"");
		    var intLoopCount;
		    var arrSubStates = strSubStates.split("~");
		    var objSubStates = window.document.getElementById(strSubStateId);
		    var objLen = objSubStates.length;
		    for(intLoopCount=0;intLoopCount<=objLen;intLoopCount++)
		    {
			    objSubStates.remove(objSubStates.item(intLoopCount));
		    }
    		opt = new Option("-- Select --",'');
    		objSubStates.options.add(opt);
		    if (strSubStates.length > 0)
		    {
			    for(intLoopCount=0;intLoopCount<=arrSubStates.length-1;intLoopCount++)
			    {
				    var arrIdNames = (arrSubStates[intLoopCount]).split('|');
				    opt = new Option(arrIdNames[0],arrIdNames[1]);
				    objSubStates.options.add(opt);
			    }
		    }
		}
		else
	    {
	        tddrpState.style.display = "none";
            tdTextState.style.display = "block";
	    }				
	}
	else
	{
	    tddrpState.style.display = "none";
        tdTextState.style.display = "block";
	}
}
function getStateName(obj)
{
    var intSelectedIndex = document.getElementById(obj).selectedIndex;
    var sValue = document.getElementById("ctl00_cphmain_hdnStateValue");
    if (intSelectedIndex > 0)
	{
	    var code = document.getElementById(obj).options[intSelectedIndex].value;
	    sValue.value = code;
	}
}
function UserEmail(obj)
{
    var context=new Object();
    var strEmail = document.getElementById(obj.id).value;
    document.getElementById("hdnEmailID").value = obj.id;
    context.flag = strEmail;
    CheckEmail(context.flag,context);
    return false;
}
function CallbackOnSucceeded(result,context)
{
    try
    {
        if(result == "false")
        {
            document.getElementById(document.getElementById("hdnEmailID").value).value = "";
            document.getElementById("ctl00_lblErrMsg").innerHTML = 'Email Address already exist with us. Choose another Email Address.';
            document.getElementById("ctl00_btnHidden").click();
        }
    }
    catch(err)
    {
        txt="There was an error on this page.\n\n";
        txt+="Error description: " + err.description + "\n\n";
        document.getElementById("ctl00_lblErrMsg").innerHTML = txt;
        document.getElementById("ctl00_btnHidden").click();
    }
}
function CallbackOnFailed(result,context)
{
    var val = result;
    document.getElementById("ctl00_lblErrMsg").innerHTML = val;
    document.getElementById("ctl00_btnHidden").click();
}
function checkCCode()
{
    var ddlSubscriptions = document.getElementById("ctl00_cphmain_rbtnSubscribeType");
    var cCode   = document.getElementById("ctl00_cphmain_txtCouponCode");
    var Count = chlCount();
    if(document.getElementById("ctl00_cphmain_lblSubTotal") != null && document.getElementById("ctl00_cphmain_lblSubTotal").innerHTML == "")
    {
        document.getElementById("ctl00_cphmain_lblSubTotal").innerHTML = "0.00";
    }
    if(ddlSubscriptions.selectedIndex > 0)
    {
        if(ddlSubscriptions.options[ddlSubscriptions.selectedIndex].text != "Trail"  && Count >= 2 && cCode.value != "")
        {
            PageMethods.CallServer(cCode.value,OnSucceeded,OnFailed);
        }
        else
        {
            if(document.getElementById("ctl00_cphmain_txtCouponCode").value == "")
            {
                if(document.getElementById("ctl00_cphmain_hdnDPrice").value != "" && document.getElementById("ctl00_cphmain_hdnCDiscount").value != "")
                {
                    document.getElementById("ctl00_cphmain_lblTotalPrice").innerHTML = parseFloat(document.getElementById("ctl00_cphmain_hdnDPrice").value) + parseFloat(document.getElementById("ctl00_cphmain_hdnCDiscount").value);
                    if(document.getElementById("ctl00_cphmain_lblSubTotal") != null)
                    {
                        document.getElementById("ctl00_cphmain_lblTotal").innerHTML = formatCurrency(parseFloat(document.getElementById("ctl00_cphmain_lblSubTotal").innerHTML) + parseFloat(document.getElementById("ctl00_cphmain_lblTotalPrice").innerHTML));
                    }
                    else
                    {
                        document.getElementById("ctl00_cphmain_lblTotal").innerHTML = formatCurrency(parseFloat(document.getElementById("ctl00_cphmain_lblTotalPrice").innerHTML));
                    }
                    document.getElementById("ctl00_cphmain_hdnDPrice").value = document.getElementById("ctl00_cphmain_lblTotal").innerHTML;
                }
            }
            else
            {
                document.getElementById("ctl00_lblErrMsg").innerHTML = "Coupon Number is not valid.";
                document.getElementById("ctl00_btnHidden").click();
                document.getElementById("ctl00_cphmain_txtCouponCode").value = "";
            }
            document.getElementById("ctl00_cphmain_hdnCDiscount").value = "0.00";
        }
    }
    return false;
}
function OnSucceeded(result, userContext, methodName) 
{
    try
    {
        if(document.getElementById("ctl00_cphmain_lblSubTotal") != null && document.getElementById("ctl00_cphmain_lblSubTotal").innerHTML == "")
        {
            document.getElementById("ctl00_cphmain_lblSubTotal").innerHTML = "0.00";
        }
        if(result != "")
        {
            document.getElementById("ctl00_cphmain_hdnCDiscount").value = result;
            document.getElementById("ctl00_cphmain_lblTotalPrice").innerHTML = document.getElementById("ctl00_cphmain_lblTotalPrice").innerHTML - result;
            document.getElementById("ctl00_cphmain_hdnCCode").value = document.getElementById("ctl00_cphmain_txtCouponCode").value;
            document.getElementById("ctl00_cphmain_txtCouponCode").disabled = true;
            if(document.getElementById("ctl00_cphmain_lblSubTotal") != null)
            {
                document.getElementById("ctl00_cphmain_lblTotal").innerHTML = formatCurrency(parseFloat(document.getElementById("ctl00_cphmain_lblSubTotal").innerHTML) + parseFloat(document.getElementById("ctl00_cphmain_lblTotalPrice").innerHTML));
            }
            else
            {
                document.getElementById("ctl00_cphmain_lblTotal").innerHTML = formatCurrency(parseFloat(document.getElementById("ctl00_cphmain_lblTotalPrice").innerHTML));
            }
            document.getElementById("ctl00_cphmain_hdnDPrice").value = document.getElementById("ctl00_cphmain_lblTotal").innerHTML;
        }
        else
        {
            if(document.getElementById("ctl00_cphmain_txtCouponCode").value == "")
            {
                if(document.getElementById("ctl00_cphmain_hdnDPrice").value != "" && document.getElementById("ctl00_cphmain_hdnCDiscount").value != "")
                {
                    document.getElementById("ctl00_cphmain_lblTotalPrice").innerHTML = parseFloat(document.getElementById("ctl00_cphmain_hdnDPrice").value) + parseFloat(document.getElementById("ctl00_cphmain_hdnCDiscount").value);
                    if(document.getElementById("ctl00_cphmain_lblSubTotal") != null)
                    {
                        document.getElementById("ctl00_cphmain_lblTotal").innerHTML = formatCurrency(parseFloat(document.getElementById("ctl00_cphmain_lblSubTotal").innerHTML) + parseFloat(document.getElementById("ctl00_cphmain_lblTotalPrice").innerHTML));
                    }
                    else
                    {
                        document.getElementById("ctl00_cphmain_lblTotal").innerHTML = formatCurrency(parseFloat(document.getElementById("ctl00_cphmain_lblTotalPrice").innerHTML));
                    }
                    document.getElementById("ctl00_cphmain_hdnDPrice").value = document.getElementById("ctl00_cphmain_lblTotal").innerHTML;
                }
            }
            else
            {
                document.getElementById("ctl00_lblErrMsg").innerHTML = "Coupon Number is not valid.";
                document.getElementById("ctl00_btnHidden").click();
                document.getElementById("ctl00_cphmain_txtCouponCode").value = "";
            }
            document.getElementById("ctl00_cphmain_hdnCDiscount").value = "0.00";
        }
    }
    catch(err)
    {
        txt="There was an error on this page.\n\n";
        txt+="Error description: " + err.description + "\n\n";
        document.getElementById("ctl00_lblErrMsg").innerHTML = txt;
        document.getElementById("ctl00_btnHidden").click();
    }
}
function OnFailed(error, userContext, methodName) 
{
    try
    {
        document.getElementById("ctl00_lblErrMsg").innerHTML = error;
        document.getElementById("ctl00_btnHidden").click();
    }
    catch(err)
    {
        txt="There was an error on this page.\n\n";
        txt+="Error description: " + err.description + "\n\n";
        document.getElementById("ctl00_lblErrMsg").innerHTML = txt;
        document.getElementById("ctl00_btnHidden").click();
    }
}
function ddlCStatus()
{
    if(document.getElementById("ctl00_cphmain_lblSubTotal") != null && document.getElementById("ctl00_cphmain_lblSubTotal").innerHTML == "")
    {
        document.getElementById("ctl00_cphmain_lblSubTotal").innerHTML = "0.00";
    }
    var ddlSubscriptions = document.getElementById("ctl00_cphmain_rbtnSubscribeType");
    var Count = chlCount();
    if(document.getElementById("ctl00_cphmain_hdnCouponVisible").value == "Y")
    {
        document.getElementById("ctl00_cphmain_txtCouponCode").value = "";
        document.getElementById("ctl00_cphmain_hdnDPrice").value = ""
        document.getElementById("ctl00_cphmain_hdnCDiscount").value = "0.00";
    }
    if(ddlSubscriptions.selectedIndex > 0)
    {
        if(ddlSubscriptions.options[ddlSubscriptions.selectedIndex].text != "Trail"  && Count >= 2)
        {
            document.getElementById("ctl00_cphmain_tblCSection").style.display = "block";
            document.getElementById("ctl00_cphmain_hdnCouponVisible").value = "Y";
            document.getElementById("ctl00_cphmain_txtCouponCode").disabled = false;
        }
        else
        {
            document.getElementById("ctl00_cphmain_tblCSection").style.display = "none";
            document.getElementById("ctl00_cphmain_hdnCouponVisible").value = "N";
        }
    }
    else
    {
        document.getElementById("ctl00_cphmain_tblCSection").style.display = "none";
        document.getElementById("ctl00_cphmain_hdnCouponVisible").value = "N";
    }
    if(ddlSubscriptions.selectedIndex > 0 && Count > 0)
    {
        if(ddlSubscriptions.options[ddlSubscriptions.selectedIndex].text != "Trail")
        {
            if(trimAll(ddlSubscriptions.options[ddlSubscriptions.selectedIndex].text) == "Monthly")
            {
                res(Count,hdnMonthly);
            }
            else if(trimAll(ddlSubscriptions.options[ddlSubscriptions.selectedIndex].text) == "3Months")
            {
                res(Count,hdn3Months);
            }
            else if(trimAll(ddlSubscriptions.options[ddlSubscriptions.selectedIndex].text) == "6Months")
            {
                res(Count,hdn6Months);
            }
            else if(trimAll(ddlSubscriptions.options[ddlSubscriptions.selectedIndex].text) == "1Year")
            {
                res(Count,hdn1Year);
            }
        }
        else
        {
            document.getElementById("ctl00_cphmain_lblTotalPrice").innerHTML = "0.00";
            if(document.getElementById("ctl00_cphmain_lblSubTotal") != null)
            {
                document.getElementById("ctl00_cphmain_lblSubTotal").innerHTML = splChlPrice();
                document.getElementById("ctl00_cphmain_lblTotal").innerHTML = formatCurrency(parseFloat(document.getElementById("ctl00_cphmain_lblSubTotal").innerHTML) + parseFloat(document.getElementById("ctl00_cphmain_lblTotalPrice").innerHTML));
            }
            else
            {
                document.getElementById("ctl00_cphmain_lblTotal").innerHTML = formatCurrency(parseFloat(document.getElementById("ctl00_cphmain_lblTotalPrice").innerHTML));
            }
            document.getElementById("ctl00_cphmain_hdnDPrice").value = document.getElementById("ctl00_cphmain_lblTotal").innerHTML;
        }
    }
    else
    {
        document.getElementById("ctl00_cphmain_lblTotalPrice").innerHTML = "0.00";
        if(document.getElementById("ctl00_cphmain_lblSubTotal") != null)
        {
            document.getElementById("ctl00_cphmain_lblSubTotal").innerHTML = splChlPrice();
            document.getElementById("ctl00_cphmain_lblTotal").innerHTML = formatCurrency(parseFloat(document.getElementById("ctl00_cphmain_lblSubTotal").innerHTML) + parseFloat(document.getElementById("ctl00_cphmain_lblTotalPrice").innerHTML));
        }
        else
        {
            document.getElementById("ctl00_cphmain_lblTotal").innerHTML = formatCurrency(parseFloat(document.getElementById("ctl00_cphmain_lblTotalPrice").innerHTML));
        }
        document.getElementById("ctl00_cphmain_hdnDPrice").value = document.getElementById("ctl00_cphmain_lblTotal").innerHTML;
    }
    return true;
}
function res(count,sTypeID)
{
    var arrPrices = sTypeID.split('|');
    for(var i = 0;i <= arrPrices.length - 1;i++)
    {
        var arrSubPrices = arrPrices[i].split('~');
        if(count == arrSubPrices[0])
        {
            document.getElementById("ctl00_cphmain_lblTotalPrice").innerHTML = arrSubPrices[1];
            if(document.getElementById("ctl00_cphmain_lblSubTotal") != null)
            {
                document.getElementById("ctl00_cphmain_lblSubTotal").innerHTML = splChlPrice();
                document.getElementById("ctl00_cphmain_lblTotal").innerHTML = formatCurrency(parseFloat(document.getElementById("ctl00_cphmain_lblSubTotal").innerHTML) + parseFloat(document.getElementById("ctl00_cphmain_lblTotalPrice").innerHTML));
            }
            else
            {
                document.getElementById("ctl00_cphmain_lblTotal").innerHTML = formatCurrency(parseFloat(document.getElementById("ctl00_cphmain_lblTotalPrice").innerHTML));
            }
            document.getElementById("ctl00_cphmain_hdnDPrice").value = document.getElementById("ctl00_cphmain_lblTotal").innerHTML;
            break;
        }
    }
}
function chlCount()
{
    var chkList = document.getElementsByTagName('input');
    var itemsSelected = 0;
    var strPackages = "";
    for(var i = 0;i < chkList.length; i++)
    {
        if(chkList[i].type == "checkbox" && chkList[i].checked == true)
        {
            if(chkList[i].id != "ctl00_cphmain_chkAgree" && chkList[i].id != "ctl00_cphmain_chkMail" && chkList[i].id.indexOf("ctl00_cphmain_gvPackages") == -1)
            {
                itemsSelected++;
                var cName = chkList[i].name;
                strPackages += cName.substring(cName.indexOf("$Chk")+4,cName.length) + ",";
            }
        }
    }
    document.getElementById("ctl00_cphmain_hdnPID").value = strPackages;
    return itemsSelected;
}
function splChlCount()
{
    var chkList = document.getElementsByTagName('input');
    var itemsSelected = 0;
    var strPackages = "";
    for(var i = 0;i < chkList.length; i++)
    {
        if(chkList[i].type == "checkbox" && chkList[i].checked == true)
        {
            if(chkList[i].id.indexOf("ctl00_cphmain_gvPackages") != -1)
            {
                itemsSelected++;
                var obj = chkList[i].id;
                var pkgID = obj.replace("chkPackage","lblPackageName");
                strPackages += document.getElementById(pkgID).innerHTML + ",";
            }
        }
    }
    document.getElementById("ctl00_cphmain_hdnSPID").value = strPackages;
    return itemsSelected;
}
function TotalCost(object)
{
    var res;
    var ddlSubscriptions = document.getElementById("ctl00_cphmain_rbtnSubscribeType");
    var count = chlCount();
    var splCount = splChlCount();
    var splPkgAmount = "0.00";
    var obj = object.id;
    if(document.getElementById("ctl00_cphmain_lblTotalPrice").innerHTML == "")
    {
        document.getElementById("ctl00_cphmain_lblTotalPrice").innerHTML = "0.00";
    }
    if(count == 0 || count > 0 && ddlSubscriptions.selectedIndex == 0 || count > 0 && ddlSubscriptions.selectedIndex > 0 && ddlSubscriptions.options[ddlSubscriptions.selectedIndex].text == "Trail")
    {
        splPkgAmount = SplPkgValue;
    }
    else
    {
        splPkgAmount = parseFloat(document.getElementById(obj).value);
    }
    if(document.getElementById(obj).checked == true)
    {
        if(document.getElementById("ctl00_cphmain_lblSubTotal").innerHTML == "")
        {
            document.getElementById("ctl00_cphmain_lblSubTotal").innerHTML = "0.00";
        }
        res = parseFloat(document.getElementById("ctl00_cphmain_lblSubTotal").innerHTML) + splPkgAmount;
    }
    else
    {
        res = parseFloat(document.getElementById("ctl00_cphmain_lblSubTotal").innerHTML) - splPkgAmount;
    }
    if(res < 0 || res == "")
    {
        document.getElementById("ctl00_cphmain_lblSubTotal").innerHTML = "0.00";
    }
    else
    {
        document.getElementById("ctl00_cphmain_lblSubTotal").innerHTML = formatCurrency(res);
    }
    
    document.getElementById("ctl00_cphmain_hdnSplPkgCost").value = document.getElementById("ctl00_cphmain_lblSubTotal").innerHTML;
    document.getElementById("ctl00_cphmain_lblTotal").innerHTML = formatCurrency(parseFloat(document.getElementById("ctl00_cphmain_lblSubTotal").innerHTML) + parseFloat(document.getElementById("ctl00_cphmain_lblTotalPrice").innerHTML));
    document.getElementById("ctl00_cphmain_hdnDPrice").value = document.getElementById("ctl00_cphmain_lblTotal").innerHTML;
}
function splChlPrice()
{
    var chkList = document.getElementsByTagName('input');
    var itemsSelected = 0;
    var splPkgCost = "0.00";
    var count = chlCount();
    var splCount = splChlCount();
    var ddlSubscriptions = document.getElementById("ctl00_cphmain_rbtnSubscribeType");
    for(var i = 0;i < chkList.length; i++)
    {
        if(chkList[i].type == "checkbox" && chkList[i].checked == true)
        {
            if(chkList[i].id.indexOf("ctl00_cphmain_gvPackages") != -1)
            {
                itemsSelected++;
                var obj = chkList[i].id;
                splPkgCost = parseFloat(splPkgCost) + parseFloat(document.getElementById(chkList[i].id).value);
            }
        }
    }
    if(count == 0 && itemsSelected > 0 || count > 0 && ddlSubscriptions.selectedIndex == 0 || count > 0 && ddlSubscriptions.selectedIndex > 0 && ddlSubscriptions.options[ddlSubscriptions.selectedIndex].text == "Trail")
    {
        if(splCount != 0)
        {
            splPkgCost = SplPkgValue;
        }
    }
    document.getElementById("ctl00_cphmain_hdnSplPkgCost").value = splPkgCost;
    return splPkgCost;
}
