
  function OpenPopup(Page, Title, WindowWidth, WindowHeight, WindowLeft, WindowTop, Features)
  {
        var lScreenWidth = screen.availWidth;	// The width of the users screen size  i.e 800 x 600
        var lScreenHeight = screen.availHeight;	// The height of the users screen size i.e 1024 x 768
     
        var lLeft = WindowLeft;			// Left-hand starting position for the window
        var lTop = WindowTop;			// Highest starting position for the window

        if (lLeft == -1)
           lLeft = (lScreenWidth - WindowWidth) / 2;

        if (lTop == -1)
           lTop = ((lScreenHeight - WindowHeight) - 100) / 2;

        if (Features == "")
           Features = "status=no,scrollbars=no,menubar=no,location=no,toolbar=no,resizable=no";

        myHandle = window.open(Page, Title,'width=' + WindowWidth + ',height=' + WindowHeight + ',top=' + lTop + ',left=' + lLeft + ',' + Features);
        if (!myHandle.opener) myHandle.opener = self;
        myHandle.focus();
  }

  function OpenCertDetails()
  {
     thewindow = window.open('https://www.thawte.com/cgi/server/certdetails.exe?code=GBCALL31-3', 'anew', config='height=520,width=520,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,directories=no,status=yes');
     thewindow.focus();
  }

  function OpenPaymentByCheque()
  {
     OpenPopup('Default.asp?page=faq&id=19&subid=59', 'PaymentByCheque', 800, 600, -1, -1, 'status=yes,scrollbars=yes,menubar=yes,location=yes,toolbar=yes,resizable=yes')
     //window.location.href = 'AccountInfo.asp';
     return true;
  }

  function OpenPaymentByBankTransfer()
  {
     OpenPopup('Default.asp?page=faq&id=19&subid=57', 'PaymentByBankTransfer', 800, 500, -1, -1, 'status=yes,scrollbars=yes,menubar=yes,location=yes,toolbar=yes,resizable=yes')
     //window.location.href = 'AccountInfo.asp';
     return true;
  }

  function OpenPaymentByWesternUnion()
  {
     OpenPopup('Default.asp?page=faq&id=19&subid=58','PaymentByWesternUnion', 800, 500, -1, -1, 'status=yes,scrollbars=yes,menubar=yes,location=yes,toolbar=yes,resizable=yes')
     //window.location.href = 'AccountInfo.asp';
     return true;
  }

  function OpenDialingRules()
  {
     OpenPopup('internet_telephone_dialling_example.asp','dialling_rules', 500, 460, -1, -1, 'scrollbars=no')
     return true;
  }

  function OpenRefundsPolicy()
  {
     OpenPopup('help_details.asp?id=4#4121','RefundsPolicy', 800, 500, -1, -1, 'status=yes,scrollbars=yes,menubar=yes,location=yes,toolbar=yes,resizable=yes')
     //window.location.href = 'AccountInfo.asp';
     return true;
  }

  function OpenPDTShop()
  {
     OpenPopup('http://shop.voipvoice.com/callserve','ShopPDT', 800, 500, -1, -1, 'status=yes,scrollbars=yes,menubar=yes,location=yes,toolbar=yes,resizable=yes')
     return true;
  }

  function OpenCommunitechShop()
  {
     OpenPopup('http://www.callserveus.communitech.com/storefront.asp?pgid=1', 'ShopCommunitech', 800, 500, -1, -1, 'status=yes,scrollbars=yes,menubar=yes,location=yes,toolbar=yes,resizable=yes')
     return true;
  }

  function OpenShopItem(ItemNo)
  {
     OpenPopup('ShopItem.asp?id=' + ItemNo, 'MoreInfoBuy', 525, 450, -1, -1, 'status=no,scrollbars=no,menubar=no,location=no,toolbar=no,resizable=no')
     return true;
  }

  function DisplayStatement(dtMonthValue)
  {
     strAppendToTitle = StripOutSpaces(dtMonthValue);
     qs = "?MonthDate=" + dtMonthValue;

     OpenPopup("Statement.asp" + qs, "Statement" + strAppendToTitle, 750, 500, -1, -1, "status=no,toolbar=yes,menubar=yes,location=no,scrollbars=yes,resizable=yes");
  }

  function ShowSupportedMobiles()
  {
     var lLeft = (screen.width - 600) / 2;
     var lTop = (screen.height - 500) / 2;
     myHandle=window.open('/Ringtones/RingtoneSupportedMobiles.asp','Mobiles_Supported_Phones','width=600,height=500,top=' + lTop + ',left=' + lLeft + ',scrollbars=yes,menubar=no,location=no,toolbar=no,resizable=yes');
     if (!myHandle.opener) myHandle.opener = self;
  }
  
  function ShowRingtoneTaCs()
  {
     var lLeft = (screen.width - 500) / 2;
     var lTop = (screen.height - 500) / 2;
     myHandle=window.open('/Ringtones/RingtoneTandCs.asp#TermsConditions','Mobile_Terms_Conditions','width=500,height=500,top=' + lTop + ',left=' + lLeft + ',scrollbars=yes,menubar=no,location=no,toolbar=no,resizable=yes');
     if (!myHandle.opener) myHandle.opener = self;
  }

  function ShowRingtonePrivacy()
  {
     var lLeft = (screen.width - 500) / 2;
     var lTop = (screen.height - 500) / 2;
     myHandle=window.open('/Ringtones/RingtoneTandCs.asp#Privacy','Mobile_Privacy','width=500,height=500,top=' + lTop + ',left=' + lLeft + ',scrollbars=yes,menubar=no,location=no,toolbar=no,resizable=yes');
     if (!myHandle.opener) myHandle.opener = self;
  }

  function GetTimeZone()
  {
    // Setup a GMTOffset Cookie for Later Use
    if ('<%=SetClock%>' == 'Yes') 
    {
       if ('<%=GMTOffset%>' == '') 
       {
         var today = new Date();
         var GMTOffset = - today.getTimezoneOffset () / 60;
         var expires = new Date();
         expires.setTime(expires.getTime() + 3E11);
         document.cookie = "GMTOffset=" + escape(GMTOffset) + "; expires=" + expires.toGMTString();
       }
    }
  }

  function ValidEmailAddress(strEmail)
  {
     // Simple client-side email address validation.  It saves round trips.
     strEmail = StripOutSpaces(strEmail);
     return /^[^@]+@[^@]+\.[^@]{2,}$/i.test(strEmail);
  }

  function ValidRateNumber(strPhoneNumber) 
  {
    // Check if the number is valid to call
    if (strPhoneNumber.length == 0) return false;

    // Check for 0 - 9 and +
    for (i = 0; i < strPhoneNumber.length; i++) 
    {
      if ((strPhoneNumber.charAt(i) > "9") || (strPhoneNumber.charAt(i) < "0") && 
          (strPhoneNumber.charAt(i) != '+') && 
          (strPhoneNumber.charAt(i) != ' ') && 
          (strPhoneNumber.charAt(i) != '-') && 
          (strPhoneNumber.charAt(i) != '(') && 
          (strPhoneNumber.charAt(i) != ')'))

         return false;
    }

    return true;
  }

  function ValidNumber(strNumber) 
  {
    // Check if the value parsed any contains numbers and/or a full stop
    if (strNumber.length == 0) return false;

    // Check for 0 - 9 and decimal place (period)
    for (i = 0; i < strNumber.length; i++) 
    {
      if ((strNumber.charAt(i) > "9") || (strNumber.charAt(i) < "0") && (strNumber.charAt(i) != '.'))
         return false;
    }

    return true;
}


