﻿// By Nawal: 31 Oct 2007
//this is made for optional extras(discount code)
      function getSuppCode(suppName,suppCode)
        {
            
//        showHide('tblDiscountCode');
        
            switch(suppName)
            {
            case '1':
              document.getElementById("ctl00_BodyContent_txtAvisDiscount").value=suppCode;
              closepopup();
              forOodlesDeals();
              break;    
            case '2':
              document.getElementById("ctl00_BodyContent_txtBudgetDiscount").value=suppCode;
              closepopup();
              forOodlesDeals();
              break;
            case '3':
                document.getElementById("ctl00_BodyContent_txtEuropCarDiscount").value = suppCode;
              closepopup();
              forOodlesDeals();
              break;
            case '4':
              document.getElementById("ctl00_BodyContent_txtHertzDiscount").value=suppCode;
              closepopup();
              forOodlesDeals();
              break;
            case '5':
              document.getElementById("ctl00_BodyContent_txtThriftyDiscount").value=suppCode;
              closepopup();
              forOodlesDeals();
              break;
            case '6':
              document.getElementById("ctl00_BodyContent_txtOodlesDiscount").value=suppCode;
              closepopup();
              break;
            default:
              alert('Some problem occurred during the process.');
            }
            }
    
    function showHide(layerName)
    {
        var id=document.getElementById(layerName).style;
        var tblCS=document.getElementById("tblChildSeats").style;
        var tblDC=document.getElementById("tblDiscountCode").style;
        var tblER=document.getElementById("tblExcessReduction").style;
        var tblFB=document.getElementById("tblFastBreak").style;
        var link1=document.getElementById("link1").style;
        var link2=document.getElementById("link2").style;
        var link3=document.getElementById("link3").style;
        var link4=document.getElementById("link4").style;
            
        if (layerName=="tblChildSeats")
        {
        id.visibility = "visible";
        id.display ="block";
        
        link1.background='url(images/oxActiveLinkBg.gif)';
        link1.backgroundRepeat='no-repeat';
        
        link2.background='url(images/noLink.gif)';
        link2.backgroundRepeat='no-repeat';
        link3.background='url(images/noLink.gif)';
        link3.backgroundRepeat='no-repeat';
        link4.background='url(images/noLink.gif)';
        link4.backgroundRepeat='no-repeat';
        
        tblDC.visibility = "hidden";
        tblDC.display ="none";
        tblER.visibility = "hidden";
        tblER.display ="none";
        tblFB.visibility = "hidden";
        tblFB.display ="none";
                
        }else if (layerName=="tblDiscountCode")
        {
        id.visibility = "visible";
        id.display ="block";
        link2.background='url(images/oxActiveLinkBg.gif)';
        link2.backgroundRepeat='no-repeat';
        
        link1.background='url(images/noLink.gif)';
        link1.backgroundRepeat='no-repeat';
        link3.background='url(images/noLink.gif)';
        link3.backgroundRepeat='no-repeat';
        link4.background='url(images/noLink.gif)';
        link4.backgroundRepeat='no-repeat';
                
        tblCS.visibility = "hidden";
        tblCS.display ="none";
        tblER.visibility = "hidden";
        tblER.display ="none";
        tblFB.visibility = "hidden";
        tblFB.display ="none";
        
        }else if (layerName=="tblExcessReduction")
        {
        id.visibility = "visible";
        id.display ="block";
        link3.background='url(images/oxActiveLinkBg.gif)';
        link3.backgroundRepeat='no-repeat';
        
        link1.background='url(images/noLink.gif)';
        link1.backgroundRepeat='no-repeat';
        link2.background='url(images/noLink.gif)';
        link2.backgroundRepeat='no-repeat';
        link4.background='url(images/noLink.gif)';
        link4.backgroundRepeat='no-repeat';
        
        tblCS.visibility = "hidden";
        tblCS.display ="none";
        tblDC.visibility = "hidden";
        tblDC.display ="none";
        tblFB.visibility = "hidden";
        tblFB.display ="none";
        
        }else if (layerName=="tblFastBreak")
        {
        id.visibility = "visible";
        id.display ="block";
        link4.background='url(images/oxActiveLinkBg.gif)';
        link4.backgroundRepeat='no-repeat';
        
        link1.background='url(images/noLink.gif)';
        link1.backgroundRepeat='no-repeat';
        link2.background='url(images/noLink.gif)';
        link2.backgroundRepeat='no-repeat';
        link3.background='url(images/noLink.gif)';
        link3.backgroundRepeat='no-repeat';
        
        tblCS.visibility = "hidden";
        tblCS.display ="none";
        tblDC.visibility = "hidden";
        tblDC.display ="none";
        tblER.visibility = "hidden";
        tblER.display ="none";
        } else {
        alert('Some problem has occured!')
        }
    }
    function clearDiscountCode()
    {
        document.getElementById("ctl00_BodyContent_txtAvisDiscount").value="";
        document.getElementById("ctl00_BodyContent_txtBudgetDiscount").value="";
        document.getElementById("ctl00_BodyContent_txtHertzDiscount").value = "";
        document.getElementById("ctl00_BodyContent_txtEuropCarDiscount").value = "";
        document.getElementById("ctl00_BodyContent_txtOodlesDiscount").value=""
    }
    function clearFastBreak()
    {
        document.getElementById("txtAvisMembership").value="";
        document.getElementById("txtBudgetMembership").value="";
        document.getElementById("txtHertzMembership").value = "";
    }
