﻿
// JScript File

// By Nawal: 31 Oct 2007
//edited: M. Sohail Amjad 13/03/2009
//this is made for optional extras

 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 clearChildSeats()
        //{
        //document.getElementById("ddlChildSeats").selectedIndex=0;
        //document.getElementById("ddlInfantSeats").selectedIndex=0;
        //document.getElementById("ddlBoosterSeats").selectedIndex=0;
        ////nawal:clears validation message


//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

var popWin;

function dealsPopup() {
    popWin = window.open('http://oodles.com/Popups/discountDeals.aspx', "myWindow", "status=0,height=300,scrollbars=1,width=600,resizable=0,left=350,top=250");
}
function childseatpopup() {
    popWin = window.open('http://oodles.com/Popups/ChildSeat.aspx', "myWindow", "status=0,height=270,scrollbars=0,width=555,resize=0,scrolling=0,center=1");
}

function excessReduction() {
    popWin = window.open('http://oodles.com/Popups/excessReduction.aspx', "myWindow", "status=0,height=270,scrollbars=0,width=555,resize=0,scrolling=0,center=1");
}

function myPopup(code) {
    popWin = window.open('http://oodles.com/PopUps/discountDeals.aspx', "myWindow", "status=0,height=200,scrollbars=1,width=400,resizable=0,left=350,top=250")
}
function closepopup()
{
 if (popWin) //(false == popWin.closed) 
 {
    popWin.close();
 } 
}
//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("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;
              checkOtherDeals();
              closepopup();
              break;
            default:
              alert('Some problem occurred during the process.');
            }
            }
  function clearDiscountCode()
    {
        document.getElementById("lblMess").innerHTML="";
        document.getElementById("ctl00_BodyContent_txtAvisDiscount").value="";
        document.getElementById("ctl00_BodyContent_txtBudgetDiscount").value="";
        document.getElementById("ctl00_BodyContent_txtHertzDiscount").value="";
        document.getElementById("ctl00_BodyContent_txtOodlesDiscount").value="";
        
        var message="You have to hit Search button to update your search."
        document.getElementById("lblMess").innerHTML=message;
        
    }
function myPopup() {
popWin=window.open( 'Popups/discountDeals.aspx', "myWindow","status=0,height=200,scrollbars=1,width=400,resizable=0,left=350,top=250" )
}

//function promptForSearchBtn(){
//        document.getElementById("ddlChildSeats").selectedIndex=0;
//        document.getElementById("ddlInfantSeats").selectedIndex=0;
//        document.getElementById("ddlBoosterSeats").selectedIndex=0;
////         if (document.getElementById("CustValiTotChildSeats").value != "")
////          {
//           document.getElementById("CustValiTotChildSeats").innerHTML= "Please click the search button."
////          }
//        }

//Nawal:26Sep2007(v-3.2):This function shows a message if child seats are altered/modified.
function clickSearch(){
    var box = document.form1.ddlChildSeats;
	var destination = box.options[box.selectedIndex].value;
	var message="You have to hit Search button to update your search."
    //alert(message);
    document.getElementById("lblMess").innerHTML=message;

    }
    
// Sohail - 07 MAY 2008 -
            function checkOtherDeals()
            {
            if (document.getElementById("ctl00_BodyContent_txtAvisDiscount").value !="" || 
            document.getElementById("ctl00_BodyContent_txtBudgetDiscount").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 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="";
                }
            } 
// End -------- Sohail - 07 MAY 2008 -

            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="";
                }
            }
            
            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 correct Membership Number.");
                        me.value="";
                        return false;
                    }else {
                        var message="If you have made a change, hit Search button."
                        document.getElementById("lblMess").innerHTML=message;
                    }
                }
           }
           
                     
           function ValidateHertzMembCode(me)
           {
                var regx = /\w/;
                var memNo= me.value;
                if (memNo != "")
                {
                    if (!((regx.test(memNo) && (memNo.length == 8))))
                    { 
                        alert("Please enter correct Membership Number.");
                        me.value="";
                        return false;
                    }else {
                        var message="If you have made a change, hit Search button."
                        document.getElementById("lblMess").innerHTML=message;
                    }
                }
           }
            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 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);
    }
    function newsletterPopup() 
    {
        popWin = window.open('http://oodles.com/Popups/Newsletter.aspx', "myWindow", "status=0,height=200,scrollbars=0,width=400,resizable=0,left=350,top=250");
  }

  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 clearOodlesCode() {
      document.getElementById("ctl00_BodyContent_txtOodlesDiscount").value = "";
  }