// check and ensure a whole non-decimal number is returned /Tobi 21 April 2009
function ValidInteger(strNumber) {
    if (!ValidNumber(strNumber))
        return false;
    else
        return (strNumber.indexOf(".") == -1);
}
  
  
  
  

  function PhoneNumberChars(strValue) 
  {
    var strReturnValue = '';

    // Take out any spaces in the specified string
    for (i = 0; i < strValue.length; i++) 
    {
       if ((strValue.charAt(i) >= "0") && (strValue.charAt(i) <= "9"))
			 strReturnValue += strValue.charAt(i)
    }
  
    return strReturnValue;
  }

  function ValidNumberWithSpaces(strNumber) 
  {
    // Check if the value parsed only contains numbers or spaces

    if (strNumber.length == 0) return false;

    // if (strNumber == '') return false;

    // Check for 0 - 9 and decimal place (period)
    for (i = 0; i < strNumber.length; i++) 
    {
      if ((strNumber.charAt(i) > "9") || (strNumber.charAt(i) < "0") && (strNumber.charAt(i) != ' '))
         return false;
    }

    return true;
  }

  function StripOutSpaces(strValue) 
  {
    var strReturnValue = '';

    // Take out any spaces in the specified string
    for (i = 0; i < strValue.length; i++) 
    {
       if (strValue.charAt(i) != ' ')
	  strReturnValue = strReturnValue + strValue.charAt(i)
    }
  
    return strReturnValue;
  }

  function SpacesPresent(text) 
  {
    for (var iLoop = 0; iLoop < text.length; iLoop++) 
    {
      if (text.charAt(iLoop) == " ") return true;
    }
    return false;
  }

  function MM_findObj(n, d) {
    var p,i,x;
    if(!d) {
      d=document;
    }
    if(0<(p=n.indexOf("?"))&&parent.frames.length) {
      d=parent.frames[n.substring(p+1)].document;
      n=n.substring(0,p);
    }
    if(!(x=d[n])&&d.all) {
      x=d.all[n];
    }
    for (i=0;!x&&i<d.forms.length;i++) {
      x=d.forms[i][n];
    }
    for(i=0;!x&&d.layers&&i<d.layers.length;i++) {
      x=MM_findObj(n,d.layers[i].document);
    }
    return x;
  }

  function MM_swapImage() {
    var i,j=0,x,a=MM_swapImage.arguments;
    document.MM_sr=new Array;
    for(i=0;i<(a.length-2);i+=3) {
      if ((x=MM_findObj(a[i]))!=null){
        document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];
      }
    }
  }

  function MM_swapImgRestore() {
    var i,x,a=document.MM_sr;
    for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) {
      x.src=x.oSrc;
    }
  }

  function MM_preloadImages() {
    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];
        }
      }
    }
  }
 
  function onlineTransfer()
  {
     //Open the window
     aWin = popupWindow("/Processing/popup_online_transfer.asp","OLT",400,350,0,0,true);
  }

  function banktransferInfo()
  {
     aWin = popupWindow("/Processing/popup_bank_transferinfo.asp", "OLT", 400, 600, 0, 0, true);
  }

  function chequePopup()
  {
     aWin = popupWindow("/Processing/popup_cheque_payment.asp", "CPW", 400, 350, 0, 1, true);
  }
 
  function minspecPopup()
  {
     aWin = popupWindow("/popup_minspec.asp", "MSC", 400, 190, 0, 0, true);
  }

  function diallingexamplesPopup()
  {
     aWin = popupWindow("/Internet_telephone_dialling_example.asp", "dialling", 500, 400, 0, 0, true);
  }

  function forgottenPopup()
  {
     aWin = popupWindow("/Processing/popup_forgotpassword.asp", "MSC", 400, 160, 0, 0, true);
  }

  function popupWindow(url, name, width, height, tools, scrolls, centered)
  {
    aWin = window.open(url, name, "width=" + width + ", height=" + height + ", toolbars=" + tools + ", scrollbars=" + scrolls);

    //Center
    if (centered)
    {
	//Hide window while we fiddle
	aWin.blur();
	
	w = (screen.width - width) / 2;
	h = (screen.height - height) / 2
	
	aWin.moveTo(w, h);
		
	//And back again
	aWin.focus();
    }
    return aWin;
  }