//function clearChildSeats()
//{
//document.getElementById("ddlChildSeats").selectedIndex=0;
//document.getElementById("ddlInfantSeats").selectedIndex=0;
//document.getElementById("ddlBoosterSeats").selectedIndex=0;
////nawal:clears validation message
//    if (document.getElementById("CustomValidator5").value != "")
//    {
//    document.getElementById("CustomValidator5").innerHTML= ""
//    }
//}

//NAWAL: Start: clears defaut input values
function clickclear(thisfield, defaulttext,color) {
if (thisfield.value == defaulttext) {
thisfield.value = "";
if (!color) {
			color = "666666";
		}
		thisfield.style.color = "#" + color;
}
}
function clickrecall(thisfield, defaulttext,color) {
if (thisfield.value == "") {
thisfield.value = defaulttext;
if (!color) {
			color = "666666";
		}
		thisfield.style.color = "#" + color;
}
}
//End Here

function SetPickupLocationFromListBox()
{
    if (document.getElementById) {  // DOM3 = IE5, NS6
        var listBoxPickup= document.getElementById("lbPickupLocation");
        var txtPickup= document.getElementById("txtPickupLocation");
        
        for (i = 0; i < listBoxPickup.options.length; i++) {
            if (listBoxPickup.options[i].selected) 
            {
                txtPickup.value = listBoxPickup.options[i].value;
            } 
        }
    }
    else {
        if (document.layers) {  // Netscape 4
            var listBoxPickup= document.lbPickupLocation;
            var txtPickup= document.txtPickupLocation;
            
            for (i = 0; i < listBoxPickup.options.length; i++) {
                if (listBoxPickup.options[i].selected) 
                {
                    txtPickup.value = listBoxPickup.options[i].value;
                } 
            }
        }
        else {  // IE 4
                var listBoxPickup= document.all.lbPickupLocation;
                var txtPickup= document.all.txtPickupLocation;
                for (i = 0; i < listBoxPickup.options.length; i++) {
                    if (listBoxPickup.options[i].selected) 
                    {
                        txtPickup.value = listBoxPickup.options[i].value;
                    } 
                }
        }
    }
}
function SetDropOffLocationFromListBox()
{
    if (document.getElementById) {  // DOM3 = IE5, NS6
    
        var listBoxDropOff= document.getElementById("lbDropOffLocation");
        var txtDropOff= document.getElementById("txtDropOffLocation");
        
        for (i = 0; i < listBoxDropOff.options.length; i++) {
            if (listBoxDropOff.options[i].selected) 
            {
                txtDropOff.value = listBoxDropOff.options[i].value;
            } 
        }
    }
    else {
        if (document.layers) {  // Netscape 4
            var listBoxDropOff= document.lbPickupLocation;
            var txtDropOff= document.txtPickupLocation;
            
            for (i = 0; i < listBoxDropOff.options.length; i++) {
                if (listBoxDropOff.options[i].selected) 
                {
                    txtDropOff.value = listBoxDropOff.options[i].value;
                } 
            }
        }
        else {  // IE 4
                var listBoxDropOff= document.all.lbPickupLocation;
                var txtDropOff= document.all.txtPickupLocation;
                for (i = 0; i < listBoxPickup.options.length; i++) {
                    if (listBoxDropOff.options[i].selected) 
                    {
                        txtDropOff.value = listBoxDropOff.options[i].value;
                    } 
                }
        }
    }
}
function bookmark(){
            var title="Oodles.com: Home"
            var url="http://oodles.com"

            if (window.sidebar) window.sidebar.addPanel(title, url,"");

            else if( window.opera && window.print )
            {
            var mbm = document.createElement('a');
            mbm.setAttribute('rel','sidebar');
            mbm.setAttribute('href',url);
            mbm.setAttribute('title',title);
            mbm.click();
            }

            else if( document.all ) window.external.AddFavorite( url, title);
    }
    
    //This function open a new window on the centre of the screen
    var win = null;
    function NewWindow(mypage,myname,w,h,scroll){
    LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
    TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
    settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
    win = window.open(mypage,myname,settings)
    }
    
    function getSuppCode1(suppName,suppCode)
        {
            
        showHide('tblDiscountCode');
        
            switch(suppName)
            {
            case '1':
              document.getElementById("ctl00_BodyContent_txtAvisDiscount").value=suppCode;
              forOodlesDeals();
              break;    
            case '2':
              document.getElementById("ctl00_BodyContent_txtBudgetDiscount").value=suppCode;
              forOodlesDeals();
              break;
            case '3':
              document.getElementById("ctl00_BodyContent_txtEuropCarDiscount").value=suppCode;
              forOodlesDeals();
              break;
            case '4':
              document.getElementById("ctl00_BodyContent_txtHertzDiscount").value=suppCode;
              forOodlesDeals();
              break;
            case '5':
              document.getElementById("ctl00_BodyContent_txtThriftyDiscount").value=suppCode;
              forOodlesDeals();
              break;
            case '6':
              document.getElementById("ctl00_BodyContent_txtOodlesDiscount").value=suppCode;
              checkOtherDeals();
              break;
            default:
              alert('Some problem occurred during the process.');
            }
            }
            
            function forOodlesDeals()
            {
            if (document.getElementById("ctl00_BodyContent_txtOodlesDiscount").value !="")
                {
                    alert("Supplier's deal can not be selected with Oodles' deal!");
                    document.getElementById("ctl00_BodyContent_txtAvisDiscount").value="";
                    document.getElementById("ctl00_BodyContent_txtBudgetDiscount").value="";
                    document.getElementById("ctl00_BodyContent_txtHertzDiscount").value = "";
                    document.getElementById("ctl00_BodyContent_txtEuropCarDiscount").value = "";
                }
//            if  ((document.getElementById("ctl00_BodyContent_txtAvisDiscount").value !="") &&
//                (document.getElementById("ctl00_BodyContent_txtBudgetDiscount").value !="") &&
//                (document.getElementById("ctl00_BodyContent_txtHertzDiscount").value !=""))               
//                {
//                    alert("");
//                }
            } 
            
            function checkOtherDeals()
            {
            if (document.getElementById("ctl00_BodyContent_txtAvisDiscount").value !="" ||
            document.getElementById("ctl00_BodyContent_txtBudgetDiscount").value != "" ||
            document.getElementById("ctl00_BodyContent_txtEuropCarDiscount").value != "" ||
            document.getElementById("ctl00_BodyContent_txtHertzDiscount").value !="" )
                {
               // alert("Oodles' deal can not be selected with other deals!");
                    document.getElementById("ctl00_BodyContent_txtAvisDiscount").value="";
                    document.getElementById("ctl00_BodyContent_txtBudgetDiscount").value="";
                    document.getElementById("ctl00_BodyContent_txtHertzDiscount").value="";
                }
            }
            
            function checkOodlesDeals()
            {
            if (document.getElementById("ctl00_BodyContent_txtOodlesDiscount").value != "" )
                {
                alert("Oodles' deal can not be selected with other deals!");
                    document.getElementById("ctl00_BodyContent_txtAvisDiscount").value="";
                    document.getElementById("ctl00_BodyContent_txtBudgetDiscount").value="";
                    document.getElementById("ctl00_BodyContent_txtHertzDiscount").value = "";
                    document.getElementById("ctl00_BodyContent_txtEuropCarDiscount").value = "";
                }
            }
            
            function ValidateDiscountCode(me)
            {
                var SupplierVal = me.value; 
                var FirstPart = SupplierVal.substring(1,4);
                var SecPart = SupplierVal.substring(4,7);
                if ((isInteger(FirstPart)==true || isInteger(SecPart)==false || SupplierVal.length >= 8 || SupplierVal.length < 7) && (SupplierVal.length != 0))
                {
                    alert("Invalid discount code");
                    me.value="";
                    return false;
                }
            }
            
            function ValidateHertzDiscountCode(me)
            {
                var SupplierVal = me.value; 
                if (( isInteger(SupplierVal)==false || SupplierVal.length > 7 || SupplierVal.length < 6) && (SupplierVal.length != 0))
                {
                    alert("Invalid Hertz discount code");
                    me.value="";
                    return false;
                }
            }

           function isInteger (s)
           {
              var i;

              if (isEmpty(s))
              if (isInteger.arguments.length == 1) return 0;
              else return (isInteger.arguments[1] == true);

              for (i = 0; i < s.length; i++)
              {
                 var c = s.charAt(i);

                 if (!isDigit(c)) return false;
              }

              return true;
           }
           
           function isEmpty(s)
           {
              return ((s == null) || (s.length == 0))
           }
           function isDigit (c)
           {
              return ((c >= "0") && (c <= "9"))
           }
           
           function ValidateMembCode(me)
           {
           var regx = /\w/;
           var memNo= me.value;
           if (memNo != ""){
               if (!((regx.test(memNo) && (memNo.length == 6))))
               { 
                        alert("Please enter a correct Membership Number.");
                        me.value="";
                        return false;
               } 
             }
             return true;
           }
           
           
          function ValidateHertzMembCode(me)
           {
           var regx = /\w/;
           var memNo= me.value;
           if (memNo != ""){
               if (!((regx.test(memNo) && (memNo.length == 8))))
               { 
                        alert("Please enter a correct Membership Number.");
                        me.value="";
                        return false;
               } 
             }
             return true;
           }
           
           function ValidateThriftyMembCode(me)
           {
           var regx = /\w/;
           var memNo= me.value;
           if (memNo != ""){
               if (!((regx.test(memNo) && (memNo.length == 6))))
               { 
                        alert("Please enter a correct Membership Number.");
                        me.value="";
                        return false;
               } 
             }
             return true;
           }
           
           
               function OnClientItemsRequestingHandler(sender, eventArgs)  
    {  
       if (sender.get_text().length < 2)  
       {  
           sender.clearItems();
           eventArgs.set_cancel(true);  
       }  
    }

    var popWin;
    function dealsPopup() 
    {
      popWin=window.open( 'Popups/discountDeals.aspx', "myWindow","status=0,height=300,scrollbars=1,width=600,resizable=0,left=350,top=250" );
    }
    
    function newsletterPopup() 
    {
      popWin=window.open( 'Popups/Newsletter.aspx', "myWindow","status=0,height=200,scrollbars=0,width=400,resizable=0,left=350,top=250" );
  }

  function childseatpopup() {
      popWin = window.open('Popups/ChildSeat.aspx', "myWindow", "status=0,height=270,scrollbars=0,width=555,resize=0,scrolling=0,center=1");
  }
  function excessReduction() {
      popWin = window.open('Popups/excessReduction.aspx', "myWindow", "status=0,height=270,scrollbars=0,width=555,resize=0,scrolling=0,center=1");
  }
    function closepopup()
    {
     if (popWin) //(false == popWin.closed) 
     {
        popWin.close();
     }
 }

 function clearAvisCode() {
     document.getElementById("ctl00_BodyContent_txtAvisDiscount").value = "";
 }
 function clearBudgetCode() {
     document.getElementById("ctl00_BodyContent_txtBudgetDiscount").value = "";
 }
 function clearHertzCode() {
     document.getElementById("ctl00_BodyContent_txtHertzDiscount").value = "";

 }
 function clearEuropcarCode() {
     document.getElementById("ctl00_BodyContent_txtEuropcarDiscount").value = "";

 }
 function clearOodlesCode() {
     document.getElementById("ctl00_BodyContent_txtOodlesDiscount").value = "";
 }

 function FillPromotion(promoCode, SupplierID) {

     if (SupplierID == '1') {
         document.getElementById("ctl00_BodyContent_txtAvisDiscount").value = promoCode;
     }
     if (SupplierID == '2') {
         document.getElementById("ctl00_BodyContent_txtBudgetDiscount").value = promoCode;
     }
     if (SupplierID == '3') {
         document.getElementById("ctl00_BodyContent_txtEuropcarDiscount").value = promoCode;
     }
     if (SupplierID == '4') {
         document.getElementById("ctl00_BodyContent_txtHertzDiscount").value = promoCode;
     }
     
 
 }
