
  function changePhones(){
    $("#selectphone").html('<select class="wide174"><option value="">Loading...</option></select>');
    $("#selectphone").load("/home/changephone?carrier="+document.getElementById('carrier2').value+"&brand="+document.getElementById('brand2').value);
    document.getElementById('dloption').style.display='none';
  }

  function changeBrands(){
    $("#selectbrand").html('<select class="wide174"><option value="">Loading...</option></select>');
    $("#selectbrand").load("/home/changebrand?carrier="+document.getElementById('carrier2').value);
    document.getElementById('dloption').style.display='none';
  }

  function imgchange(){
    if(document.getElementById('carrier2').value!='' && document.getElementById('brand2').value!='')
        document.getElementById('dloption').style.display='block';
    $("#phoneimg").load("/home/imgchange?phone="+document.getElementById('phone2').value);
    getSuggestion(document.getElementById('carrier2').value, document.getElementById('brand2').value, document.getElementById('phone2').value);

  }      
  /*function getcarrier(){
      $("#mobilecarrier").load("/home/mobilecarrier?number="+document.getElementById('number').value);
  } */

  function applySuggestion(){
    if(document.getElementById('suggestedMethod').value==1){
        setRadioDownloadValue(document.getElementById('helpformat').value);
    }
    if(document.getElementById('suggestedMethod').value==2){
        setRadioEmailValue(document.getElementById('helpformat').value);
    }
    if(document.getElementById('suggestedMethod').value==3){
        setRadioPhoneValue(document.getElementById('helpformat').value);
    }
  }

  function getRadioValue(radioN)
  {
    for(i=0;i<document.updateHelp[radioN].length;i++)
    {
      if (document.updateHelp[radioN][i].checked == true)
        return document.updateHelp[radioN][i].value;
    }
  }

  function setRadioDownloadValue(radiovalue){
    for(i=0;i<document.downloadForm['format'].length;i++)
    {
        if (document.downloadForm['format'][i].value == radiovalue){
            document.downloadForm['format'][i].checked = true;
        }

    }
  }

  function setRadioEmailValue(radiovalue){
    for(i=0;i<document.emailForm['format'].length;i++)
    {
        if (document.emailForm['format'][i].value == radiovalue){
            document.emailForm['format'][i].checked = true;
        }

    }
  }

  function setRadioPhoneValue(radiovalue){
    document.getElementById('selectPhoneForm').value = radiovalue;
    for (i=0; i <= document.phoneForm.carrier.options.length - 1;i++)
    {
        var tempString = new String(document.phoneForm.carrier.options[i].value);
        var brokenstring = tempString.split('^');
        if((brokenstring[4] == document.getElementById('suggestedCarrier').value) || (brokenstring[3] == document.getElementById('suggestedCarrier').value) || (brokenstring[2] == document.getElementById('suggestedCarrier').value))
            document.phoneForm.carrier.options[i].selected = "selected";
    }

    for(i=0;i<document.phoneForm['web_sup'].length;i++)
    {
        if (document.phoneForm['web_sup'][i].value == document.getElementById('suggestedSupport').value){
            document.phoneForm['web_sup'][i].checked = true;
        }
    }
  }

  function changeSuggestion(){
    $("#dloption").load("/home/dloption?has=2");
  }

  function getSuggestion(car2, bran2, phon2){
    $("#dloption").html("Loading...");
    $("#dloption").load("/home/dloption?carrier="+car2+"&brand="+bran2+"&phone="+phon2);
  }

  function checkHelpForm(){
    if(document.getElementById('carrier2').value==''){
        alert('Please select a carrier');
        return false;
    }
    if(document.getElementById('brand2').value==''){
        alert('Please select a brand');
        return false;
    }
    if(document.getElementById('phone2').value==''){
        alert('Please select a phone');
        return false;
    }

    var options = {
        target:        '#dloption'
    };

    $('#updateHelp').ajaxSubmit(options);

    return false;
  }

  function checkPaypal(){
    if(document.getElementById('payEmail').value.length<5){
      alert('Please enter a valid email');
      return false;
    }

    if(document.getElementById('nCust').checked==true){
        if(document.getElementById('npass').value.length<3){
            alert('Please enter a password');
            return false;
        }
    }

    if(document.getElementById('nCust').checked==true){
        if(document.getElementById('npass').value!=document.getElementById('npass2').value){
            alert('Passwords do not match');
            return false;
        }

        if(document.getElementById('termscheck').checked!=true){
            alert('You have not agreed to our terms and conditions');
            return false;
        }
    }

    return true;
  }

  function suggestion(totalTime, videoId){

      $("#suggestionShell").load("/index.php/home/suggestion?time="+totalTime+"&v="+videoId);
      //alert(videoId);
  }

  function createFile(start, end, videoid) {
      createNamed(start, end, videoid, '');
  }

  function createNamed(start, end, videoid, named) {
      prerecord = 0;
      var duration = end - start;
      if(duration > 40)
        duration = 40;
      $("#bottompage").html('<center><div id="audioPlayer" ><img src="/images/loading_aqua.gif" /></div></center>');
      $("#bottompage").load("/index.php/home/convertTube?start="+start+"&duration="+duration+"&v="+videoid+"&toneid="+toneid+"&processing="+processing+"&tonename="+named+"&error="+error+"&realsource="+realsource);
      format = 'mp3';
      phoneformat = 'mp3';
      document.getElementById('audioPlayer').style.height="83px";
      document.getElementById('audioPlayer').focus();
      document.getElementById('suggestor').style.display='none';
      document.getElementById('suggest').style.display='none';
      document.getElementById('suggestclick').style.display='block';
      toneid = 0;
      return null;
  }

  function sendEmail() {
      $("#emailmessage").html('loading');
      $("#emailmessage").load("/index.php/home/email?format="+format+"&v="+document.getElementById('emailj').value+"&filename="+document.getElementById('emailfile').value+"&email="+document.getElementById('email').value+"&pre="+prerecord+"&realsource="+realsource);
      return null;

  }
  function sendPhone() {
      if(document.getElementById('carrier').value==""){
          alert('Select Your Mobile Provider');
      }
      else{
        $("#phonemessage").html('sending');
        $("#phonemessage").load("/index.php/home/phone?format="+phoneformat+"&v="+document.getElementById('phonej').value+"&filename="+document.getElementById('phonefile').value+"&number="+document.getElementById('number').value+"&carrier="+escape(document.getElementById('carrier').value)+"&pre="+prerecord+"&web="+document.getElementById('web_sup_input').value+"&realsource="+realsource);
      }
      return null;
  }

  function phoneformat2(format2){
    phoneformat = format2;
  }

  function updateCarrierList(web){
    $("#smsSubmit").html('loading..');
    document.getElementById('web_sup_input').value=web;
    $("#carriersList2").load("/index.php/home/carriersList?helper=0&web="+web);
  }

  function updateCarrierList2(web){
    $("#helperCarrierList").load("/index.php/home/carriersList?helper=1&web="+web);
  }

  function emailformat2(format2){
    format = format2;
  }

  function loadYoutube() {
    $("#choose_alias").html('');
    $("#hide_alias").html('');
    v = document.getElementById('youtubeLink').value;
    $("#bottompage").html('<div id="bottompage"><div id="audioPlayer" >&nbsp;</div></div>');
    $("#suggestionShell").html("");
    $("#videoPlayer").html('<center><img src="/images/loading_aqua.gif" style="padding-bottom:400px"/></center>');
    $("#videoPlayer").load("/index.php/home/getTube?url2="+escape(document.getElementById('youtubeLink').value));
  }

  function loadYoutube2(v) {
    window.location = '/index.php/home/redirecter?url='+escape(v);
  }

  function loadYoutubePage(page) {
    v = document.getElementById('youtubeLink').value;
    $("#bottompage").html('<div id="bottompage"><div id="audioPlayer" >&nbsp;</div></div>');
    $("#videoPlayer").html('<center><img src="/images/loading_aqua.gif" style="padding-bottom:400px"/></center>');
    $("#videoPlayer").load("/index.php/home/getTube?url2="+escape(document.getElementById('youtubeLink').value)+"&page="+page);
  }

  function twit(v, n, start, duration){
    $("#content2").load("/index.php/home/saveRingtone?video="+v+"&start="+start+"&duration="+duration+"&name="+n);
  }

  function removeSpaces(string) {
   return string.split(' ').join('');
  }

  function revertSMS(){
    $("#smsSubmit").html('<input style="background-image:url(/images/send_up.png); background-repeat:no-repeat; background-position:center top;background-color:transparent; border:medium none; cursor:pointer; height:40px; text-index:-1000em; width:150px; " type="button" value="" onclick="sendPhone();" />');

  }

  function youtubeComment(){
    document.getElementById('comment_overlay').style.display='block';
    document.getElementById('comment_window').style.display='block';
  }

  function youtubeCommentSend(cemail, cpass, comment, cvid){
    $("#comment_success").html('Sending');

    $("#comment_success").load("/index.php/home/sharetube?comment="+escape(trim(comment))+"&email="+trim(cemail)+"&pass="+trim(cpass)+"&video="+cvid);
  }

  function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
  }

  function track(tvid){
    $("#t_success").load("/index.php/home/sharetube?help=1&video="+tvid);
  }