function isaPosNum(s) {
return (parseInt(s) > 0)
}

function qty_check(item) {

var returnVal = false
for(var i=0; i<item.value.length;++i){
	if(item.value.substring(i,i+1)==" " || item.value.substring(i,i+1)=="-" || item.value.substring(i,i+1)=="+" || item.value.substring(i,i+1)=="(" || item.value.substring(i,i+1)==")"){item.value=item.value.substring(0,i)+item.value.substring(i+1,item.value.length); }
}
for(var i=0; i<item.value.length;++i){
	if(item.value.substring(i,i+1)==" " || item.value.substring(i,i+1)=="-" || item.value.substring(i,i+1)=="+" || item.value.substring(i,i+1)=="(" || item.value.substring(i,i+1)==")"){item.value=item.value.substring(0,i)+item.value.substring(i+1,item.value.length); }
}
for(var i=0; i<item.value.length;++i){
	if(item.value.substring(i,i+1)!="0" && item.value.substring(i,i+1)!="1" && item.value.substring(i,i+1)!="2" && item.value.substring(i,i+1)!="3" && item.value.substring(i,i+1)!="4"  && item.value.substring(i,i+1)!="5"  && item.value.substring(i,i+1)!="6"  && item.value.substring(i,i+1)!="7" && item.value.substring(i,i+1)!="8" && item.value.substring(i,i+1)!="9"){alert("The Phone Number must only have numbers"); return false; }
}

if (!isaPosNum(item.value)){ alert("Please enter a valid phone number:\nUse: 1+Area Code+Number (for USA, Canada, Bermuda, Caribbean) \n011+Country Code+City Code+Number (For International locations)");return returnVal;}

//else if(item.value.substring(0,1)!="1" && item.value.substring(0,1)!="0"){item.value="1"+item.value;}

if(item.value.substring(0,4)=="1800" || item.value.substring(0,4)=="1888" || item.value.substring(0,4)=="1877" || item.value.substring(0,4)=="1866"){alert("The Toll-Free phone number:" + item.value + " is not accessible on this service."); return false }
else if(item.value.substring(0,4)=="1900"){alert("The Phone number:" + item.value + " is not accessible on this service."); return false }

else if(item.value.substring(0,1)=="1" && parseInt(item.value.length) > 11){alert("Please enter a valid phone number:\nUse: 1+Area Code+Number (for USA, Canada, Bermuda, Caribbean) \n011+Country Code+City Code+Number (For Other Locations)"); return false }
else if(item.value.substring(0,1)!="1" && item.value.substring(0,3)!="011"){alert("Please enter a valid phone number:\nUse: 1+Area Code+Number (for USA, Canada, Bermuda, Caribbean) \n011+Country Code+City Code+Number (For Other Locations)"); return false }
else if (parseInt(item.value.length) < 11){alert("Please enter a valid phone number:\nUse: 1+Area Code+Number (for USA, Canada, Bermuda, Caribbean) \n011+Country Code+City Code+Number (For Other Locations)");return false;}
else if (parseInt(item.value.length) > 19){alert("Please enter a valid phone number:\nUse: 1+Area Code+Number (for USA, Canada, Bermuda, Caribbean) \n011+Country Code+City Code+Number (For Other Locations)");return false;}
else if(item.value.substring(0,1)!="1" && item.value.substring(0,3)!="011"){alert("Please enter a valid phone number:\nUse: 1+Area Code+Number (for USA, Canada, Bermuda, Caribbean) \n011+Country Code+City Code+Number (For Other Locations)"); return false }
else if(item.value.substring(0,1)=="1" || item.value.substring(0,3)=="011"){return true }
else return false
}


