﻿// JScript File
var mediaItems;
var currentPage  = 1;
var totalItems;

//Load StarzPlay Video
function showmovie(movieFile){
   var so = new SWFObject("/Shop/images/Starz/Player/verizon_flvAS2_videoPlayer.swf", "mymovie", "324", "264", "8");
   so.addVariable("movie",movieFile);
   so.addParam("quality", "high");
   so.addParam("wmode", "transparent");
   so.write("flashcontent");
}

// Load Box Art and Titles, Pagenation
function loadPage(strDirection)
 {
   //debugger;
    mediaItems = Verizon.Surround.Web.Shop_Entertainment_StarzPlay.getMediaItems(); 
   //debugger;
   //alert(mediaItems.value.length);
   totalItems = mediaItems.value.length;
   var iresult = totalItems / 10 | 0; 
   var irem = totalItems % 10;
   var totalPages;
   if (irem > 0)
        {
            iresult += 1;
        }
   totalPages = iresult;
   //alert(totalPages);
   
   var lblPage =  document.getElementById("ctl00_ctl00_Body_mainBody_lblPageNumber");
     
    switch(strDirection)
    {
        case "Prev":
           if (lblPage !=null)
            {
                if (currentPage <=1)
                {
                    lblPage.innerHTML = "<span class=\"Bold FS2\">"+currentPage+"</span>" + " of "+ totalPages;
                    DisplayPage(currentPage, mediaItems)
                    currentPage=1;
                }
                else
                {
                    lblPage.innerHTML = "<span class=\"Bold FS2\">"+(currentPage-1)+"</span>" + " of "+ totalPages;
                    DisplayPage(currentPage-1, mediaItems)
                    currentPage--;
                }
            }
          break;
        case "Next":
            if (lblPage !=null)
            {
                if (currentPage == totalPages)
                {
                    lblPage.innerHTML = "<span class=\"Bold FS2\">"+currentPage+"</span>" + " of "+ totalPages;
                    DisplayPage(currentPage, mediaItems)
                    currentPage=totalPages;
                }
                else
                {
                    lblPage.innerHTML = "<span class=\"Bold FS2\">"+(currentPage+1)+"</span>" + " of "+ totalPages;
                    DisplayPage(currentPage+1, mediaItems)
                    currentPage++;
                }
            }
           break;
         case "Last":
            if (lblPage !=null)
            {
                lblPage.innerHTML = "<span class=\"Bold FS2\">"+totalPages+"</span>" + " of "+ totalPages;
            }
            DisplayPage(totalPages, mediaItems)
            currentPage= totalPages;
            break;
        case "First":
            if (lblPage !=null)
            {
                lblPage.innerHTML = "<span class=\"Bold FS2\">"+1 +"</span>" + " of "+ totalPages;
            }
            DisplayPage(1, mediaItems)
            currentPage = 1;
          break;
        default:
            break;
   
    }
}
 
