﻿var retUrlArr = new Array();
//for flights
retUrlArr.push("Listing.aspx".toLowerCase());
retUrlArr.push("publishbooking.aspx".toLowerCase());
retUrlArr.push("domesticbooking.aspx".toLowerCase());
//for hotels
retUrlArr.push("listing.aspx".toLowerCase());
retUrlArr.push("PassengerDetails.aspx".toLowerCase());
retUrlArr.push("PaymentConfirmation.aspx".toLowerCase());
//for transfer
retUrlArr.push("TransferListing.aspx".toLowerCase());
retUrlArr.push("PassengerDetails.aspx".toLowerCase());
retUrlArr.push("PaymentConfirmation.aspx".toLowerCase());

pathArray = window.location.pathname.split( '/' );
var curURL = pathArray[pathArray.length-1];
var retURL = "";
for (var cnt=0;cnt<retUrlArr.length;cnt++)
{
	if(curURL.toLowerCase() == retUrlArr[cnt])
	{
		retURL = document.location.href;
	}
}

var strhttpPath="http://www.wakanow.com";
var strhttpsPath="https://www.wakanow.com";

function createCookie(name,value,days)
    {
          if (days)
          {
            var date = new Date();
            date.setTime(date.getTime() + (days*24*60*60*1000));
            var expires = "; expires=" + date.toGMTString();
          }
          else 
            var expires = "";
          document.cookie = name + "=" + value + expires + "; path=/";
    };
    
    function readCookie(name)
    {
          var nameEQ = name + "=";
          var ca = document.cookie.split(';');
          for(var i=0;i < ca.length;i++)
          {
                var c = ca[i];
                while (c.charAt(0)==' ') c = c.substring(1,c.length);
                if (c.indexOf(nameEQ) == 0) 
                    return c.substring(nameEQ.length,c.length);
          }
          return null;
    };
    
    function eraseCookie(name)
    {
          createCookie(name,"",-1);
    };
function getTopNave(domainName)
{
    var topNavHtml = new Array();
     topNavHtml.push("<table class='login' id='spnLogin' style='display: block;background-image:url(" + strhttpsPath + "/Images/login_bg1.jpg); background-repeat:no-repeat; height:45px;width:179px;'>");
                                            topNavHtml.push("<tr>");                                            
                                                topNavHtml.push("<td align='left' style='text-align: left; padding-left: 70px;font-family:Verdana;font-size:12px; color:#EA6C08;line-height:18px;'>");
                                                    topNavHtml.push("<b>My Account</b>");                       
                                                topNavHtml.push("</td>");
                                            topNavHtml.push("</tr>");                                            
                                             topNavHtml.push("<tr>");                                           
                                                 topNavHtml.push("<td align='left' style='text-align:left;padding-left:60px;'>");  
                                                     topNavHtml.push("<span style='font-size:12px;font-family:verdana;color:#0B6138;'>");
            if(retURL!="")
				topNavHtml.push("<a style='color:#0B6138;' href='" + strhttpPath + "/login.aspx?returnURL="+retURL+"'> Login</a>&nbsp;|&nbsp;");
			else
				topNavHtml.push("<a style='color:#0B6138;' href='" + strhttpPath + "/login.aspx'> Login</a>&nbsp;|&nbsp;");                                               
            topNavHtml.push("<a style='color:#0B6138;' href='" + strhttpPath + "/registration.aspx'>Register</a></span>");                                                
        topNavHtml.push("</td>");
         topNavHtml.push("</tr>");
      topNavHtml.push("</table>");    
    return topNavHtml.join("");
}

function getFeedback()
{
    var feedbackHtml = new Array();
    
    feedbackHtml.push("<img src='" + strhttpsPath + "'/images/cross-close.gif' alt='' title='Close' width='11' height='11' border='0' style='cursor:pointer; float:right;' onclick='HideFeedback();' />");
    feedbackHtml.push("<div style='clear:both; margin:5px 10px 10px 10px; padding:10px; border:1px solid #000;'>");
        feedbackHtml.push("<table border='0' cellpadding='0' cellspacing='0' width='100%'>");
            
            feedbackHtml.push("<tr>");
                feedbackHtml.push("<td colspan='3' align='left' style='margin-bottom:10px; margin-top:10px; color:white; height:15px' bgcolor='#37A0B8'>&nbsp;&nbsp;<b>Feedback Form</b></td>");
            feedbackHtml.push("</tr>");
            
            feedbackHtml.push("<tr>");
                feedbackHtml.push("<td colspan='3' align='center' style='height:10px'>");
                    feedbackHtml.push("<div id='divMsg' style='padding-top:10px; padding-bottom:10px; width:100%; color:rgb(234, 108, 8);'></div>");
                feedbackHtml.push("</td>");
            feedbackHtml.push("</tr>");
            
            feedbackHtml.push("<tr>");
                feedbackHtml.push("<td align='left' valign='top' style='width:60px'>Title</td>");
                feedbackHtml.push("<td align='center' valign='top' style='width:20px'> : </td>");
                feedbackHtml.push("<td align='left' valign='top' style='width:370px'>");
                    feedbackHtml.push("<input type='text' id='txtFeedBack_Title' name='txtFeedBack_Title' runat='server' value='' class='fieldFeedback' style='width:330px' maxlength='200' />");
                feedbackHtml.push("</td>");
            feedbackHtml.push("</tr>");
            
            feedbackHtml.push("<tr>");
                feedbackHtml.push("<td colspan='3' align='left' style='height:10px'></td>");
            feedbackHtml.push("</tr>");
            
            feedbackHtml.push("<tr>");
                feedbackHtml.push("<td align='left' valign='top' style='width:60px; height: 24px;'>Message</td>");
                feedbackHtml.push("<td align='center' valign='top' style='width:20px; height: 24px;'> : </td>");
                feedbackHtml.push("<td align='left' valign='top' style='width:370px; height: 24px;'>");    
                    feedbackHtml.push("<textarea id='txtFeedBack_Message' name='txtFeedBack_Message' rows='6' cols='1' runat='server' class='fieldFeedback' style='width:330px' maxlength='500'></textarea>");
                feedbackHtml.push("</td>");
            feedbackHtml.push("</tr>");
            
            feedbackHtml.push("<tr>");
                feedbackHtml.push("<td colspan='3' align='left' style='height:10px'></td>");
            feedbackHtml.push("</tr>");
            
            feedbackHtml.push("<tr>");
                feedbackHtml.push("<td align='center' colspan='3'>");
                    feedbackHtml.push("<img src='" + strhttpsPath + "/Images/wakanow-submit_new.gif' alt='' title='Submit' border='0' style='cursor:pointer;' onclick='javascript:return Validate_And_SendMail();' />");
                    feedbackHtml.push("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src='" + strhttpsPath + "/Images/wakanow-close_new.gif' alt='' title='Close' border='0' style='cursor:pointer;' onclick='HideFeedback();' />");                
                feedbackHtml.push("</td>");
            feedbackHtml.push("</tr>");
            
        feedbackHtml.push("</table>");
    feedbackHtml.push("</div>");
    
    return feedbackHtml.join("");
}

