﻿// global variables
var isMozilla;
var objDiv = null;
var originalDivHTML = "";
var DivID = "";

var over = false;
var dayList = new Array('الأحد', 'الأثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت');
var monthList = new Array('يناير', 'فبراير', 'مارس', 'ابريل', 'مايو', 'يونيو', 'يوليه', 'اغسطس', 'سبتمبر', 'اكتوبر', 'نوفمبر', 'ديسمبر');
var SoonList = new Array('done1.png', 'done2.png', 'done3.png', 'done4.png');
var timeout;

//header rotator
function soonrotator() {
    var rand = Math.floor(Math.random() * 4);
    document.write("<img src='RixonIncludes/Style/images/header/" + SoonList[rand] + "' alt='شركة سياحية - وكالة سياحة و سفر - ركسون فرع الرياض' />");
}
// bookmarkv
function bookmark() {
    if (document.all)
    { window.external.AddFavorite("http://www.myrtn.com", "شبكة ركسون للسياحة -  سياحة وسفر – رحلات سياحية - عروض سياحية - خدمات سياحية - حجز فنادق | Rixon tours network"); }
    else if (window.sidebar) // firefox
    { window.sidebar.addPanel("شبكة ركسون للسياحة -  سياحة وسفر – رحلات سياحية - عروض سياحية - خدمات سياحية - حجز فنادق | Rixon tours network", "http://www.myrtn.com", ""); }
}
shuffle = function(o) { //v1.0
    for (var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
    return o;
};

//Newst Tours 
function BarDir(Dir, speed, pauseimg) {
    document.getElementById('LatestNewsM').direction = Dir;
    document.getElementById('LatestNewsM').scrollAmount = speed;
    document.getElementById('imgPauseScrolling').src = 'RixonIncludes/Style/images/header/' + pauseimg + '.png';
}
function changvideo(url,city) {
    document.getElementById("vid-emb").innerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="338" height="257" hspace="0" vspace="0">' +
                                                '<param name="movie" value="' + url + '&" />' +
                                                '<param name="quality" value="high" />' +
                                                '<param name="wmode" value="transparent" />' +
                                                '<param name="allowscriptaccess" value="always" />' +
                                                '<param name="allowFullScreen" value="true" />' +
                                                '<embed pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" src="' + url + '&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="338" height="257" wmode="transparent"></embed>' +
                                            '</object>';
}
function showHide(link,obj) {
    if (document.getElementById(obj).style.display == "none") {
        document.getElementById(obj).style.display = "block";
        document.getElementById(link).innerHTML = "<img src='RixonIncludes/Style/images/icon/collapse_tcat.gif' border='0' height='11px' width='11px' align='middle'/> مقترحات يمكن إضافتها للرحلة";
    }
    else {
        document.getElementById(obj).style.display = "none";
        document.getElementById(link).innerHTML = "<img src='RixonIncludes/Style/images/icon/collapse_tcat_collapsed.gif' border='0' height='11px' width='11px' align='middle'/> مقترحات يمكن إضافتها للرحلة";
    }

}


//Date and Time
function setluDateTime() {
    var tempDateObj = new Date();
    var tempDay = dayList[tempDateObj.getDay()];
    var tempMonth = monthList[tempDateObj.getMonth()];
    var tempDate = tempDateObj.getDate();
    var tempYear = tempDateObj.getFullYear();
    return "أخر تحديث للموقع " + tempDay + ' ' + tempDate + ' ' + tempMonth + '  ' + tempYear;
}

//Check date for hotel booking
function CheckDate() {
    var cuur = new Date();
    var fromDate = new Date();
    var txtFromDate = document.getElementById("inv_date").value;
    var aFromDate = txtFromDate.split("/");
    var fdd = aFromDate[1]; //get the day part 
    var fmm = aFromDate[0]; //get the month part 
    var fyyyy = aFromDate[2]; //get the year part

    fromDate.setDate(fdd);
    fromDate.setMonth(fmm - 1);
    fromDate.setFullYear(fyyyy);
    if (fromDate <= cuur) {
        alert("خطأ في تاريخ الدخول");
        return false;
    }
    else { return true; }
}
function CalculateExitDate() {
    var fromDate = new Date(document.getElementById("inv_date").value);
    var nights;
    if (document.getElementById("ctl00_ContentPlaceHolder1_birthday")) {
        nights = parseInt(document.getElementById("ctl00_ContentPlaceHolder1_birthday").value, 0);
    }
    else { nights = 1; }
    fromDate.setDate(fromDate.getDate() + nights);
    if (document.getElementById("EndDate"))
    { document.getElementById("EndDate").innerHTML = fromDate.getDate() + " - " + monthList[fromDate.getMonth()] + " - " + fromDate.getFullYear(); }
}
//Pop window
function PopupWin(URl, Name, Attributs) {
    var neww;
    neww = window.open(URl, Name, Attributs);
    neww.window.focus();
}
//Show result of hotel book search contentDocument
function ShowResult() {
    if (document.getElementById("ctl00_ContentPlaceHolder1_Hideres")) {
        var hiddeninput = document.getElementById("ctl00_ContentPlaceHolder1_Hideres");
        if (document.getElementById("ResultFrame")) { Show(hiddeninput.value); }
        hiddeninput.value = null;
    }
}
function Show(val) {
    var testFrame = document.getElementById("ResultFrame");
    var doc = testFrame.contentDocument;

    if (doc == undefined || doc == null)
    { doc = testFrame.contentWindow.document; }
    
    doc.open();
    doc.write("<html class='html-fram'><head><link href='RixonIncludes/Style/style.css' rel='stylesheet' type='text/css' /></head><body class='body-fram'>" + val + "</body></html>");
    doc.close();
    testFrame.style.height = testFrame.contentWindow.document.body.scrollHeight + "px";
    testFrame.style.visibility = "visible";
}
//Check validation of reservation page
function CheckResevvalid() {
    if (Page_ClientValidate()) {
        if ((document.getElementById('ctl00_ContentPlaceHolder1_TourBook_tbl') != null || document.getElementById('ctl00_ContentPlaceHolder1_Hotel_tbl') != null) && document.getElementById('ctl00_ContentPlaceHolder1_Sgl_occup_txt').value == "" && document.getElementById('ctl00_ContentPlaceHolder1_Dbl_occup_txt').value == "" && document.getElementById('ctl00_ContentPlaceHolder1_Trpl_occup_txt').value == "") {
            alert('يجب أن تحدد عدد الغرف المطلوبة سواء مفردة أو ثنائية أو ثلاثية');
            return false;
        }
        else if (document.getElementById('ctl00_ContentPlaceHolder1_SeaBook_tbl') != null && document.getElementById('ctl00_ContentPlaceHolder1_InteriorNum_txt').value == "" && document.getElementById('ctl00_ContentPlaceHolder1_OceanviewNum_txt').value == "" && document.getElementById('ctl00_ContentPlaceHolder1_BalconyNum_txt').value == "" && document.getElementById('ctl00_ContentPlaceHolder1_SuiteNum_txt').value == "") {
            alert('يجب أن تحدد عدد الكبائن المطلوبة سواء داخلية أو مطل علي البحر أو بلكون أو جناح');
            return false;
        }
        else if (document.getElementById('ctl00_ContentPlaceHolder1_Agree_chk').checked == false) {
            alert('للأتمام عملية الحجز لابد من الموافقه علي قوانين وشروط ريكسون');
            document.getElementById('ctl00_ContentPlaceHolder1_Agree_chk').focus();
            return false;
        }
        else { return true; }
    }
    else { return false; }
}
function setOpacity(obj, opacity) {
    opacity = (opacity == 100) ? 99.999 : opacity;
    // IE/Win
    obj.style.filter = "alpha(opacity:" + opacity + ")";
    // Safari<1.2, Konqueror
    obj.style.KHTMLOpacity = opacity / 100;
    // Older Mozilla and Firefox
    obj.style.MozOpacity = opacity / 100;
    // Safari 1.2, newer Firefox and Mozilla, CSS3
    obj.style.opacity = opacity / 100;
}
function fadeIn(objId, opacity) {
    if (document.getElementById) {
        obj = document.getElementById(objId);
        if (opacity <= 100) {
            setOpacity(obj, opacity);
            opacity += 10;
            window.setTimeout("fadeIn('" + objId + "'," + opacity + ")", 100);
        }
    }
}
function SwitchMenu(obj) {
    if (document.getElementById) {
        var el = document.getElementById(obj);
        var ar = document.getElementById("faqscontent").getElementsByTagName("div"); //DynamicDrive.com change
        if (el.style.display != "block") { //DynamicDrive.com change
            for (var i = 0; i < ar.length; i++) {
                 //DynamicDrive.com change
                ar[i].style.display = "none";
            }
            el.style.display = "block";
        }
        else {
            el.style.display = "none";
        }
    }
}

/*FloatingDiv Functions Start*/
function displayFloatingDiv(divId, title, imgname, width, height, flag, desc) {
    DivID = divId;
    document.getElementById(divId).style.width = width + 'px';
    document.getElementById(divId).style.height = height + 'px';
    if (flag == 0 || flag == 2) {
        document.getElementById(divId).style.left = (screen.width / 2 - width / 2) + 'px';
        document.getElementById(divId).style.top = 450 + 'px';

        var addHeader = '<table width="' + width + 'px" class="floatingHeader"><tr style="cursor:move;height:18px">' +
	                '<td width="18" align="right"><a href="javascript:hiddenFloatingDiv(\'' + divId + '\');void(0);"><img alt="Close..." title="Close..." src="RixonIncludes/Style/images/icon/close.jpg" width="18" height="18" border="0"></a></td>' +
	                '<td align="center" ondblclick="void(0);" onmouseover="over=true;" onmouseout="over=false;">' + title + '</td>' +
	                '</tr></table>';

        if (flag == 0)
        { addHeader = addHeader + '<img src="RixonIncludes/Style/images/static-img/' + imgname + '.png"  border="0" />'; }
        else { addHeader = addHeader + '<object width="480" height="385"><param name="movie" value="http://www.youtube.com/p/BE44EC134498F74E?hl=en_US&amp;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/p/BE44EC134498F74E?hl=en_US&amp;fs=1" type="application/x-shockwave-flash" width="480" height="385" allowscriptaccess="always" allowfullscreen="true"></embed></object>'; }

        document.getElementById(divId).innerHTML = addHeader;
    }
    else {
        if (isMozilla) {
            document.getElementById(divId).style.left = window.event.screenY + 'px';
            document.getElementById(divId).style.top = window.event.screenY + 'px';
        }
        else {
            document.getElementById(divId).style.left = (mouseX(window.event) - width) + 'px';
            document.getElementById(divId).style.top = (mouseY(window.event) - (height / 2)) + 'px';
        }
        var addHeader = '<div class="SO-container">' +
                            '<div ondblclick="void(0);" class="SO-title"><h3>' + title + '</h3></div>' +
                            '<div class="SO-contents"><p>' + desc + '</p><img src="http://www.myrtn.com/Special_offer/images/' + imgname + '" border="0"/></div>' +
                            '</div>';
    }
    document.getElementById(divId).innerHTML = addHeader;
    document.getElementById(divId).className = 'dimming';
    document.getElementById(divId).style.display = "block";
}
function hiddenFloatingDiv(divId) {
    document.getElementById(divId).innerHTML = "";
    document.getElementById(divId).style.display = 'none';
    DivID = "";
}
 function mouseX(evt) {
    if (evt.pageX) return evt.pageX;
    else if (evt.clientX)
        return evt.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
    else return null;
}
function mouseY(evt) {
    if (evt.pageY) return evt.pageY;
    else if (evt.clientY)
        return evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
    else return null;
}
function MouseDown(e) {
    if (over) {
        if (isMozilla) {
            objDiv = document.getElementById(DivID);
            X = e.layerX;
            Y = e.layerY;
            return false;
        }
        else {
            objDiv = document.getElementById(DivID);
            objDiv = objDiv.style;
            X = event.offsetX;
            Y = event.offsetY;
        }
    }
}
function MouseMove(e) {
    if (objDiv) {
        if (isMozilla) {
            objDiv.style.top = (e.pageY - Y) + 'px';
            objDiv.style.left = (e.pageX - X) + 'px';
            return false;
        }
        else {
            objDiv.pixelLeft = event.clientX - X + document.body.scrollLeft;
            objDiv.pixelTop = event.clientY - Y + document.body.scrollTop;
            return false;
        }
    }
}
function MouseUp() {
    objDiv = null;
}
function init() {
    // check browser
    isMozilla = (document.all) ? 0 : 1;
    if (isMozilla) {
        document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP);
    }
    document.onmousedown = MouseDown;
    document.onmousemove = MouseMove;
    document.onmouseup = MouseUp;
}
// call init
init();
/*FloatingDiv Functions End*/