function DisplayPage(pageNumber, mediaItems)
{
    
        imgIds = ["ctl00_ctl00_Body_mainBody_img1","ctl00_ctl00_Body_mainBody_img2","ctl00_ctl00_Body_mainBody_img3", "ctl00_ctl00_Body_mainBody_img4", "ctl00_ctl00_Body_mainBody_img5", "ctl00_ctl00_Body_mainBody_img6", "ctl00_ctl00_Body_mainBody_img7", "ctl00_ctl00_Body_mainBody_img8", "ctl00_ctl00_Body_mainBody_img9","ctl00_ctl00_Body_mainBody_img10"];
        label = ["ctl00_ctl00_Body_mainBody_Label1","ctl00_ctl00_Body_mainBody_Label2","ctl00_ctl00_Body_mainBody_Label3", "ctl00_ctl00_Body_mainBody_Label4", "ctl00_ctl00_Body_mainBody_Label5", "ctl00_ctl00_Body_mainBody_Label6", "ctl00_ctl00_Body_mainBody_Label7", "ctl00_ctl00_Body_mainBody_Label8", "ctl00_ctl00_Body_mainBody_Label9","ctl00_ctl00_Body_mainBody_Label10"];
        
        var startIndex;
       
        if (pageNumber > 1)
        {
            startIndex = (pageNumber-1) * 10;
        }
        else
        {
            startIndex = pageNumber-1;  
        }
        

        for (var i = 0; i < 10; i++)
        {
             
            var img = document.getElementById(imgIds[i]);
            var lbl = document.getElementById(label[i]);
            if (img !=null && lbl!= null)
            {
                if (startIndex < totalItems)
                {
                    var actors = mediaItems.value[startIndex].Actors;
                    var strActors ="";
                    for (var j = 0; j < actors.length; j++)
                    {
                        if (j == actors.length - 1)
                            strActors = strActors + actors[j];
                        else
                            strActors = strActors + actors[j]+", ";

                    }
                       
                    trimTitle= mediaItems.value[startIndex].Title;
                    if (trimTitle.length > 15)
                        trimTitle = trimTitle.substring(0, 15) + '...';
                    lbl.innerHTML = trimTitle;
                    lbl.title = mediaItems.value[startIndex].Title;
                     //lbl.attributes("title") = mediaItems.value[startIndex].Title;
                    lbl.style.visibility="visible";
                    
                    img.src = mediaItems.value[startIndex].ImageUrl;
                    //img.title = "Title: " + mediaItems.value[startIndex].Title + "\nRating: " + mediaItems.value[startIndex].Rating +  "\nActors: " + strActors ;
                    img.style.visibility="visible";
                }
                else
                {
                     img.style.visibility="hidden";
                     lbl.style.visibility="hidden";
                }
                startIndex += 1;
            }
            
        }

    
}
 
  

 
 // JavaScript Document

/* Popup Scripts */
/* Function to show/hide drop downs */
function hideDropDown() {
	var pgdrop1 = document.getElementsByTagName("select");
	for(i=0;i<pgdrop1.length;i++)
	pgdrop1[i].style.visibility='hidden';
}

function showDropDown() {
	var pgdrop2 = document.getElementsByTagName("select");
	for(i=0;i<pgdrop2.length;i++)
	pgdrop2[i].style.visibility='visible';
}


function hideDivPopUp(){
	showDropDown();
	document.getElementById('EmptyDiv').style.display = "none";
	document.getElementById('DivPopUp').style.display = "none";
}

//<!-- begin post download iframe -->

function beginDownload() {
  idl = -1;
  idl = location.search.indexOf("idl=n");
  if (idl < 0) 
  {
	document.getElementById('downloadDiv').style.display = "block";
    document.getElementById('downloadDiv').innerHTML ='<iframe height="0" width="0" src="http://www.verizon.net/starzplaydownload/default.asp"></iframe>';
  }
}

//window.onLoad=beginDownload();
//-->
//</script><noscript><iframe height="0" width="0" src="http://www.verizon.net/starzplaydownload/default.asp"></iframe></noscript>
//<!-- end post download iframe -->

