function alert111()
{
        alert('111');
}

function loadPage()
{
        /*
        alert('1');
        var objCollection=document.getElementsByName('extraHotelsInChain_hotel');
        alert(objCollection);
        alert(objCollection.length); //IE PROBLEM!!!!
        for (i=0;i<=objCollection.length-1;i++)
        {
                alert(objCollection[i]);
                var objDiv=objCollection[i];
                alert(objDiv);
        }
        */

       hideExtraHotlsInChain('extraHotelsInChain_hotel_1');
       hideExtraHotlsInChain('extraHotelsInChain_hotel_2');
       hideExtraHotlsInChain('extraHotelsInChain_hotel_3');
       hideExtraHotlsInChain('extraHotelsInChain_hotel_4');
       hideExtraHotlsInChain('extraHotelsInChain_hotel_5');
       hideExtraHotlsInChain('extraHotelsInChain_hotel_6');
       hideExtraHotlsInChain('extraHotelsInChain_hotel_7');
       hideExtraHotlsInChain('extraHotelsInChain_hotel_8');
       hideExtraHotlsInChain('extraHotelsInChain_hotel_9');
       hideExtraHotlsInChain('extraHotelsInChain_hotel_10');
}

function hideExtraHotlsInChain(divId)
{
       var objDiv = document.getElementById(divId);
       if(!objDiv)
                return;
               
       //alert(objDiv);
       //alert(divId + '_1');

       var strHtml1 = document.getElementById(divId + '_1').innerHTML;
       var strHtml2 = document.getElementById(divId + '_2').innerHTML;
       var strHtml3 = document.getElementById(divId + '_3').innerHTML;

       if(strHtml1 == '' && strHtml2 == '' & strHtml3 == '')
       {
               //alert('nothing here');
               objDiv.style.display = 'none';
       }
}




//ISROTEL ENGINE SCRIPT
function goSearchEngine()
{
        var daysInMonth = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
        var days;
        if (1 == document.SearchEngine.FromMonth.value-1)
                days =  ((0 == document.SearchEngine.FromYear.value % 4) && (0 != (document.SearchEngine.FromYear.value % 100))) || (0 == document.SearchEngine.FromYear.value % 400) ? 29 : 28;
        else
                days =  daysInMonth[document.SearchEngine.FromMonth.value-1];
        if(document.SearchEngine.FromDay.value > days)
        {
                alert("תאריך הגעה לא תקף")
                return false;
        }
        if (1 == document.SearchEngine.ToMonth.value-1)
                days =  ((0 == document.SearchEngine.ToYear.value % 4) && (0 != (document.SearchEngine.ToYear.value % 100))) || (0 == document.SearchEngine.ToYear.value % 400) ? 29 : 28;
        else
                days =  daysInMonth[document.SearchEngine.ToMonth.value-1];
        if(document.SearchEngine.ToDay.value > days)
        {
                alert("תאריך עזיבה לא תקף");
                return false;
        }
        var objNow = new Date('2009','0','25');
        var objFromDate = new Date(document.SearchEngine.FromYear.value  ,document.SearchEngine.FromMonth.value-1 ,document.SearchEngine.FromDay.value   )
        var objToDate = new Date(document.SearchEngine.ToYear.value  ,document.SearchEngine.ToMonth.value-1 ,document.SearchEngine.ToDay.value   )

        if (objFromDate < objNow)
        {
                alert("תאריך זה אינו תקף");
                return false;
        }
        if (objToDate <= objFromDate)
        {
                alert("תאריך הגעה חייב להיות קודם לתאריך העזיבה");
                return false;
        }
        if(document.SearchEngine.AdultNum.value == '0' && document.SearchEngine.KidNum.value == '0')
        {
                alert("בחר את מספר הנופשים");
                return false;
        }
        if((parseInt(document.SearchEngine.AdultNum.value) + parseInt(document.SearchEngine.KidNum.value)) > 6)
        {
                alert("חרגת ממקסימום נפשות לחדר");
                return false;
        }
        if(parseInt(document.SearchEngine.AreaHotelId.value) > 100)
        {
                document.SearchEngine.AreaId.value = document.SearchEngine.AreaHotelId.value;
                document.SearchEngine.HotelId.value = "0";
        }
        else
        {
                document.SearchEngine.HotelId.value = document.SearchEngine.AreaHotelId.value;
                document.SearchEngine.AreaId.value = '0';
        }
        //document.SearchEngine.submit();
        return true;       
}


/*DEALS*/
function get_deals()
{
        //alert(document.getElementById('div_deals_container').innerHTML);
        //alert('get_deals');
        //PARAMS
        var strBlogInfo = document.getElementById('txtBlogInfo').value;
        var style = document.getElementById('txtStyle').value;
        var deal_type = remove_p_tag(document.getElementById('txtDealType').value);
        var city = remove_p_tag(document.getElementById('txtCity').value);
        var hotel_rating = remove_p_tag(document.getElementById('txtHotelRating').value);
        var hotel_name = remove_p_tag(document.getElementById('txtHotelName').value);
        var deals = document.getElementById('txtDeals').value;
        var strParams = "action=get_deals&strBlogInfo=" + strBlogInfo + "&style=" + style + "&deal_type=" + deal_type + "&city=" + city;
        strParams = strParams + "&hotel_rating=" + hotel_rating + "&hotel_name=" + hotel_name + "&deals=" + deals;
        //alert(strParams);
        //ofekTest();
        //alert(hotel_rating);


        //alert(strBlogInfo);
        //var strAjaxUrl = 'wp-content/themes/5_stars/ajax.php';
        //var strAjaxUrl = '../wp-content/themes/5_stars/ajax.php';
        var strAjaxUrl = strBlogInfo + '/ajax.php';
        ajaxPost(strAjaxUrl, get_deals_hander, strParams);
}
function get_deals_hander()
{
        //alert('get_deals_hander');
        if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
                //alert(xmlhttp.responseText);
                document.getElementById('div_deals_container').innerHTML = xmlhttp.responseText;

                //HIDE BOX IN CASE IT'S EMPTY OR THERE IS NO HEADER
                var strTemp = document.getElementById('deal_header').innerHTML;
                var strTemp2 = xmlhttp.responseText;
                strTemp = strTemp.replace(/^\s*/, "").replace(/\s*$/, ""); //TRIM
                strTemp2 = strTemp2.replace(/^\s*/, "").replace(/\s*$/, ""); //TRIM
                //if(strTemp =='' || strTemp2 =='')
                        //document.getElementById('div_deals_wide').style.display='none';

                if(strTemp =='' || strTemp2 =='')
                {
                        if (document.getElementById('div_deals_wide') != null)
                                document.getElementById('div_deals_wide').style.display='none';

                        if (document.getElementById('div_deals_narrow') != null)
                                document.getElementById('div_deals_narrow').style.display='none';
                }



        }
}
/*END DEALS*/

function remove_p_tag(str)
{
        str = str.replace("<p>", "")
        str = str.replace("</p>", "")
        str = str.replace("\n", "")
        str = str.replace("\r", "")
        //str = escape(str);
        return str;
}

