﻿function include(file){
var script=document.createElement('script')
script.src=file
script.type='text/javascript'
script.defer=true
document.getElementsByTagName('head').item(0).appendChild(script)}
function trim(inputString){
if(typeof inputString !="string"){
return inputString}
var retValue=inputString
var ch=retValue.substring(0,1)
while(ch==" "){
retValue=retValue.substring(1,retValue.length)
ch=retValue.substring(0,1)}
ch=retValue.substring(retValue.length-1,retValue.length)
while(ch==" "){
retValue=retValue.substring(0,retValue.length-1)
ch=retValue.substring(retValue.length-1,retValue.length)}
while(retValue.indexOf("  ")!=-1){
retValue=retValue.substring(0,retValue.indexOf("  "))+retValue.substring(retValue.indexOf("  ")+1,retValue.length)}
return retValue}
function ValidateMSISDN(fieldName){
if(trim(fieldName.value).length==0){
alert("Enter MSISDN Number")
fieldName.focus()
return false}
myNum=new Number(fieldName.value)
if(myNum.valueOf()<0 || myNum.valueOf()+""=="NaN"){
alert("Enter valid MSISDN Number--")
fieldName.select()
return false}
else if(fieldName.value.length<10 || fieldName.value.length>12){
alert("Enter valid MSISDN Number")
fieldName.select()
return false}
return true}
function IsCharSpaceKey(evt){
var charCode=(evt.which)? evt.which : event.keyCode
if((charCode>=65&&charCode<=91)^ charCode==32 ^ charCode==45 ^ charCode==46 ^ charCode==64)
return true
if(charCode>=97&&charCode<=122)
return true
if(charCode>=48&&charCode<=57)
return true
if(charCode == 8)
return true
return false}

function isValidEmailChar(mail,evt){
var charCode=(evt.which)? evt.which : event.keyCode
var character=String.fromCharCode(charCode)
if((charCode>=65&&charCode<=91))
return true
if(charCode>=97&&charCode<=122)
return true
if(charCode>=48&&charCode<=57)
{
var sMail=mail.value
if(sMail.length==0)
{return false;}
if(sMail.substring(0,1)==character)
{return false;}
return true
}
if(charCode==46 || charCode==64)
return true
if(charCode==45 || charCode==95)
return true
if (charCode == 8)
return true
return false}


function EnableNatureOfBusiness(ddlNofB,txtOthers){
var subm=document.getElementById(ddlNofB)
var Txtbox=document.getElementById(txtOthers)
document.getElementById('lblErrorNatureOfBusiness').innerHTML='';
var w=subm.selectedIndex
var selected_text=subm.options[w].text
if(selected_text=="Other"){
Txtbox.style.display='';
Txtbox.disabled=false;
/*Txtbox.disabled=false;Txtbox.focus()*/
Txtbox.value='';
}
else{
Txtbox.disabled=false;
Txtbox.style.display='none';
Txtbox.value="Other nature of business"
/*Txtbox.disabled=true*/}}
function DisableSubmit(chkone,btnsubmit,btncancel){
var submitbtn=document.getElementById(btnsubmit)
var checkbox1=document.getElementById(chkone)
var cancel=document.getElementById(btncancel)
submitbtn.disabled=false;
checkbox1.checked=false}

function CompareDates(from,to,lbl,lblErr){
var oFrom=from.value;
var oTo=to.value;
var fYear=oFrom.substring(0,oTo.indexOf("-"));
var fMonth=oFrom.substring(oTo.indexOf("-")+1,oTo.lastIndexOf("-"));
var fDay=oFrom.substring(oTo.lastIndexOf("-")+1,oFrom.length);
var tYear=oTo.substring(0,oTo.indexOf("-"));
var tMonth=oTo.substring(oTo.indexOf("-")+1,oTo.lastIndexOf("-"));
var tDay=oTo.substring(oTo.lastIndexOf("-")+1,oTo.length);
var ToDate = new Date(tYear,tMonth,tDay);
var FromDate = new Date(fYear,fMonth,fDay);
if(FromDate > ToDate){
//oFrom=fMonth+"-"+fDay+"-"+fYear;oTo=tMonth+"-"+tDay+"-"+tYear;if(Date.parse(oFrom)>Date.parse(oTo)){-- commented for firefox compatability
document.getElementById(lbl).innerHTML="Invalid Date Range! <br> StartDate cannot be greater than ToDate!";
if(document.getElementById(lblErr)!=null)
document.getElementById(lblErr).innerHTML="";
return false;}
document.getElementById(lbl).innerHTML="";
return true;}
// function for download reports functionality
function EnableDisableSendLater(TableName,From,To,Check,LblError,fromHrs,fromMins,toHrs,toMins){
var tblSLater=document.getElementById(TableName);
var oFromDate=document.getElementById(From);
var oToDate=document.getElementById(To);
var oChkSendLater=document.getElementById(Check);
var d=new Date();
var curr_date=d.getDate();
var curr_month=d.getMonth();
curr_month=curr_month+1;
var curr_year=d.getFullYear();
var dl=curr_date.toString().length;
var ml=curr_month.toString().length;
if(dl==1){curr_date="0"+curr_date.toString();}
if(ml==1){curr_month="0"+curr_month.toString();}
var curr_fullyear=curr_year+"-"+curr_month+"-"+curr_date;
if(oChkSendLater.checked==false){
tblSLater.style.display='none';}
if(oChkSendLater.checked==true){
tblSLater.style.display='';}
oFromDate.value=curr_fullyear;  // changed Innertext to value
oToDate.value=curr_fullyear;
document.getElementById(LblError).innerHTML='';
}


function IsNotInteger(evt){
var charCode=(evt.which)? evt.which : event.keyCode
if((charCode>=65&&charCode<=91)^ charCode==32)
return true
if (charCode == 8)
return true
if(charCode>=97&&charCode<=122)
return true
if(charCode==44)
return false
if(charCode>31&&(charCode<48 || charCode>57))
return false
return false}
function isNumberKey(evt){
var charCode=(evt.which)? evt.which : event.keyCode
if(charCode>31&&(charCode<48 || charCode>57))
return false
return true}