function showDivPopup(DivTitle,DivId)
{
	hideDropDown();
	document.getElementById('EmptyDiv').style.height = document.body.scrollHeight-10;
	document.getElementById('EmptyDiv').style.width = document.body.scrollWidth-10;
	document.getElementById('EmptyDiv').style.display = "block";
	DivX=(document.body.clientWidth)/2-300;
	DivY=(document.body.clientHeight)/2-150;
	document.getElementById('DivPopUp').style.left = DivX;
	document.getElementById('DivPopUp').style.top = "185px";
	document.getElementById('DivPopUp').style.display = "block";
	document.getElementById('DivPopUp').innerHTML = '<div>'+
	'<div class="BgTile1 LH2 Bdr2"><div class="Fl Txt4 LPad1">'+DivTitle+'</div><div class="CloseIcon Fr" onclick="hideDivPopUp()" title="Close"></div>'+
	'</div>'+  
	'<div class="BgTile2 Pad4 Bdr1" id="DivPopUpM"></div>'+ 
	'</div>';
	if(DivId == "LearnMore"){
	document.getElementById('DivPopUpM').innerHTML = '<table width="100%" align="center" border="0" cellspacing="0" cellpadding="0">'+
	'<tr><td colspan="2" height="10"></td></tr>'+
   	'<tr>'+
	'<td valign="top" width="100%">'+
		'<table width="100%" align="center" border="0" cellspacing="0" cellpadding="0">'+
		'<tr>'+
		//'<td valign="top" class="Txt5" colspan="2" height="50">Order today and enjoy unlimited movie and video downloads for as low as $5.99 per month </td>'+
		//'</tr>'+
		'<td valign="top" class="Txt5" colspan="2" height="50">Order today and enjoy unlimited movie and video downloads for as low as $5.99 per month <br /> <span style="font-size:10px">($9.99 per month for customers who are not subscribers to verizon FiOS or Verizon High Speed Internet).</span></td>'+
		'</tr>'+
		'<tr>'+
		'<td height="45" width="75" nowrap><div class="Step1Icon" title="Step1"></div></td>'+
		'<td class="Txt7" width="85%">Sign up now and start service</td>'+
		'</tr>'+
		'<tr>'+
		'<td height="45"><div class="Step2Icon" title="Step2"></div></td>'+
		'<td class="Txt7">Read and accept Terms of Use</td>'+
		'</tr>'+
		'<tr><td colspan="2" height="10"><td></tr>'+
		'<tr>'+
		'<td height="40" valign="top"><div class="Step3Icon" title="Step3"></div></td>'+
		'<td class="Txt7" valign="top">Download and watch movies immediately<br> via the free Starz Play software</td>'+
		'</tr>'+
		'<tr>'+
		'<td height="55" valign="bottom"></td>'+
		'<td><div class="SFreeTrialBtn" title="Start Free Trial" onclick="return dcsExit(\'https://www.verizon.net/ssowebapp/VOLPortalLogin?clientId=cnsmrshp&TARGET=http://surround.verizon.net/shop/shopRedirect.aspx?oid=VX300\')" > </div></td>'+
		'</tr>'+
		'<tr>'+
		'<td height="60" colspan="2"><div class="DwlDiv"><a href="javascript:beginDownload();" onclick="return beginDownload(); dcsExit(\'http://www.verizon.net/starzplaydownload\', \'\', \'target=_blank,location=1,status=1,scrollbars=1,resizable=1,menubar=1,toolbar=1\');return false;"  class="Lnk3">Click here to download the Starz player</a><br /><span class="LH1">Note: If you already have a starz play account, you can download the player and use your acount information to play movies.</span><br><span class="LH4"><a href="http://www.verizon.net/starzplayhelp" target="_blank" class="Lnk3">Verizon Starz Play General FAQ</a></span></div></td>'+
		'</tr>'+
		'</table>'+
	'</td>'+
	'<td valign="top" width="193"><div class="Bg3 Txt6 TPad1 LH3" align="center"><div class="WH2 TAL">Starz Play offers download and streaming access to hit movies and so much more for <span class="Txt8 Bold">Windows PCs and select personal video players,</span> all for one flat monthly rate as low as $5.99 per month on your Verizon bill.</div></div>'+
	'</td>'+
	'</tr>'+
    '</table>';
	}
	
	else if(DivId == "VongoCustomers"){
	document.getElementById('DivPopUpM').innerHTML = '<table width="100%" align="center" border="0" cellspacing="0" cellpadding="0">'+
	'<tr>'+
	'<td valign="top" width="100%" style="color:black;">'+
		'<span style=" margi-top:5px;color:#ff9e0a;text-decoration:none; font-size:18px;">Vongo member?</span> <br />'+
		'Starting on September 30, 2008, you will no longer be able to use the Vongo service. Enjoy the same great subscription movie download features by signing up for Starz Play provided by Verizon. <br /><br />'+
		'<a href="" onclick="return dcsExit(\'https://www.verizon.net/ssowebapp/VOLPortalLogin?clientId=cnsmrshp&TARGET=http://surround.verizon.net/shop/shopRedirect.aspx?oid=VX300\')" >Click here</a> to take advantage of a 14-day free trial of Starz Play provided by Verizon.<br />'+
		'<br />'+
		'Still have questions about your Vongo account? Check out the FAQs below for more info.<br />'+
		'<br />'+
		'<b>What will happen to my Vongo account?</b><br />'+
		'<br />'+
		'Final billing for your Vongo membership will occur in August. Your Vongo membership will be active until September 30, 2008. If you wish to cancel before September 30, please login to your Vongo Account and follow the steps to cancel. All Vongo Registered User accounts will expire on September 30, 2008 and all Vongo titles will be deleted.<br />'+
		'<br />'+
		'<b>What will happen to my movies?</b><br />'+
		'<br />'+
		'When the Vongo service ceases on September 30, 2008 all of your Vongo titles will be deleted. If you have downloaded a Pay-Per-View title it will be available until the earlier of its expiration date or September 30, 2008.<br />'+
		'<br />'+
		'<b>Do I need to uninstall the Vongo application before installing Starz Play?</b><br />'+
		'<br />'+
		'Yes, you must uninstall the Vongo application prior to downloading and installing Starz Play whether before or after the September 30, 2008 expiration date.  Before September 30, you must also cancel your membership account before you uninstall Vongo.  To cancel: Login in to Vongo’s My Account and select the Account Type tab.  Click on the Cancel Services button and follow the steps to cancel.<br />'+
		'<br />'+
		'<b>Vongo Rewards Redemption </b>'+
		'If you are trying to redeem a Vongo reward in connection with the Coke Rewards program or a Samsung P2 offer, please call 877-VONGO-21.<br />'+
		'<br />'+
		'Have specific questions about Starz Play? Get more information with <a href="http://www.verizon.net/starzplayhelp" target="_blank">Verizon Starz Play General FAQ.</a><br />'+
	    '<br /><br />'+
	'</td>'+
	'</tr>'+
    '</table>';
	}
}