function validateAndSubmit(theform) {
if (theform.Rlist.value.length==0){alert("Please enter your the phone number(s) or a text file with the phone numbers."); return false; }
if(theform.VoxxMessage.options.selectedIndex == 0){alert("Please Select the Message to be Delivered"); return false; }

selectedmonth=theform.Month.options.selectedIndex;
thehour = theform.hour.options[theform.hour.options.selectedIndex].value
if(theform.R1.options[0].selected && thehour==12) thehour = parseInt(thehour) - 12 ;
else if(theform.R1.options[1].selected && thehour<12) thehour = parseInt(thehour) + 12 ;

theminute = theform.minute.options[theform.minute.options.selectedIndex].value
theday = theform.Day.options[theform.Day.options.selectedIndex].value
themonth = theform.Month.options[theform.Month.options.selectedIndex - 1].value
theyear = theform.Year.options[theform.Year.options.selectedIndex].value

// Server offset from GMT
var tday= new Date();
var y1 = new Date(theyear,themonth,theday,thehour,theminute,0);

//getTime() converts time to milliseconds
if(y1.getTime()<tday.getTime()- 3600*1000){alert("Please select a Date/Time that is greater than the present time"); return false;}
//if(tday.getTime() - y1.getTime() < 3*60*1000)y1=new Date(tday.getTime() - 3*60*1000)


timezoneoffset = y1.getTimezoneOffset()
// Calculate Future date in GTM
futuredate = new Date(y1.getTime() + timezoneoffset*60*1000 )
// Adjust future date for server offset
futureserverdate = new Date(futuredate - theform.shour.value*3600*1000)

theform.xdate.value = (futureserverdate.getMonth()+1) + "/" + futureserverdate.getDate() + "/" + futureserverdate.getFullYear()
theform.xhour.value = (futureserverdate.getHours())
theform.xminute.value = (futureserverdate.getMinutes())
}
function t2pfvalidateAndSubmit(theform) {
if (theform.userphonenumber.value.length==0){alert("Please enter your the phone number(s) or a text file with the phone numbers."); return false; }
if(theform.textMessage.value == ""){alert("Please type the Message to be Delivered"); return false; }
if(dxdate(theform)==false)return false;
}

function vox2pvalidateAndSubmit(theform) {
if (theform.Rlist.value.length==0){alert("Please enter your the phone number(s) or a text file with the phone numbers."); return false; }
if(theform.VoxxMessage.options.selectedIndex == 0){alert("Please Select the Message to be Delivered"); return false; }
if(dxdate(theform)==false)return false;
}
function t2pvalidateAndSubmit(theform) {
if (theform.Rlist.value.length==0){alert("Please enter your the phone number(s) or a text file with the phone numbers."); return false; }
if(theform.textMessage.value == ""){alert("Please type the Message to be Delivered"); return false; }
if(dxdate(theform)==false)return false;
}
function t2prmvalidateAndSubmit(theform) {
if(theform.textMessage.value == ""){alert("Please type the Message to be Delivered"); return false; }
if(dxdate(theform)==false)return false;
//if(qty_check(theform.userphonenumber)==false)return false;
}
function w2pvalidateAndSubmit(theform) {
if (theform.userphonenumber.value.length==0){alert("Please enter your the phone number(s) or a text file with the phone numbers."); return false; }
if(dxdate(theform)==false)return false;
}
function validateeMessageAndSubmit(theform) {
if(dxdate(theform)==false)return false;
else return true;
}
function dxdate(theform){
myshour = parseInt(theform.myshour.value)
selectedmonth=theform.Month.options.selectedIndex;
thehour = theform.hour.options[theform.hour.options.selectedIndex].value
if(theform.R1.options[0].selected && thehour==12) thehour = parseInt(thehour) - 12 ;
else if(theform.R1.options[1].selected && thehour<12) thehour = parseInt(thehour) + 12 ;
theminute = theform.minute.options[theform.minute.options.selectedIndex].value

theday = theform.Day.options[theform.Day.options.selectedIndex].value
themonth = theform.Month.options[theform.Month.options.selectedIndex].value
theyear = theform.Year.options[theform.Year.options.selectedIndex].value
// Server offset from GMT
var tday= new Date();
var y1 = new Date(theyear,themonth - 1,theday,thehour,theminute,0);
//getTime() will converts time to milliseconds
if(y1.getTime()<tday.getTime()- 3600*1000){alert("Please select a Date/Time that is greater than the present time"); return false;}
timezoneoffset = tday.getTimezoneOffset()
// Convert requested date to GTM
y1.setHours(y1.getHours()+tday.getTimezoneOffset()/60)
// Adjust y1 date for wpb offset
//y1.setHours(y1.getHours()-5)
y1.setHours(y1.getHours()-myshour)
theform.xdate.value = y1.getMonth()+1 + "/" + y1.getDate() + "/" + y1.getFullYear()
theform.xhour.value = (y1.getHours())
theform.xminute.value = (y1.getMinutes())
}