function trim(sStr)
{   
    var oRegSpaces = /^\s+(.*?)\s+$/;
    return sStr.replace(oRegSpaces, "$1");
}

function ShowFeedback()
{
    if (document.getElementById('txtFeedBack_Title') != null)
        document.getElementById('txtFeedBack_Title').value = "";  
        
    if (document.getElementById('txtFeedBack_Message') != null)
        document.getElementById('txtFeedBack_Message').value = "";  
        
    if (document.getElementById('divMsg') != null)
        document.getElementById('divMsg').innerHTML = "";    
        
    if (document.getElementById("divFeedback") != null)
    {
        var pageWidth = 0;
        var pageHeight = 0;
        
        if (document.body.clientWidth)
            pageWidth = document.body.clientWidth;     
        else
            pageWidth = 1000;           
        
        //if (document.body.clientHeight)
        //    pageHeight = document.body.clientHeight;
        
        document.getElementById("divFeedback").style.left = (pageWidth - 470) + "px";
        document.getElementById("divFeedback").style.top = "60px";
    
        document.getElementById("divFeedback").style.display = "block";        
    }       
}

function HideFeedback()
{       
    if (document.getElementById("divFeedback") != null)
        document.getElementById("divFeedback").style.display = "none";        
}

function Validate_And_SendMail()
{   
    // Validate and if No Blank fields found then send Feedback Message to Support  
    
    if (document.getElementById('txtFeedBack_Title') != null)
    {  
       if (trim(document.getElementById('txtFeedBack_Title').value) == "")
       {   
           alert("Feedback Title should not be blank.")
           return false;
       }
    }
    
    if (document.getElementById('txtFeedBack_Message') != null)
    {
       if (trim(document.getElementById('txtFeedBack_Message').value) == "")
       {
           alert("Feedback Message should not be blank.")
           return false;
       }
    }  
    
    // Send Mail through sendMail.aspx page...
    
    if (document.getElementById('txtFeedBack_Title') != null && document.getElementById('txtFeedBack_Message') != null)    
    {
        if (document.getElementById('txtFeedBack_Title').value != "" && document.getElementById('txtFeedBack_Message').value != "")
        {
            var img = new Image();
                        
            var _txtTitleJS = escape(document.getElementById('txtFeedBack_Title').value);
            var _txtMessageJS = escape(document.getElementById('txtFeedBack_Message').value);
            
            var imgSrc = "SendMail.aspx?Title=" + _txtTitleJS + "&Msg=" + _txtMessageJS;
            img.src = imgSrc; // calling SendMail.aspx
            
            document.getElementById('txtFeedBack_Title').value = "";
            document.getElementById('txtFeedBack_Message').value = "";
            
            if (document.getElementById('divMsg') != null)
                document.getElementById('divMsg').innerHTML = "<b>Thanks for your feedback. We will get back to you asap.</b>";    
                
            return false;
        }
    }  
}
  var uPref = "US";
  
    var cookieName = 'User_Pref';
    function SetCookie(Pref)
    {
        var USRedirector = 'http://www.wakanow.com';
        var NGRedirector = 'http://www.wakanow.com/ng/';
        var URLRedirector = "";
        var nameEQ = cookieName + "=";
        var ca = document.cookie.split(';');
        for(var i=0; i<ca.length; i++)
        {
            var c = ca[i];
            while (c.charAt(0)==' ') 
                c = c.substring(1,c.length);
            if (c.indexOf(nameEQ) == 0) 
                uPref = c.substring(nameEQ.length,c.length);
            if(Pref != "US")
                Pref = "NG";
            if(uPref.toUpperCase() == "US")
            {
                if(Pref.toUpperCase() == uPref.toUpperCase() || Pref == "")
                    URLRedirector =  USRedirector;
                else
                {
                    eraseCookie(cookieName);
                    createCookie(cookieName, Pref, 7);
                    URLRedirector =  NGRedirector;
                }
            }
            else
            {
                if(Pref.toUpperCase() == uPref.toUpperCase() || Pref == "")
                    URLRedirector =  NGRedirector;
                else
                {
                    eraseCookie(cookieName);
                    createCookie(cookieName, Pref, 7);
                    URLRedirector =  USRedirector;
                }
            }
            window.location = URLRedirector;
        }
    }