/* Popup Menu Scripts */
xpos = null;
ypos = null;
if (!document.all) {
document.captureEvents(Event.MOUSEMOVE);
}
document.onmousemove = MousePosition;
function MousePosition(evt){
if (document.all&& document.body != null) {
xpos = window.event.x + document.body.scrollLeft;
ypos = window.event.y + document.body.scrollTop;
}
else{
	if(evt != null)
		{
			xpos = evt.pageX-30;
			ypos = evt.pageY-98;
		}
}
} 

browser_type = navigator.appName;
browser_version = parseInt(navigator.appVersion);

if (browser_type == "Microsoft Internet Explorer")
{
	browser_version= parseInt(navigator.appVersion.replace(/^.*MSIE/,''));
}


function PopUpMOver(PopDivName){
	document.getElementById(PopDivName).style.visibility='visible';
}

function PopUpMOut(PopDivName){
	document.getElementById(PopDivName).style.visibility='hidden';
}

function PopUpMLeave(PopDivName){
	document.getElementById(PopDivName).style.visibility='hidden';
}

<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//-->


 /* Script Updated on Apr 11 */
function showPops(PopupId, imageId){
	
	var mediaId;
	if (currentPage > 1)
	{
	    mediaId = ((currentPage - 1)* 10) + (imageId - 1);
	}
	else
	{
	    mediaId = imageId - 1;
	}
	mediaItems = Verizon.Surround.Web.Shop_Entertainment_StarzPlay.getMediaItems(); 
    
  
    var actors = mediaItems.value[mediaId].Actors;
    var strActors ="";
    var length = 0; 
    if (actors != null)
    {
        if (actors.length > 4)
        {
           length  = 4; 
        }
        else
        {
            length = actors.length;
        }
        
        for (var j = 0; j < length; j++)
        {
            if (j == length - 1)
                strActors = strActors + actors[j];
            else
                strActors = strActors + actors[j]+", ";
        }
    }
    else
    {
        strActors = "Not Available";
    }
   
   	var titleDiv =  document.getElementById("titleDiv");
   	if (titleDiv != null)
   	{
   	    titleDiv.innerHTML = mediaItems.value[mediaId].Title;
   	}
   	else
   	{
   	    titleDiv = "Not Available"
   	}
   	
   
   var videoUrl =  mediaItems.value[mediaId].VideoUrl;
   	if (videoUrl == null)
   	{
   	    videoUrl = "/Shop/images/Starz/Player/starzplay.flv";
   	}
   	
   	
   	
   	var rating = mediaItems.value[mediaId].Rating;
    if (rating == null)
    {
       rating = "Not Available";
    }
    
    var releaseYear = mediaItems.value[mediaId].ReleaseYear;
    if (releaseYear == null)
    {
       releaseYear =  "Not Available";
    }
    
      	                   
   	var myDiv =  document.getElementById("PostPopIn");
   	if (myDiv != null)
   	{
	    myDiv.innerHTML= 'Release Year: '+ releaseYear +'<br />'+
                     'MPAA Rating: '+ rating +'<br />'+
                     'Starring: '+ strActors + '<br />'+
                     //+
                     //'<div class="Fl TryItBtn Pad5" title="Try It" onclick="return dcsExit(\'https://sso.verizon.net/ssowebapp/VOLPortalLogin?ActualTarget=http://surround.verizon.net/shop/shopRedirect.aspx?oid=VX300\');return false;"></div>';
                     '<div class="Fl PreviewBtn" title="Preview" onclick="javascript:showmovie(\''+ videoUrl +'\');"></div>';
    
    
    }                  
                             
	
	var MaxX = document.body.clientWidth;
	var DivTest = document.getElementById(PopupId)
	var DivWidth;
	if (DivTest != null)
	{
		DivWidth = DivTest.clientWidth;
	}
		if((xpos + DivWidth)>MaxX){
		xpos = MaxX - DivWidth - 20;
		if(!document.all){
			xpos=xpos-35;
			ypos=ypos;
		}
	}
	
	
	arwDiv = document.getElementById('PopArwDiv');

	if (browser_type == "Netscape" && (browser_version >= 4)) 
	{
		if(arwDiv != null)
		{
			arwDiv.style.top="2px";
		}
	}
	else if (browser_type == "Microsoft Internet Explorer" && (browser_version >= 4)) 
	{
		xpos=xpos+15-window.event.offsetX;
		ypos=ypos+100-window.event.offsetY;
		
		if(arwDiv != null)
			if (browser_version < 7)
			{
				arwDiv.style.top=8;
			}
			else
			{
				arwDiv.style.top=2;
			}
	}
	

	var xval;var yval;
	if (imageId == '1')
	{
		xval = "270px"; 
		yval = "460px";
	}
	else if(imageId == '2')
	{
		xval = "405px"; 
		yval = "460px";	
	}
	else if(imageId == '3')
	{
		xval = "540px"; 
		yval = "460px";	
	}
	else if(imageId == '4')
	{	
		xval = "675px"; 
		yval = "460px";	
	}
	else if(imageId == '5')
	{
		xval = "810px"; 
		yval = "460px";	
	}
	else if(imageId == '6')
	{
		xval = "270px"; 
		yval = "690px";	
	}
	else if(imageId == '7')
	{
		xval = "405px"; 
		yval = "690px";	
	}
	else if(imageId == '8')
	{
		xval = "540px"; 
		yval = "690px";	
	}
	else if(imageId == '9')
	{
		xval = "675px"; 
		yval = "690px";	
	}
	else if(imageId == '10')
	{
		xval = "810px"; 
		yval = "690px";	
	}

	/*document.getElementById(PopupId).style.left=xpos + 'px';
	if(ypos!=null)
	document.getElementById(PopupId).style.top=ypos + 'px';*/
	
	document.getElementById(PopupId).style.left=xval;
	if(ypos!=null)
	document.getElementById(PopupId).style.top=yval;
	document.getElementById(PopupId).style.visibility='visible';
	document.getElementById(PopupId).style.display='block';
}