function t2pinit()
{
var tday= new Date();
tday.getTime();
y=tday.getFullYear();
m=tday.getMonth();
d=tday.getDate();
h=tday.getHours();
n=tday.getMinutes();

if(m=="0")document.theform.Month.options[0].selected = true;
else if(m=="1")document.theform.Month.options[1].selected = true;
else if(m=="2")document.theform.Month.options[2].selected = true;
else if(m=="3")document.theform.Month.options[3].selected = true;
else if(m=="4")document.theform.Month.options[4].selected = true;
else if(m=="5")document.theform.Month.options[5].selected = true;
else if(m=="6")document.theform.Month.options[6].selected = true;
else if(m=="7")document.theform.Month.options[7].selected = true;
else if(m=="8")document.theform.Month.options[8].selected = true;
else if(m=="9")document.theform.Month.options[9].selected = true;
else if(m=="10")document.theform.Month.options[10].selected = true;
else if(m=="11")document.theform.Month.options[11].selected = true;
if(d=="1")document.theform.Day.options[0].selected = true;
else if(d=="2")document.theform.Day.options[1].selected = true;
else if(d=="3")document.theform.Day.options[2].selected = true;
else if(d=="4")document.theform.Day.options[3].selected = true;
else if(d=="5")document.theform.Day.options[4].selected = true;
else if(d=="6")document.theform.Day.options[5].selected = true;
else if(d=="7")document.theform.Day.options[6].selected = true;
else if(d=="8")document.theform.Day.options[7].selected = true;
else if(d=="9")document.theform.Day.options[8].selected = true;
else if(d=="10")document.theform.Day.options[9].selected = true;
else if(d=="11")document.theform.Day.options[10].selected = true;
else if(d=="12")document.theform.Day.options[11].selected = true;
else if(d=="13")document.theform.Day.options[12].selected = true;
else if(d=="14")document.theform.Day.options[13].selected = true;
else if(d=="15")document.theform.Day.options[14].selected = true;
else if(d=="16")document.theform.Day.options[15].selected = true;
else if(d=="17")document.theform.Day.options[16].selected = true;
else if(d=="18")document.theform.Day.options[17].selected = true;
else if(d=="19")document.theform.Day.options[18].selected = true;
else if(d=="20")document.theform.Day.options[19].selected = true;
else if(d=="21")document.theform.Day.options[20].selected = true;
else if(d=="22")document.theform.Day.options[21].selected = true;
else if(d=="23")document.theform.Day.options[22].selected = true;
else if(d=="24")document.theform.Day.options[23].selected = true;
else if(d=="25")document.theform.Day.options[24].selected = true;
else if(d=="26")document.theform.Day.options[25].selected = true;
else if(d=="27")document.theform.Day.options[26].selected = true;
else if(d=="28")document.theform.Day.options[27].selected = true;
else if(d=="29")document.theform.Day.options[28].selected = true;
else if(d=="30")document.theform.Day.options[29].selected = true;
else if(d=="31")document.theform.Day.options[30].selected = true;

if(h<12)document.theform.R1.options[0].selected=true;
else if(h>=12)document.theform.R1.options[1].selected=true;
//if(h==23)document.theform.R1[0].checked=true;

if(h=="1" || h==13)document.theform.hour.options[0].selected = true;
else if(h=="2" || h==14)document.theform.hour.options[1].selected = true;
else if(h=="3" || h==15)document.theform.hour.options[2].selected = true;
else if(h=="4" || h==16)document.theform.hour.options[3].selected = true;
else if(h=="5" || h==17)document.theform.hour.options[4].selected = true;
else if(h=="6" || h==18)document.theform.hour.options[5].selected = true;
else if(h=="7" || h==19)document.theform.hour.options[6].selected = true;
else if(h=="8" || h==20)document.theform.hour.options[7].selected = true;
else if(h=="9" || h==21)document.theform.hour.options[8].selected = true;
else if(h=="10" || h==22)document.theform.hour.options[9].selected = true;
else if(h=="11" || h==23)document.theform.hour.options[10].selected = true;
else if(h=="12" || h=="0")document.theform.hour.options[11].selected = true;

if(n>=55)document.theform.minute.options[11].selected = true;
else if(n>=50)document.theform.minute.options[10].selected = true;
else if(n>=45)document.theform.minute.options[9].selected = true;
else if(n>=40)document.theform.minute.options[8].selected = true;
else if(n>=35)document.theform.minute.options[7].selected = true;
else if(n>=30)document.theform.minute.options[6].selected = true;
else if(n>=25)document.theform.minute.options[5].selected = true;
else if(n>=20)document.theform.minute.options[4].selected = true;
else if(n>=15)document.theform.minute.options[3].selected = true;
else if(n>=10)document.theform.minute.options[2].selected = true;
else if(n>=5)document.theform.minute.options[1].selected = true;
else if(n>=0)document.theform.minute.options[0].selected = true;

document.theform.minute.options[12].selected = true;
if(n<10)document.theform.minute.options[12].text = "0" + n;
else document.theform.minute.options[12].text =n;
document.theform.minute.options[12].value = n;
document.theform.Year.options[0].selected = true;
document.theform.Year.options[0].text = y;
document.theform.Year.options[1].text =parseInt(y) + 1;
document.theform.Year.options[0].value = y;
document.theform.Year.options[1].value = parseInt(y) + 1;

//alert(document.theform.Year.options[0].value);
//alert(document.theform.Year.options[1].value);
//parseInt(s)
}
function InitDate()
{
var tday= new Date();
tday.getTime();
y=tday.getFullYear();
m=tday.getMonth();
d=tday.getDate();
h=tday.getHours();
n=tday.getMinutes();
if(m=="0")document.theform.Month.options[0].selected = true;
else if(m=="1")document.theform.Month.options[1].selected = true;
else if(m=="2")document.theform.Month.options[2].selected = true;
else if(m=="3")document.theform.Month.options[3].selected = true;
else if(m=="4")document.theform.Month.options[4].selected = true;
else if(m=="5")document.theform.Month.options[5].selected = true;
else if(m=="6")document.theform.Month.options[6].selected = true;
else if(m=="7")document.theform.Month.options[7].selected = true;
else if(m=="8")document.theform.Month.options[8].selected = true;
else if(m=="9")document.theform.Month.options[9].selected = true;
else if(m=="10")document.theform.Month.options[10].selected = true;
else if(m=="11")document.theform.Month.options[11].selected = true;
if(d=="1")document.theform.Day.options[0].selected = true;
else if(d=="2")document.theform.Day.options[1].selected = true;
else if(d=="3")document.theform.Day.options[2].selected = true;
else if(d=="4")document.theform.Day.options[3].selected = true;
else if(d=="5")document.theform.Day.options[4].selected = true;
else if(d=="6")document.theform.Day.options[5].selected = true;
else if(d=="7")document.theform.Day.options[6].selected = true;
else if(d=="8")document.theform.Day.options[7].selected = true;
else if(d=="9")document.theform.Day.options[8].selected = true;
else if(d=="10")document.theform.Day.options[9].selected = true;
else if(d=="11")document.theform.Day.options[10].selected = true;
else if(d=="12")document.theform.Day.options[11].selected = true;
else if(d=="13")document.theform.Day.options[12].selected = true;
else if(d=="14")document.theform.Day.options[13].selected = true;
else if(d=="15")document.theform.Day.options[14].selected = true;
else if(d=="16")document.theform.Day.options[15].selected = true;
else if(d=="17")document.theform.Day.options[16].selected = true;
else if(d=="18")document.theform.Day.options[17].selected = true;
else if(d=="19")document.theform.Day.options[18].selected = true;
else if(d=="20")document.theform.Day.options[19].selected = true;
else if(d=="21")document.theform.Day.options[20].selected = true;
else if(d=="22")document.theform.Day.options[21].selected = true;
else if(d=="23")document.theform.Day.options[22].selected = true;
else if(d=="24")document.theform.Day.options[23].selected = true;
else if(d=="25")document.theform.Day.options[24].selected = true;
else if(d=="26")document.theform.Day.options[25].selected = true;
else if(d=="27")document.theform.Day.options[26].selected = true;
else if(d=="28")document.theform.Day.options[27].selected = true;
else if(d=="29")document.theform.Day.options[28].selected = true;
else if(d=="30")document.theform.Day.options[29].selected = true;
else if(d=="31")document.theform.Day.options[30].selected = true;

document.theform.Year.options[0].selected = true;
document.theform.Year.options[0].text = y;
document.theform.Year.options[1].text =parseInt(y) + 1;
document.theform.Year.options[0].value = y;
document.theform.Year.options[1].value = parseInt(y) + 1;

}
function zxdate(theform){
selecteddate=theform.qdate.value
//selectedmonth=theform.Month.options.selectedIndex;
myshour = parseInt(theform.myshour.value)

thehour = theform.hour.options[theform.hour.options.selectedIndex].value
if(theform.R1.options[0].selected && thehour==12) thehour = parseInt(thehour) - 12 ;
else if(theform.R1.options[1].selected && thehour<12) thehour = parseInt(thehour) + 12 ;
theminute = theform.minute.options[theform.minute.options.selectedIndex].value

var tday= new Date(); // Current datetime of computer
var y1 = new Date(selecteddate + " " + thehour + ":" + theminute); // datetime selected by user
//getTime(): this converts time to milliseconds from 1970
if(y1.getTime()<tday.getTime()- 3600*1000){alert("Please select a Date/Time that is greater than the present time"); return false;}
//timezoneoffset = y1.getTimezoneOffset()
timezoneoffset = tday.getTimezoneOffset()
// Calculate Future date in GTM
y1.setHours(y1.getHours()+tday.getTimezoneOffset()/60)
//y1.setHours(y1.getHours()-5)
y1.setHours(y1.getHours()-myshour)
theform.xdate.value = y1.getMonth()+1 + "/" + y1.getDate() + "/" + y1.getFullYear()
theform.xhour.value = (y1.getHours())
theform.xminute.value = (y1.getMinutes())
return true;
}
function InitTime()
{
var tday= new Date();
tday.getTime();
h=tday.getHours();
n=tday.getMinutes();

if(h<12)document.theform.R1.options[0].selected=true;
else if(h>=12)document.theform.R1.options[1].selected=true;
//if(h==23)document.theform.R1[0].checked=true;

if(h=="1" || h==13)document.theform.hour.options[0].selected = true;
else if(h=="2" || h==14)document.theform.hour.options[1].selected = true;
else if(h=="3" || h==15)document.theform.hour.options[2].selected = true;
else if(h=="4" || h==16)document.theform.hour.options[3].selected = true;
else if(h=="5" || h==17)document.theform.hour.options[4].selected = true;
else if(h=="6" || h==18)document.theform.hour.options[5].selected = true;
else if(h=="7" || h==19)document.theform.hour.options[6].selected = true;
else if(h=="8" || h==20)document.theform.hour.options[7].selected = true;
else if(h=="9" || h==21)document.theform.hour.options[8].selected = true;
else if(h=="10" || h==22)document.theform.hour.options[9].selected = true;
else if(h=="11" || h==23)document.theform.hour.options[10].selected = true;
else if(h=="12" || h=="0")document.theform.hour.options[11].selected = true;

if(n>=55)document.theform.minute.options[11].selected = true;
else if(n>=50)document.theform.minute.options[10].selected = true;
else if(n>=45)document.theform.minute.options[9].selected = true;
else if(n>=40)document.theform.minute.options[8].selected = true;
else if(n>=35)document.theform.minute.options[7].selected = true;
else if(n>=30)document.theform.minute.options[6].selected = true;
else if(n>=25)document.theform.minute.options[5].selected = true;
else if(n>=20)document.theform.minute.options[4].selected = true;
else if(n>=15)document.theform.minute.options[3].selected = true;
else if(n>=10)document.theform.minute.options[2].selected = true;
else if(n>=5)document.theform.minute.options[1].selected = true;
else if(n>=0)document.theform.minute.options[0].selected = true;

document.theform.minute.options[12].selected = true;
if(n<10)document.theform.minute.options[12].text = "0" + n;
else document.theform.minute.options[12].text =n;
document.theform.minute.options[12].value = n;

}
