function startclock()
{
var thetime=new Date();

var nhours=thetime.getHours();
var nmins=thetime.getMinutes();
var nsecn=thetime.getSeconds();
var nday=thetime.getDay();
var nmonth=thetime.getMonth();
var ntoday=thetime.getDate();
var nyear=thetime.getYear();
var AorP=" ";
var monthName="";

if (nhours>=12)
    AorP="P.M.";
else
    AorP="A.M.";

if (nhours>=13)
    nhours-=12;

if (nhours==0)
   nhours=12;

if (nsecn<10)
 nsecn="0"+nsecn;

if (nmins<10)
 nmins="0"+nmins;

if (nmonth==0)
  monthName="January";
if (nmonth==1)
  monthName="February";
if (nmonth==2)
  monthName="March";
if (nmonth==3)
  monthName="April";
if (nmonth==4)
  monthName="May";
if (nmonth==5)
  monthName="June";
if (nmonth==6)
  monthName="July";
if (nmonth==7)
  monthName="August";
if (nmonth==8)
  monthName="September";
if (nmonth==9)
  monthName="October";
if (nmonth==10)
  monthName="November";
if (nmonth==11)
  monthName="December";

//nmonth+=1;

if (nyear<=99)
  nyear= "19"+nyear;

if ((nyear>99) && (nyear<2000))
 nyear+=1900;

document.all.clock.innerHTML=monthName+" "+ntoday+", "+nyear+" "+nhours+":"+nmins+":"+nsecn+" "+AorP+" PST";

setTimeout('startclock()',1000);
} 
/**************************************************************
 AllowOnly: This function allow entering just the specified
            Expression to a textbox or textarea control.

 Parameters:
      Expression = Allowed characters.
                   a..z => ONLY LETTERS
                   0..9 => ONLY NUMBERS
                   other symbols...

 Example: use the onKeyPress event to make this function work:
          //Allows only from A to Z
          onKeyPress="AllowOnly('a..z');"

          //Allows only from 0 to 9
          onKeyPress="AllowOnly('0..9');"

          //Allows only A,B,C,1,2 and 3
          onKeyPress="AllowOnly('abc123');"

          //Allows only A TO Z,@,#,$ and %
          onKeyPress="AllowOnly('a..z|@#$%');"

		  //Allows only A,B,C,0 TO 9,.,,,+ and -
          onKeyPress="AllowOnly('ABC|0..9|.,+-');"

 Remarks: Use the pipe "|" symbol to separate a..z from 0..9 and symbols

 Returns: None
***************************************************************/
function AllowOnly(Expression)
{
	Expression = Expression.toLowerCase();
	Expression = Replace(Expression, 'a..z', 'abcdefghijklmnopqrstuvwxyz');
	Expression = Replace(Expression, '0..9', '0123456789');
	Expression = Replace(Expression, '|', '');

	var ch = String.fromCharCode(window.event.keyCode);
	ch = ch.toLowerCase();
	Expression = Expression.toLowerCase();
	var a = Expression.indexOf(ch);
	if (a == -1) 
		window.event.keyCode = 0;
}
/**************************************************************
 Replace: Returns a string in which a specified substring has 
          been replaced with another substring a specified 
          number of times.

 Parameters:
      Expression = String expression containing substring to 
                   replace
      Find       = Substring being searched for.
      Replace    = Replacement substring.

 Returns: String
***************************************************************/
function Replace(Expression, Find, Replace)
{
	var temp = Expression;
	var a = 0;

	for (var i = 0; i < Expression.length; i++) 
	{
		a = temp.indexOf(Find);
		if (a == -1)
			break
		else
			temp = temp.substring(0, a) + Replace + temp.substring((a + Find.length));
	}

	return temp;
}
function getHeader()
{
	links = new Array();
	links[0] = "<a href=speak.htm>Speak</a>";
	links[1] = "<a href=otherleadservices.htm>Other Lead Services</a>";
	links[2] = "<a href=leadgeneration.htm>Lead Generation Nirvana</a>";
	links[3] = "<a href=voicemessaging.htm>Voice Messaging</a>";
	links[4] = "<a href=voicebroadcasting.htm>Voice Broadcasting</a>";
	links[5] = "<a href=aboutus.htm>About Voice Traffic</a>";

	document.write("<div id=tab>");
	document.write("<ul>");
	document.write("<li>"+links[0]+"</li>");
	document.write("<li>"+links[1]+"</li>");
	document.write("<li>"+links[2]+"</li>");
	document.write("<li>"+links[3]+"</li>");
	document.write("<li>"+links[4]+"</li>");
	document.write("<li>"+links[5]+"</li>");
	document.write("</ul></div>");
	
}
function getLinks()
{
	var sep;
	links = new Array();
	
	sep = "&nbsp;|&nbsp;";
	
	links[0] = "<a href=index.htm>Home</a>";
	links[1] = "<a href=contact_us.htm>Contact Us</a>";
	links[2] = "<a href=aboutus.htm>About Us</a>";
	

	document.write("<div id=whitelinks>");
	document.write(links[0]+sep+links[1]+sep+links[2]);
	document.write("</div>");
	
}
function getFooter()
{
	var sep;
	links = new Array();
	sep = "&nbsp;|&nbsp;";
	
	links[0] = "<a href=index.htm>Home</a>";
	links[1] = "<a href=speak.htm>Speak</a>";
	links[2] = "<a href=otherleadservices.htm>Other Lead Services</a>";
	links[3] = "<a href=leadgeneration.htm>Lead Generation Nirvana</a>";
	links[4] = "<a href=voicemessaging.htm>Voice Messaging</a>";
	links[5] = "<a href=voicebroadcasting.htm>Voice Broadcasting</a>";
	links[6] = "<a href=aboutus.htm>About Voice Traffic</a>";
	
	document.write("<table id=footerlinks width=750 align=center cellpadding=5 cellspacing=0 border=0>");
	document.write("<td align=center>");
	document.write(links[0]+sep+links[1]+sep+links[2]+sep+links[3]+sep+links[4]+sep+links[5]+sep+links[6]);
	document.write("<p>&copy; 2007 <a href=index.htm>VoiceTraffic.net.</a>  All rights reserved.</p>");
	document.write("</td>");
	document.write("</table>");
}
function toCurrency( Field ) {

	var num = Field.value;
	
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
	num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10)
	cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
	num = num.substring(0,num.length-(4*i+3))+','+
	num.substring(num.length-(4*i+3));
	
	var retValue = (((sign)?'':'-') + '$' + num + '.' + cents);
	
	Field.value = retValue;
	//eval("document.all." + FieldToFormat + ".value = '" + retValue + "'");
}
//////////////////////////////////////////////////////////////////
// Checks for the maxlength and then sets focus to next fields
//////////////////////////////////////////////////////////////////
function checkLength(e){
   if (ns4){
      var key = e.which
      var el = e.target;
      var str = String(e.target);
      str = str.toLowerCase();
      if (str.indexOf('input') != -1){
         el.tagName = "INPUT"
      }
      else{
         return;
      }
      str = str.slice(str.indexOf('maxlength'), str.indexOf('maxlength')+14);
      str = str.slice(str.indexOf('=')+1, str.indexOf('=')+6);
      el.maxLength = parseInt(str);
      if (el.maxLength == -1){
         el.maxLength = 2147483647;
      }
   }
   else{
      var key = 0;
      var el = event.srcElement;
   }
   if (el.tagName=="INPUT" && key != 8 && el.type=="text"){
      if (el.value.length>=el.maxLength){
         var i;
         for(i=0; i<el.form.elements.length; i++){
            if (el==el.form.elements[i]){
               break;
            }
         }
         if (i != el.form.elements.length){
          el.form.elements[i+1].focus();
         }
         else {
            i=0;
            el.form.elements[i].focus();
         }
      }
   }
}
function getWSDL()
{
	IrmWebService.useService("http://www.instantresponse.org/IRMWebservice/EmailService.asmx?WSDL", "EmailService");
}
function getResult()
{
	window.location = "thankyou.htm";
}
function SendEmail()
{
	//callID = myWebService.IP2Country.callService("getCountry", txtIP.value);
	var arrVal = new Array(14);
	var arrCol = new Array(14);
				
	arrCol = getFormName();
	arrVal = getFormValue();
				
	callID = IrmWebService.EmailService.callService("SaveVoiceTrafficQuotes", arrVal, arrCol);
}