function showStarzEmailDiv()
{
showDropDown();
var DivStarzEmail = document.getElementById("DivStarzEmail");
if(DivStarzEmail != null)
{
    document.getElementById('DivPopUpM').innerHTML = DivStarzEmail.innerHTML;
}
}
     
function sendStarzSupportEmail()
{
    var txtFirstName = document.getElementById("txtFirstName");
    var txtLastName = document.getElementById("txtLastName");
    var ddlSubscribedService = document.getElementById("ddlSubscribedService");
    var txtCBNumber = document.getElementById("txtCBNumber");
    var txtEmailAdd = document.getElementById("txtEmailAdd");
    var ddlBestDay = document.getElementById("ddlBestDay");
    var ddlBestTime = document.getElementById("ddlBestTime");
    var ddlPreContactMethod = document.getElementById("ddlPreContactMethod");
    var ddlCategory = document.getElementById("ddlCategory");
    var txtComment = document.getElementById("txtComment");
    if(txtFirstName != null && txtLastName!= null && ddlSubscribedService!= null &&
    txtCBNumber != null && txtEmailAdd != null && ddlBestTime != null && ddlBestDay!= null && 
    ddlPreContactMethod != null && ddlCategory != null && txtComment != null)
    {
        if(ddlPreContactMethod.value == "Email")
        {
            if(txtFirstName.value != "" && txtLastName.value != "" && txtEmailAdd.value !="")
            {
                  var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
                   var address = txtEmailAdd.value;
                       if(reg.test(address) == false)
                        {
                          var DivError = document.getElementById("DivError");
                            if(DivError != null)
                            {
                                DivError.innerHTML = "Inavalid Email Address";
                                DivError.style.color = "Red";
                                      return false;
                            }
                       }
                       else
                           {
                       Shop_Entertainment_StarzPlaySupportRequest.SendStarzSupportRequestEmail(txtFirstName.value,txtLastName.value,ddlSubscribedService.value,
                        txtCBNumber.value, ddlBestDay.value+' ' +ddlBestTime.value, txtEmailAdd.value, ddlPreContactMethod.value,
                        ddlCategory.value, txtComment.value, sendStarzSupportEmailCallBack);
                        }
            }
            else
            {
                var DivError = document.getElementById("DivError");
                if(DivError != null)
                {
                    DivError.innerHTML = "Fields marked with '*' are Required Fields";
                    DivError.style.color = "Red";
                }
            }
        }
        else if(ddlPreContactMethod.value == "Phone")
        {
            if(txtFirstName.value != "" && txtLastName.value != "" && txtCBNumber.value !="")
            {
                 Shop_Entertainment_StarzPlaySupportRequest.SendStarzSupportRequestEmail(txtFirstName.value,txtLastName.value,ddlSubscribedService.value,
                txtCBNumber.value, ddlBestDay.value+' ' +ddlBestTime.value, txtEmailAdd.value, ddlPreContactMethod.value,
                ddlCategory.value, txtComment.value, sendStarzSupportEmailCallBack);
            }
            else
            {
                var DivError = document.getElementById("DivError");
                if(DivError != null)
                {
                    DivError.innerHTML = "Fields marked with '*' are Required Fields";
                    DivError.style.color = "Red";
                }
            }
        }
    }

}