function isNumberKeyWithComma(evt){
var charCode=(evt.which)? evt.which : event.keyCode
if(charCode==44 )return true
if (charCode == 127) return true
if(charCode>31&&(charCode<48 || charCode>57))return false 
return true}

function IsValidPinCode(evt){
var charCode=(evt.which)? evt.which : event.keyCode
if(charCode>=48&&charCode<=57)
return true
if (charCode == 8 )
return true
return false}

function isCharKey(evt,Pagenumber){
var charCode=(evt.which)? evt.which : event.keyCode
if((charCode>=65&&charCode<=91)^ charCode==32 ^ charCode==45 ^ charCode==46)
return true
if(charCode == 8)
return true
if(charCode>=97&&charCode<=122)
return true
if(charCode>=48&&charCode<=57)
return true
if(Pagenumber>0){
if(charCode==64)
return true}
return false}


function ValidateMobileNumber(number,lbl)
{
   MobileNumber= number.value;
    var ErrorMsg;
   if(MobileNumber.length>10)
   {
     if(MobileNumber.length==12)
    {
       if(MobileNumber.substring(0,2)!="91")
       {
       ErrorMsg="* Number should begin with 91"
       }      
        else if(MobileNumber.substring(2,3)=="9")
       {
         ErrorMsg= ""  
       }
       else if(MobileNumber.substring(2,3)=="8")
       {
         ErrorMsg= ""  
       }      
       else
        ErrorMsg="*  Invalid Mobile Number."
    }
    else if(MobileNumber.length==11)
    {
    if(MobileNumber.substring(0,1)!="0")
       {
       ErrorMsg="* Invalid Mobile Number."
       }      
        else if(MobileNumber.substring(2,2)=="9")
       {
         ErrorMsg= ""  
       }
       else if(MobileNumber.substring(2,3)=="8")
       {
         ErrorMsg= ""  
       }      
       else
        ErrorMsg="*  Invalid Mobile Number."
    }
     else
    {
      ErrorMsg="*  Invalid Mobile Number"
    }   
  }
  else if(MobileNumber.length==10)
  {
   if(MobileNumber.substring(0,1)=="9"  )
   {
     ErrorMsg= ""   //"* Number should begin with 9 or 8"
   }
    else if(MobileNumber.substring(0,1)=="8"  )
    {
    ErrorMsg=""
    }
    else
    {
     ErrorMsg= "*  Invalid Mobile Number."
    }
  }
 else if(MobileNumber.length>0)
 {
  var Digits="0123456789";
  for(var i=0;i<MobileNumber.length-1;i++)
   {  
   if(Digits.indexOf(MobileNumber.charAt(i))==-1)  
    ErrorMsg="*  Invalid Mobile Number"  
  } 
 }
else if(MobileNumber.length==0)
{
ErrorMsg="*  Enter Mobile Number"
}
document.getElementById(lbl).innerHTML=ErrorMsg

if((MobileNumber.length<10)&&(MobileNumber.length>0))
{
ErrorMsg = "Invalid Mobile Number"
document.getElementById(lbl).innerHTML="*  Invalid Mobile Number"
number.focus()
}
if((ErrorMsg==null)||(ErrorMsg==""))
{
return true
}
else
{
return false
}
}
function mailcheck(str){
var numArray=new Array('0','1','2','3','4','5','6','7','8','9')
for(var i=0;i<(numArray.length);i++){
if(str.substring(0,1)==numArray[i]){
nNumberExists=1
return false}}
var arr=new Array('.com','.net','.org','.biz','.coop','.info','.museum','.name','.pro'
,'.edu','.gov','.int','.mil','.ac','.ad','.ae','.af','.ag','.ai','.al',
'.am','.an','.ao','.aq','.ar','.as','.at','.au','.aw','.az','.ba','.bb',
'.bd','.be','.bf','.bg','.bh','.bi','.bj','.bm','.bn','.bo','.br','.bs',
'.bt','.bv','.bw','.by','.bz','.ca','.cc','.cd','.cf','.cg','.ch','.ci',
'.ck','.cl','.cm','.cn','.co','.cr','.cu','.cv','.cx','.cy','.cz','.de',
'.dj','.dk','.dm','.do','.dz','.ec','.ee','.eg','.eh','.er','.es','.et',
'.fi','.fj','.fk','.fm','.fo','.fr','.ga','.gd','.ge','.gf','.gg','.gh',
'.gi','.gl','.gm','.gn','.gp','.gq','.gr','.gs','.gt','.gu','.gv','.gy',
'.hk','.hm','.hn','.hr','.ht','.hu','.id','.ie','.il','.im','.in','.io',
'.iq','.ir','.is','.it','.je','.jm','.jo','.jp','.ke','.kg','.kh','.ki',
'.km','.kn','.kp','.kr','.kw','.ky','.kz','.la','.lb','.lc','.li','.lk',
'.lr','.ls','.lt','.lu','.lv','.ly','.ma','.mc','.md','.mg','.mh','.mk',
'.ml','.mm','.mn','.mo','.mp','.mq','.mr','.ms','.mt','.mu','.mv','.mw',
'.mx','.my','.mz','.na','.nc','.ne','.nf','.ng','.ni','.nl','.no','.np',
'.nr','.nu','.nz','.om','.pa','.pe','.pf','.pg','.ph','.pk','.pl','.pm',
'.pn','.pr','.ps','.pt','.pw','.py','.qa','.re','.ro','.rw','.ru','.sa',
'.sb','.sc','.sd','.se','.sg','.sh','.si','.sj','.sk','.sl','.sm','.sn',
'.so','.sr','.st','.sv','.sy','.sz','.tc','.td','.tf','.tg','.th','.tj',
'.tk','.tm','.tn','.to','.tp','.tr','.tt','.tv','.tw','.tz','.ua','.ug',
'.uk','.um','.us','.uy','.uz','.va','.vc','.ve','.vg','.vi','.vn','.vu',
'.ws','.wf','.ye','.yt','.yu','.za','.zm','.zw')
var val=true
var beforeat=""
var afterat=""
var afterat2=""
var dot=str.lastIndexOf(".")
var con=str.substring(dot,str.length)
con=con.toLowerCase()
con=con.toString()
for(var i=0;i<(arr.length);i++){
if(con==arr[i]){
val=true
break}
else{
val=false}}
if(val==false){
nNumberExists=2
return false}
var at="@"
var dot="."
var lat=str.indexOf(at)
var lstr=str.length
var ldot=str.indexOf(dot)
if(str.substring(ldot,ldot+1)==dot&&str.substring(ldot+2,ldot+1)==dot)
return false
if(str.indexOf(at)==-1)
return false
if(str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
return false
if(str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
return false
if(str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
return false
if(str.indexOf(at,(lat+1))!=-1)
return false
if(str.indexOf(dot,(lat+2))==-1)
return false
if(str.indexOf(",")!=-1 || str.indexOf(";")!=-1 || str.indexOf("?")!=-1 || str.indexOf("/")!=-1)
return false
if(str.indexOf(" ")!=-1 || str.indexOf("#")!=-1 || str.indexOf("$")!=-1)
return false
if(str.indexOf(">")!=-1 || str.indexOf("<")!=-1 || str.indexOf("!")!=-1)
return false
if(str.indexOf("%")!=-1 || str.indexOf("^")!=-1 || str.indexOf("&")!=-1)
return false
if(str.indexOf("*")!=-1 || str.indexOf("(")!=-1 || str.indexOf(")")!=-1)
return false
if(str.indexOf("+")!=-1 || str.indexOf("=")!=-1 || str.indexOf("~")!=-1)
return false
if(str.indexOf("{")!=-1 || str.indexOf("}")!=-1 || str.indexOf("[")!=-1 || str.indexOf("]")!=-1)
return false
if(str.indexOf("`")!=-1 || str.indexOf(":")!=-1)
return false
return true}

function SelectAllCheckboxes(spanChk,Page){
var oItem=spanChk.children
var theBox=(spanChk.type=="checkbox")?
spanChk : spanChk.children.item[0]
xState=theBox.checked
elm=theBox.form.elements
for(i=0;i<elm.length;i++){
if(elm[i].type=="checkbox"&&elm[i].id!=theBox.id)
/*if(elm[i].id!='ctl00_cphMain_tbcCompose_tbpTextMsg_chkSendLater')*/
elm[i].checked=xState}
/*if(Page=="Compose"){
var SendLater=document.getElementById('ctl00_cphMain_tbcCompose_tbpTextMsg_chkSendLater').checked
if(SendLater)
document.getElementById('ctl00_cphMain_tbcCompose_tbpTextMsg_chkSendLater').checked=true
else
document.getElementById('ctl00_cphMain_tbcCompose_tbpTextMsg_chkSendLater').checked=false}*/}


function DeselectMainCheckbox(){
var frm=document.aspnetForm
var boolAllChecked
boolAllChecked=true
for(i=0;i<frm.length;i++){
e=frm.elements[i]
if(e.type=='checkbox'&&e.name.indexOf('chkItem')!=-1)
if(e.checked==false){
boolAllChecked=false
break}}
for(i=0;i<frm.length;i++){
e=frm.elements[i]
if(e.type=='checkbox'&&e.name.indexOf('chk')!=-1){
if(boolAllChecked==false)
e.checked=false
else
e.checked=true
break}}}

function DeselectMainCheckbox(tbp){
var frm=document.aspnetForm
var boolAllChecked
boolAllChecked=true
for(i=0;i<frm.length;i++)
{
e=frm.elements[i]
if(e.type=='checkbox'&&(e.name.indexOf(tbp)!=-1&&e.name.indexOf('chkItem')!=-1))
if(e.checked==false){
boolAllChecked=false
break}
}
for(i=0;i<frm.length;i++){
e=frm.elements[i]
if(e.type=='checkbox'&&(e.name.indexOf(tbp)!=-1&&e.name.indexOf('chk')!=-1)){
if(boolAllChecked==false)
e.checked=false
else
e.checked=true
break}}}


function closer(){
this.close()}
function ValidateEMail(emailID,number,lblError,lblUser,btnSign,chk){
nNumberExists=2
browserName=navigator.appName
if((emailID.value==null)||(emailID.value=="")){
document.getElementById(lblError).innerHTML=" Enter email Id."
return false}
else{
if(mailcheck(emailID.value)==false){
if(nNumberExists==1)
document.getElementById(lblError).innerHTML=" First letter should not be number."
else{
if(emailID.value.indexOf('---')==-1){
document.getElementById(lblError).innerHTML=" Invalid email Id."}}
if(document.getElementById(lblUser)!=null)
document.getElementById(lblUser).innerHTML=""
if(number==1){
var submitbtn=document.getElementById(btnSign)
var checkbox1=document.getElementById(chk)
checkbox1.checked=false
submitbtn.disabled=false}
setTimeout(function(){emailID.focus();emailID.select();},10)
return false}
if(document.getElementById(lblError)!=null)
document.getElementById(lblError).innerHTML=""}
return true}
var horizontal_offset="2px"
var vertical_offset="0"
var ie=document.all
var ns6=document.getElementById&&!document.all
function getposOffset(what,offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop
var parentEl=what.offsetParent
while(parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop
parentEl=parentEl.offsetParent}
return totaloffset}
function iecompattest(){
return(document.compatMode&&document.compatMode!="BackCompat")? document.documentElement : document.body}
function clearbrowseredge(obj,whichedge){
var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1
if(whichedge=="rightedge"){
var windowedge=ie&&!window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-30 : window.pageXOffset+window.innerWidth-40
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if(windowedge-dropmenuobj.x<dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth+parseInt(horizontal_offset)}
else{
var windowedge=ie&&!window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if(windowedge-dropmenuobj.y<dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight}
return edgeoffset}
function showhint(menucontents,obj,e,tipwidth){
if((ie||ns6)&&document.getElementById("hintbox")){
dropmenuobj=document.getElementById("hintbox")
dropmenuobj.innerHTML=menucontents
dropmenuobj.style.left=dropmenuobj.style.top=-500
if(tipwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=tipwidth}
dropmenuobj.x=getposOffset(obj,"left")
dropmenuobj.y=getposOffset(obj,"top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj,"rightedge")+obj.offsetWidth+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj,"bottomedge")+"px"
dropmenuobj.style.visibility="visible"
obj.onmouseout=hidetip}}
function hidetip(e){
dropmenuobj.style.visibility="hidden"
dropmenuobj.style.left="-500px"}
function createhintbox(){
var divblock=document.createElement("div")
divblock.setAttribute("id","hintbox")
document.body.appendChild(divblock)}
if(window.addEventListener)
window.addEventListener("load",createhintbox,false)
else if(window.attachEvent)
window.attachEvent("onload",createhintbox)
else if(document.getElementById)
window.onload=createhintbox
function SingleSelection(val){
var flag;if(val.checked==true)flag=1;else flag=0;for(i=0;i<document.aspnetForm.elements.length;i++){elm=document.aspnetForm.elements[i];if(elm.type=='radio')elm.checked=false;}if(flag==1)val.checked=true;}


function TextMsgLength(Editortext,showTextLength,evt)
{
var oEdit=document.getElementById(Editortext).value;
var OShowTextLength=document.getElementById(showTextLength);
var charCode=(evt.which)? evt.which : event.keyCode
document.getElementById('divAlert').innerHTML ='';
document.getElementById('ctl00_cphMain_tbcCompose_tbpTextMsg_txtTextPreview').value = document.getElementById(Editortext).value;
if (charCode == 86 || charCode == 67) return;

if(charCode==8 || charCode==46)
{
   OShowTextLength.value = GetStringLength(oEdit);
    if (OShowTextLength.value >160 && oEdit.length>0 )
    {
     document.getElementById('divAlert').innerHTML ="Message exceeds 160 Characters";
    }
}
else
{
OShowTextLength.value = GetStringLength(oEdit);

if (OShowTextLength.value >160 && oEdit.length>0 )
{
//alert('Message exceeds '+OShowTextLength.value+' Characters') ; 
document.getElementById('divAlert').innerHTML ="Message exceeds 160 Characters";
} 
}
if(document.getElementById('ctl00_cphMain_tbcCompose_tbpTextMsg_ddlLanguage').value !="English")
{
    OShowTextLength.value = parseInt(OShowTextLength.value) * 4;
    var hCount = parseInt(OShowTextLength.value) / 268;
    if((parseInt(OShowTextLength.value) % 268)>0 && parseInt(OShowTextLength.value) > 268)
        hCount = hCount + 1;
       OShowTextLength.value = parseInt(OShowTextLength.value) + (parseInt(hCount) * 12);
       if(parseInt(OShowTextLength.value)>280)
       document.getElementById('divAlert').innerHTML ="Message exceeds 280 Characters";
       
}


}


function MsgLength(Editortext,showTextLength,evt)
{
var oEdit=document.getElementById(Editortext).value;
var OShowTextLength=document.getElementById(showTextLength);
var charCode=(evt.which)? evt.which : event.keyCode
if (charCode == 86 || charCode == 67) return;

if(charCode==8 || charCode==46)
{ 
OShowTextLength.value = GetStringLength(oEdit);
}
else
{
OShowTextLength.value = GetStringLength(oEdit);
if (OShowTextLength.value ==160 && oEdit.length>0 )
{ 
alert('Message exceeds '+OShowTextLength.value+' Characters') ; 
} 
}
}
function GetStringLength(str)
{
var count =0;
for (var i=0;i<str.length;i++)
{
var strChar = str.charAt(i); 
if (strChar =="}" || strChar == "{" || strChar == "]" || strChar == "[" || strChar == "|" || strChar == "^" || strChar == "~"  || strChar == "\\" )  
count = count+2;  
else
count = count+1; 
} 
return count;
}

function vCardPreview()
{
   var preview = "";
   var finalPreview = "";
   
   preview =document.getElementById('ctl00_cphMain_tbcCompose_tbpVCard_txtNameVCard').value;
  if(trim(document.getElementById('ctl00_cphMain_tbcCompose_tbpVCard_txtNameVCard').value).length >0) 
      preview = preview+"\n";
  finalPreview += preview;
  
  preview = document.getElementById('ctl00_cphMain_tbcCompose_tbpVCard_txtMobileVCard').value;
  if(trim(document.getElementById('ctl00_cphMain_tbcCompose_tbpVCard_txtMobileVCard').value).length >0)
  preview = preview+"\n";
  finalPreview += preview;
  
  preview = document.getElementById('ctl00_cphMain_tbcCompose_tbpVCard_txtEmailVCard').value;
  if(trim(document.getElementById('ctl00_cphMain_tbcCompose_tbpVCard_txtEmailVCard').value).length >0)
  preview = preview+"\n";
  finalPreview += preview;
  
   preview = document.getElementById('ctl00_cphMain_tbcCompose_tbpVCard_txtPhoneVCard').value;
  if(trim(document.getElementById('ctl00_cphMain_tbcCompose_tbpVCard_txtPhoneVCard').value).length >0)
  preview =preview ;
  finalPreview += preview;
  
document.getElementById('ctl00_cphMain_tbcCompose_tbpVCard_txtVcardPreview').value = trim(finalPreview);
}

function GetCoutof()
{ 

var Optid='';
var OptDesid='';
var Tot = 0 ;
var Length= 0;
var preview = "";
var finalPreview = "";
var Temp = "";

preview = document.getElementById('ctl00_cphMain_tbcCompose_tbpPollContests_txtHdrMsg').value.replace("\r\n","\n");
if (document.getElementById('ctl00_cphMain_tbcCompose_tbpPollContests_txtHdrMsg').value.length > 0)
 preview =preview+"\n";
finalPreview += preview;


preview = document.getElementById('ctl00_cphMain_tbcCompose_tbpPollContests_txtContetsQuestion').value.replace("\r\n","\n");
if (document.getElementById('ctl00_cphMain_tbcCompose_tbpPollContests_txtContetsQuestion').value.length > 0)
 preview =preview+"\n";
 finalPreview += preview;
 
var num;

 var TempOptions = "";
if(document.getElementById('ctl00_cphMain_tbcCompose_tbpPollContests_dlstOptions') != null)
{
var id = parseInt(document.getElementById('ctl00_cphMain_tbcCompose_tbpPollContests_dlstOptions').rows.length);

for(var i=0;i<=id-1;i++)
{
if(i>=0 && i<=6)
{
num='0'+i;
}

 preview = trim(document.getElementById('ctl00_cphMain_tbcCompose_tbpPollContests_dlstOptions_ctl'+num+'_txtOption').value).replace("\r\n","\n");
 if  (document.getElementById('ctl00_cphMain_tbcCompose_tbpPollContests_dlstOptions_ctl'+num+'_txtOption').value.length > 0)
 {
 preview = preview+") "; 
  Temp +=preview;
 } 
 finalPreview += preview;

 preview = trim(document.getElementById('ctl00_cphMain_tbcCompose_tbpPollContests_dlstOptions_ctl'+num+'_txtDesc').value).replace("\r\n","\n");
 if (document.getElementById('ctl00_cphMain_tbcCompose_tbpPollContests_dlstOptions_ctl'+num+'_txtDesc').value.length > 0)
 {  
   preview =preview+ " "; 
 } 
 finalPreview += preview;
}
}
//finalPreview = finalPreview.replace(" ","")
//Length =document.getElementById('ctl00_cphMain_tbcCompose_tbpPollContests_txtFooterMsg').value.length;
preview = document.getElementById('ctl00_cphMain_tbcCompose_tbpPollContests_txtFooterMsg').value.replace("\r\n","\n");
if (document.getElementById('ctl00_cphMain_tbcCompose_tbpPollContests_txtFooterMsg').value.length > 0 && trim(Temp).length >0)
 preview = "\n"+preview;
finalPreview += preview;
//Tot += Length;


//document.getElementById('ctl00_cphMain_tbcCompose_tbpPollContests_txtPollCount').value=Tot; 

document.getElementById('ctl00_cphMain_tbcCompose_tbpPollContests_txtPreview').value=finalPreview.replace("\r\n","\n"); 
document.getElementById('ctl00_cphMain_tbcCompose_tbpPollContests_txtPollCount').value=GetStringLength(finalPreview); 

}


/*function MsgLength(Editortext,showTextLength,evt){var oEdit=document.getElementById(Editortext).value;var OShowTextLength=document.getElementById(showTextLength);var charCode=(evt.which)? evt.which : event.keyCode
if(charCode==8){var nLength=oEdit.length;if(nLength==0)OShowTextLength.value=0;else{OShowTextLength.value=nLength-1;}}
else if(charCode==17 || charCode==9 || charCode==17 || charCode==16 || charCode==18 ||charCode==34 ||charCode==35 ||charCode==36 || charCode==37 || charCode==38 || charCode==39 || charCode==40 || charCode==46)
{var nLength=oEdit.length;if(nLength==0)OShowTextLength.value=0;}
else{OShowTextLength.value=oEdit.length;var nCount=oEdit.length%160;if(oEdit.length>0&&nCount==0)alert('Message exceeds '+oEdit.length+' Characters');}}*/

/*function MsgLength(Editortext,showTextLength,evt)
{
var oEdit=document.getElementById(Editortext).value;
var OShowTextLength=document.getElementById(showTextLength);
var charCode=(evt.which)? evt.which : event.keyCode

if (charCode == 86 || charCode == 67 ) return;
if(charCode==8 || charCode==46)
{ 
var nLength=oEdit.length;
if(nLength==0) OShowTextLength.value=0;
else
{
if(charCode == 8)
{
var diff = OShowTextLength.value-oEdit.length;
if (diff > 1)
OShowTextLength.value=OShowTextLength.value - 2;
else
OShowTextLength.value=OShowTextLength.value - 1;
}
else
{
OShowTextLength.value = GetStringLength(oEdit);
}
}
}
else if(charCode==17 || charCode==9 || charCode==18 ||charCode==34 ||charCode==35 || charCode == 16 ||charCode==36 || charCode==37 || charCode==38 || charCode==39 || charCode==40 ) /* charCode==17 || charCode==16 || -- removed from this line on 13 july 2009 

{
var nLength=oEdit.length;
if(nLength==0)OShowTextLength.value=0;
}
else if ( charCode ==192 || charCode == 219 || charCode == 221 || charCode == 220 || charCode == 54 || charCode == 123 || charCode == 219)

{ 
OShowTextLength.value=parseInt(OShowTextLength.value)+2;
 OShowTextLength.value=OShowTextLength.value%160;  --commented
if(oEdit.length>0 && OShowTextLength.value==160)
{ 
alert('Message exceeds '+OShowTextLength.value+' Characters'); 
}
}
else
{
if (parseInt(OShowTextLength.value) > 0)
OShowTextLength.value=parseInt(OShowTextLength.value)+1;
else
OShowTextLength.value=oEdit.length;
if(oEdit.length>0&&OShowTextLength.value==160)
{ 
alert('Message exceeds '+OShowTextLength.value+' Characters') ; 
} 
}
}*/

//added on 20th Feb 2009  --  Allows alphanumerics and starting character should be character
function IsCharNumericKey(code,evt){
var charCode=(evt.which)? evt.which : event.keyCode
var character=String.fromCharCode(charCode);var sCode=code.value
if(sCode.length==0)
{
if((charCode>=65&&charCode<91)||(charCode>=97&&charCode<=122))return true;
if(charCode>31&&(charCode>=48 || charCode<=57))return false;
}
else if(sCode.length>0)
{
if(charCode>=65&&charCode<91) return true
if(charCode>=97&&charCode<=122) return true
if(charCode>=48&&charCode<=57) return true
if(charCode == 8) return true;
return false
}
}
//added on 07 March 2009   -- Allows alphanumerics, Space and starting character should be character
function IsCharNumericSpaceKey(code,evt)
{
var charCode=(evt.which)? evt.which : event.keyCode
var character=String.fromCharCode(charCode);var sCode=code.value
if(sCode.length==0)
{
if((charCode>=65&&charCode<91)||(charCode>=97&&charCode<=122))return true;
if(charCode>31&&(charCode>=48 || charCode<=57))return false;
}
else if(sCode.length>0)
{
if(charCode>=65&&charCode<91)
return true
if(charCode>=97&&charCode<=122)
return true
if(charCode>=48&&charCode<=57)
return true
if(charCode = 32)
return true
if(charCode = 8)
return true
return false
}
}
function IsCharNumericKeyOption(evt){
var charCode=(evt.which)? evt.which : event.keyCode;
if(charCode>=65&&charCode<91) return true;
if(charCode>=97&&charCode<=122) return true;
if(charCode>=48&&charCode<=57) return true;
if (charCode == 8) return true;
return false;
}
function IsCharNumericSpaceDescription(evt){  
 var charCode;
if (navigator.appName == "Mozilla"  || navigator.appName == "Microsoft Internet Explorer" ) 
{  charCode = window.event.keyCode; }
else if (navigator.appName == "Opera")
{  charCode = window.event.which; }
else 
{charCode = window.event.charCode; }   

if(charCode>=65&&charCode<91) return true;
else if(charCode>=97&&charCode<=122) return true;
else if(charCode>=48&&charCode<=57) return true;
else if(charCode == 32)return true;
else if (charCode == 8) return true;
else return false;
}

 



function clearText(thefield){
	if (thefield.defaultValue==thefield.value)
		thefield.value = ""
		}
//function IsCharNumericSpaceDescription(evt){  
// var charCode=(evt.which)? evt.which : event.keyCode; 
//if(charCode>=65&&charCode<91) return true;
//else if(charCode>=97&&charCode<=122) return true;
//else if(charCode>=48&&charCode<=57) return true;
//else if(charCode == 32)return true;
//else if (charCode == 8) return true;
//else return false;
//}
//  var charCode;
//if (navigator.appName == "Mozilla") {  charCode = window.event.keyCode; }
//else { charCode = e.which;}


//added by samyukta on 20-oct-2009  for selecting payment option in AddtoCart 
function SelectPayment(rbtn)
{
var pType = rbtn.id;

/*if(pType == "ctl00_cphMain_rbtnICICI")  
{
  document.getElementById('ctl00_cphMain_trPGType').style.display='';
  document.getElementById('ctl00_cphMain_tdCdtCard').style.display='';
  document.getElementById('ctl00_cphMain_tdCashCard').style.display='none';
  document.getElementById('ctl00_cphMain_rbtnVisa').checked = false;
    document.getElementById('ctl00_cphMain_ddlBanks').style.display='none';
  document.getElementById('ctl00_cphMain_rbtnMasterCard').checked = false;
  document.getElementById('ctl00_cphMain_btnProceedToPayment').disabled = true;
} else*/
 if(pType == "ctl00_cphMain_rbtnCashCards")
{
 document.getElementById('ctl00_cphMain_trPGType').style.display='';
  //document.getElementById('ctl00_cphMain_tdCdtCard').style.display='none';
  document.getElementById('ctl00_cphMain_tdCashCard').style.display='';
   document.getElementById('ctl00_cphMain_rbtnOxyCash').checked = false;
  document.getElementById('ctl00_cphMain_rbtnItzCard').checked = false;
  document.getElementById('ctl00_cphMain_ddlBanks').style.display='none';
   document.getElementById('ctl00_cphMain_btnProceedToPayment').disabled = true;
}
else if(pType == "ctl00_cphMain_rbtnNetBanking")
{
 document.getElementById('ctl00_cphMain_trPGType').style.display='';
 // document.getElementById('ctl00_cphMain_tdCdtCard').style.display='none';
  document.getElementById('ctl00_cphMain_tdCashCard').style.display='none';
   document.getElementById('ctl00_cphMain_ddlBanks').style.display='';
   document.getElementById('ctl00_cphMain_btnProceedToPayment').disabled = false;
}
else
{
 document.getElementById('ctl00_cphMain_trPGType').style.display='none';
  document.getElementById('ctl00_cphMain_btnProceedToPayment').disabled = false;
}
}
 
//------------------------  js for support,contactus,enquiryform added by sam on 18 nov 2010

function SetDetails()
{
var Qstr = querySt("error");
if(Qstr==null ) return;
else if(Qstr=='') {document.getElementById('lblmsg').innerHTML = unescape("Successfully submitted");return;}
else if (Qstr = "-1") {document.getElementById('lblmsg').innerHTML = unescape("Unable to process.Try again.");return;}
else {document.getElementById('lblmsg').innerHTML = unescape("Unable to process.Try again.");return;}
}

function ValidateForm()
{
 
var name =  document.forms[1].txtName;var email = document.forms[1].txtEmail;var mobileno = document.forms[1].txtMNo;
if((trim(name.value)==null)||(trim(name.value)=="")) {document.getElementById('lblmsg').innerHTML="* Enter Name";name.focus();return false;}
if((trim(email.value)==null)||(trim(email.value)=="")) {document.getElementById('lblmsg').innerHTML="* Enter EmailID";email.focus();return false;}
if(Techeck(trim(email.value))==false) {document.getElementById('lblmsg').innerHTML="* Invalid EmailID";email.focus();return false;}
if((trim(mobileno.value)==null)||(trim(mobileno.value)=="")) {document.getElementById('lblmsg').innerHTML="* Enter MobileNo";mobileno.focus();return false;}
if(!ValidateMobileNumber(mobileno,'lblmsg')) return false;
 
        
return true;
}
function ValidateFormFreeTrail()
{
 
var name =  document.forms[3].txtName;var email = document.forms[3].txtEmail;var mobileno = document.forms[3].txtMNo;
if((trim(name.value)==null)||(trim(name.value)=="")) {document.getElementById('lblmsg').innerHTML="* Enter Name";name.focus();return false;}
if((trim(email.value)==null)||(trim(email.value)=="")) {document.getElementById('lblmsg').innerHTML="* Enter EmailID";email.focus();return false;}
if(Techeck(trim(email.value))==false) {document.getElementById('lblmsg').innerHTML="* Invalid EmailID";email.focus();return false;}
if((trim(mobileno.value)==null)||(trim(mobileno.value)=="")) {document.getElementById('lblmsg').innerHTML="* Enter MobileNo";mobileno.focus();return false;}
if(!ValidateMobileNumber(mobileno,'lblmsg')) return false;
 
        
return true;
}

function imposeMaxLength(Object, MaxLen)
{
  return (Object.value.length <= MaxLen);
}

/*function ValidateMobileNumber(number)
{
   MobileNumber= number.value;
    var ErrorMsg;
   if(MobileNumber.length>10)
   {
     if(MobileNumber.length==12)
    {
       if(MobileNumber.substring(0,2)!="91")
       {
       ErrorMsg="* Number should begin with 91"
       }      
        else if(MobileNumber.substring(2,3)=="9")
       {
         ErrorMsg= ""  
       }
       else if(MobileNumber.substring(2,3)=="8")
       {
         ErrorMsg= ""  
       }      
       else
        ErrorMsg="*  Invalid Mobile Number."
    }
     else
    {
      ErrorMsg="*  Invalid Mobile Number"
    }   
  }
  else if(MobileNumber.length==10)
  {
   if(MobileNumber.substring(0,1)=="9"  )
   {
     ErrorMsg= ""   //"* Number should begin with 9 or 8"
   }
    else if(MobileNumber.substring(0,1)=="8"  )
    {
    ErrorMsg=""
    }
    else
    {
     ErrorMsg= "*  Invalid Mobile Number."
    }
  }
 else if(MobileNumber.length>0)
 {
  var Digits="0123456789";
  for(var i=0;i<MobileNumber.length-1;i++)
   {  
   if(Digits.indexOf(MobileNumber.charAt(i))==-1)  
    ErrorMsg="*  Invalid Mobile Number"  
  } 
 }
else if(MobileNumber.length==0)
{
ErrorMsg="*  Enter Mobile Number"
}
document.getElementById(lbl).innerHTML=ErrorMsg

if((MobileNumber.length<10)&&(MobileNumber.length>0))
{
document.getElementById(lbl).innerHTML="*  Invalid Mobile Number"
number.focus()
}
if((ErrorMsg==null)||(ErrorMsg==""))
{
return true
}
else
{
return false
}
}
*/


// below script is update by narasimha 5:32 pm
function SelectAPIURL(rbtn)
{

var pType = rbtn.id;

/*
if(document.getElementById('ctl00_cphMain_tbcCompose_tbpApi_ctl17_hid_text').value == '')
{
    
    document.getElementById('ctl00_cphMain_tbcCompose_tbpApi_ctl17_hid_text').value = document.getElementById('ctl00_cphMain_tbcCompose_tbpApi_ctl17_ancComposeUrl').innerHTML;
} 
if(document.getElementById('ctl00_cphMain_tbcCompose_tbpApi_ctl17_hid_unicode').value=='')
{
    
    document.getElementById('ctl00_cphMain_tbcCompose_tbpApi_ctl17_hid_unicode').value = document.getElementById('ctl00_cphMain_tbcCompose_tbpApi_ctl17_ancComposeUnicodeUrl').innerHTML;
} 
if(document.getElementById('ctl00_cphMain_tbcCompose_tbpApi_ctl17_hid_flash').value=='')
{ 
    document.getElementById('ctl00_cphMain_tbcCompose_tbpApi_ctl17_hid_flash').value = document.getElementById('ctl00_cphMain_tbcCompose_tbpApi_ctl17_ancComposeFlashUrl').innerHTML;
} 
if(document.getElementById('ctl00_cphMain_tbcCompose_tbpApi_ctl17_hid_rwurl').value=='')
{
   document.getElementById('ctl00_cphMain_tbcCompose_tbpApi_ctl17_hid_rwurl').value = document.getElementById('ctl00_cphMain_tbcCompose_tbpApi_ctl17_ancComposeRWUrl').innerHTML;
} */
document.getElementById('ctl00_cphMain_tbcCompose_tbpApi_ctl17_ancComposeUrl').innerHTML = '';
document.getElementById('ctl00_cphMain_tbcCompose_tbpApi_ctl17_ancComposeUnicodeUrl').innerHTML = '';
document.getElementById('ctl00_cphMain_tbcCompose_tbpApi_ctl17_ancComposeFlashUrl').innerHTML = '';
document.getElementById('ctl00_cphMain_tbcCompose_tbpApi_ctl17_ancComposeRWUrl').innerHTML = '';
 document.getElementById('ctl00_cphMain_tbcCompose_tbpApi_ctl17_hyp_ancComposeUnicodeUrl').innerHTML='';
 
 if(pType == "ctl00_cphMain_tbcCompose_tbpApi_ctl17_rbText")
{
 document.getElementById('ctl00_cphMain_tbcCompose_tbpApi_ctl17_ancComposeUrl').style.display='';
 document.getElementById('ctl00_cphMain_tbcCompose_tbpApi_ctl17_ancComposeUnicodeUrl').style.display='none';
 document.getElementById('ctl00_cphMain_tbcCompose_tbpApi_ctl17_ancComposeFlashUrl').style.display='none';
 document.getElementById('ctl00_cphMain_tbcCompose_tbpApi_ctl17_ancComposeRWUrl').style.display='none';
 document.getElementById('ctl00_cphMain_tbcCompose_tbpApi_ctl17_hyp_ancComposeUnicodeUrl').style.display='none';
document.getElementById('ctl00_cphMain_tbcCompose_tbpApi_ctl17_ancComposeUrl').innerHTML = document.getElementById('ctl00_cphMain_tbcCompose_tbpApi_ctl17_hid_text').value; 
 
}
else if(pType == "ctl00_cphMain_tbcCompose_tbpApi_ctl17_rbUnicode")
{
 document.getElementById('ctl00_cphMain_tbcCompose_tbpApi_ctl17_ancComposeUrl').style.display='none';
 document.getElementById('ctl00_cphMain_tbcCompose_tbpApi_ctl17_ancComposeUnicodeUrl').style.display='';
 document.getElementById('ctl00_cphMain_tbcCompose_tbpApi_ctl17_ancComposeFlashUrl').style.display='none';
 document.getElementById('ctl00_cphMain_tbcCompose_tbpApi_ctl17_ancComposeRWUrl').style.display='none';
 document.getElementById('ctl00_cphMain_tbcCompose_tbpApi_ctl17_hyp_ancComposeUnicodeUrl').style.display='';
document.getElementById('ctl00_cphMain_tbcCompose_tbpApi_ctl17_ancComposeUnicodeUrl').innerHTML = document.getElementById('ctl00_cphMain_tbcCompose_tbpApi_ctl17_hid_unicode').value;  
document.getElementById('ctl00_cphMain_tbcCompose_tbpApi_ctl17_hyp_ancComposeUnicodeUrl').innerHTML='Unicode Converter';
}
else if(pType == "ctl00_cphMain_tbcCompose_tbpApi_ctl17_rbFlash")
{
 document.getElementById('ctl00_cphMain_tbcCompose_tbpApi_ctl17_ancComposeUrl').style.display='none';
 document.getElementById('ctl00_cphMain_tbcCompose_tbpApi_ctl17_ancComposeUnicodeUrl').style.display='none';
 document.getElementById('ctl00_cphMain_tbcCompose_tbpApi_ctl17_ancComposeFlashUrl').style.display='';
 document.getElementById('ctl00_cphMain_tbcCompose_tbpApi_ctl17_ancComposeRWUrl').style.display='none';
 document.getElementById('ctl00_cphMain_tbcCompose_tbpApi_ctl17_hyp_ancComposeUnicodeUrl').style.display='none';
 document.getElementById('ctl00_cphMain_tbcCompose_tbpApi_ctl17_ancComposeFlashUrl').innerHTML = document.getElementById('ctl00_cphMain_tbcCompose_tbpApi_ctl17_hid_flash').value;  
 
}
else if(pType == "ctl00_cphMain_tbcCompose_tbpApi_ctl17_rbRingTone")
{
 document.getElementById('ctl00_cphMain_tbcCompose_tbpApi_ctl17_ancComposeUrl').style.display='none';
 document.getElementById('ctl00_cphMain_tbcCompose_tbpApi_ctl17_ancComposeUnicodeUrl').style.display='none';
 document.getElementById('ctl00_cphMain_tbcCompose_tbpApi_ctl17_ancComposeFlashUrl').style.display='none';
 document.getElementById('ctl00_cphMain_tbcCompose_tbpApi_ctl17_ancComposeRWUrl').style.display='';
 document.getElementById('ctl00_cphMain_tbcCompose_tbpApi_ctl17_hyp_ancComposeUnicodeUrl').style.display='none';
 document.getElementById('ctl00_cphMain_tbcCompose_tbpApi_ctl17_ancComposeRWUrl').innerHTML = document.getElementById('ctl00_cphMain_tbcCompose_tbpApi_ctl17_hid_rwurl').value;  
}

}

function SearchnulltoOther(page)
{
    if(page=='home')
    {
        document.getElementById('txtMobile').value="";
        document.getElementById('txtEmailID').value="";
        document.getElementById('txtPassword').value="";
           
    }
    return true;
}


function SinglePicSelection(selObj) 
  {  
      // var items=document.Form1 ; //your form name     
 
           for(var i=0;i<document.forms[0].elements.length;i++) 
            {
              elm = document.forms[0].elements[i];             
               if (elm.type == 'radio')//detect radio button
                {   
                   if(document.forms[0].elements[i].id.indexOf('ctl00_cphMain_tbcCompose_tbpPicMsg_dlPicMsg')>-1)//datalist name
                    document.forms[0].elements[i].checked=false; 
                 }
            } 
             selObj.checked=true; 

             if(trim(selObj.value).length >0)
            {     
              
              var array2 = selObj.value.split("\\\\") ;             
             var img = document.createElement("IMG");
	         img.src = "https://www.mVaayoo.com//mVaayooPicImgs//"+array2[4].replace("otb","gif"); 

	        var y = document.getElementById('ctl00_cphMain_tbcCompose_tbpPicMsg_txtPicPreview'), child;
            while(child=y.firstChild)
            y.removeChild(child);
	        document.getElementById('ctl00_cphMain_tbcCompose_tbpPicMsg_txtPicPreview').appendChild(img);
	        } 
}