function sendStarzSupportEmailCallBack(res)
{

    if(res.value != null && res.value == "success")
    {
        //window.close();
          clearFields();
        var DivError = document.getElementById("DivError");
        if(DivError != null)
        {
            DivError.innerHTML = "Email has been sent successfully.";
            DivError.style.color = "Green";
          
        }
    }
    else
    {
        var DivError = document.getElementById("DivError");
        if(DivError != null)
        {
            DivError.innerHTML = "The request was not sent successfully. Please Try Again";
            DivError.style.color = "Red";
        }
    
    }
}
function showStarzEmailForm()
{
var divEmailForm = document.getElementById('divEmailForm');
var divErrorEmail = document.getElementById('divErrorEmail');
if(divEmailForm != null && divErrorEmail != null)
{
    divEmailForm.style.display = "";
    divEmailForm.style.visibility = "visible";
    divErrorEmail.style.display = "none";
    divErrorEmail.style.visibility = "hidden";
}

}

function formatPhoneNumber(oField)
{	
	var sPhone = oField.value;
	var nLenPhone = sPhone.length;
	if (nLenPhone < 1)
		return;
	//var sLastChar = sPhone.substr(nLenPhone-1,1);
	var sFirstChar = sPhone.substr(0,1);
	var sDigits = '1234567890';
	var sDelimiters = '-';
	var sNewPhone = "";
	var iChar = 0;
	var curChar;
	var curValid;
	var curIsDigit;

	// determine if all chars valid
	for (iChar=0; iChar < nLenPhone; iChar++)
	{
		if (sNewPhone.length >= 13)
		{
			break;
		}
		curValid = true;
		curChar = sPhone.charAt(iChar);
		if (sDigits.indexOf(curChar) < 0)
		{
			curIsDigit = false;
			if (sDelimiters.indexOf(curChar) < 0)
				continue;	// totally invalid char
		}
		else
		{
			curIsDigit = true;
		}
		// now, is it valid for this character position?
		switch (sNewPhone.length)
		{
//			case 0:
//				if (curChar != '(')
//				{
//					if (curIsDigit)
//						sNewPhone += '(';
//					else
//						continue;
//				}
//				break;
			
			case 3:
				if (curChar != '-')
				{
					if (curIsDigit)
						sNewPhone += '-';
					else
						continue;
				}
				break;
				
			case 7:
				if (curChar != '-')
				{
					if (curIsDigit)
						sNewPhone += '-';
					else
						continue;
				}
				break;
				
			default:	// should be a digit
				if (!curIsDigit)
					continue;
				break;
		}
		sNewPhone += curChar;
	}	// foreach char
	if (oField.value != sNewPhone)
		oField.value = sNewPhone;
}

function onddlPreContactMethodSelect()
{
    var ddlPreContactMethod = document.getElementById("ddlPreContactMethod");
    if(ddlPreContactMethod != null)
    {
         var reqEmailAddress = document.getElementById("reqEmailAddress");
          var reqcallBackNum = document.getElementById("reqcallBackNum");
        if(ddlPreContactMethod.value == "Email")
        {
            if(reqEmailAddress != null && reqcallBackNum != null)
            {
                reqEmailAddress.innerHTML = "*";
                reqcallBackNum.innerHTML ="";
            }
        }
        else if(ddlPreContactMethod.value == "Phone")
        {
            if(reqcallBackNum != null && reqEmailAddress != null)
            {
                reqcallBackNum.innerHTML = "*";
                reqEmailAddress.innerHTML = "";
            }
        }
    }
}

function clearFields()
{
    var txtFirstName = document.getElementById("txtFirstName");
    var txtLastName = document.getElementById("txtLastName");
    var txtCBNumber = document.getElementById("txtCBNumber");
    var txtEmailAdd = document.getElementById("txtEmailAdd");
    var txtComment = document.getElementById("txtComment");
    txtFirstName.value = "";
    txtLastName.value = "";
    txtCBNumber.value = "";
    txtEmailAdd.value = "";
    txtComment.value = "";
    var DivError = document.getElementById("DivError");
        if(DivError != null)
        {
            DivError.innerHTML = "";
        }
    
}


    
