﻿// JScript File
/*
        AUTHOR  :         Alan Fong @ 5176
        Date    :         NOV1-07
        Purpose :         Javascript to control cms menu and tooltips
*/
//==============================
function createCookie(name,value,minutes) {
    if (minutes) {
        var date = new Date();
        //date.setTime(date.getTime()+(days*24*60*60*1000));
        date.setTime(date.getTime()+(minutes*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 ShowMenu(id){
        var obj = document.getElementById(id);
        
        if (obj){
            var theMenu=document.getElementsByTagName("a");
            if (theMenu.length>0) {
                for (i=0; i<theMenu.length; i++) {
                        if ((theMenu[i].className == "HideLink") || (theMenu[i].className == "ShowLink")){
                            theMenu[i].className = "HideLink";
                        }    
                }    
            }    
            document.getElementById(id).className = "ShowLink";
        }    
}

//==============================
function OpenTerm(dn)
{
    ///<summary></summary>
    ///<parm>dn - 1. Dayview  2. Nightview</parm>
    if (dn == "1"){
        window.location = "../AboutNygardCay/DayTerms.aspx?id=1804";
    }else{
        window.location = "../AboutNygardCay/NightTerms.aspx?id=1804";
    }    
}

//=============================
function OpenCloseDiv(eID) {
    if (document.getElementById(eID).style.display == "block") {
        document.getElementById(eID).style.display = "none";
    } 
    else {
        document.getElementById(eID).style.display = "block";
    }
}

//=============================
function OpenEvent(dn)
{
    if (dn == "1"){
        window.location = '../EventPhoto/EventPhotoDay.aspx?MID=18&PhotoId='+ encodeURIComponent("../ViewPhoto/Photo.com");
    }else{
        window.location = '../EventPhoto/EventPhotoNight.aspx?MID=18&PhotoId='+ encodeURIComponent("../ViewPhoto/NightPhoto.com");
    }

}

//============================
function WebTerms()
{
    today=new Date();
    y0=today.getFullYear();
    document.getElementById("WebTerms").innerHTML = "©" + y0 + " Nygard International Ltd.  All Rights Reserved.  Web Site Terms & Conditions of Use&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
}

//============================
function gup( name )
{  
    name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");  
    var regexS = "[\\?&]"+name+"=([^&#]*)";  
    var regex = new RegExp( regexS );  
    var results = regex.exec( window.location.href );  
    if( results == null )    
        return "";  
    else    
        return results[1];
}

//============================
function ShowVideo()
{
    var   menuid = gup('ID');
    if ((menuid != '1814') && (menuid != "")&& (menuid != '1816') ){
         var   aID = 'ID' + menuid;
         var v_obj;
         var v_attribute_list;
         var v_class;
         v_obj=document.getElementById(aID);
         v_attribute_list=v_obj.attributes;
         v_class=v_attribute_list.getNamedItem("class");
         v_class.value="HideLinkVideo";
    }
}

//============================
function OpenFullScreen(file)
{
    var PathFile = '/uploadedfiles/video/' + file;
    newwin = window.open(PathFile,'NygardCay','height=750,width=1000');
}

//============================
function PlayMusic()
{
    var musicsrc = '/Music/PJNFavorites.mp3';
    var html = "<embed src='" + musicsrc + "' width='200' height='20' loop='true'>"    
    var songArea = document.getElementById('Music');
    songArea.innerHTML = html;
}

//=============================
function OpenDayNight(e, mid)
{
    ///<summary>e-Day or Night, mid - location</summary>
    ///<param>e - 1.Day 2.Night</param>
    ///<param>mid - location ID</param>      
    if (e == "1"){
        if (mid == "1"){
            window.location = document.getElementById("URL").innerHTML;
            //window.location = "../AboutNygardCay/OverviewNight.aspx?id=1716&MID=1";
        }else if (mid == "2"){
             window.location = "../AboutNygardCay/HistoryNight.aspx?id=1706&MID=2";
        }else if (mid == "3"){
                window.location = "../AboutNygardCay/MapNight.aspx?MID=3";
        }else if (mid == "5"){
                window.location = "../AboutNygardCay/AccommodationNight.aspx?FlashID=1&MID=5";    
        }else if (mid == "6"){
                window.location = "../AboutNygardCay/DiningNight.aspx?FlashID=4&MID=6"; 
        }else if (mid == "7"){
                window.location = "../AboutNygardCay/ActivityNight.aspx?FlashID=5&MID=7";                     
        }else if (mid == "8"){
               window.location = "../Video/VideoListingNight.aspx?id=1816&FlashID=1&MID=8";
        }else if (mid == "9"){
               window.location = "../News/NewsNight.aspx?id=1820&MID=9"; 
        }else if (mid == "10"){
               window.location = "../BookCay/BookDetailsNight.aspx?id=1972&MID=10";
        }else if (mid == "11"){
               window.location = "../BookCay/BookReviewNight.aspx?id=1974&MID=11";
        }else if (mid == "12"){
               window.location = "../BookCay/BookingFormNight.aspx?id=1766&MID=12";       
        }else if (mid == "13"){
               window.location = "../BookCay/EmploymentNight.aspx?MID=13";       
        }else if (mid == "14"){
                window.location = "../360VideosNight/NygardCayNight.aspx?MID=14&FlashID=1";       
        }else if (mid == "15"){
               window.location = "../PhotoNight/PhotoGalleryNight.aspx?FlashID=21&MID=15";       
        }else if (mid == "16"){
               window.location = "../PlayCay/ActivityNight.aspx?id=1794&MID=16";       
        }else if (mid == "17"){
               window.location = "../PlayCay/NightLifeNight.aspx?id=1796&MID=17"; 
        }else if (mid == "18"){
               window.location = "../EventPhoto/LoginNight.aspx?id=1980&MID=18";                
        }                           
           
    }else{
        if (mid == "1"){     
            window.location = document.getElementById("URL").innerHTML;  
            //window.location = "../AboutNygardCay/Overview.aspx?id=1716&MID=1";
        } else if (mid == "2"){
            window.location = "../AboutNygardCay/History.aspx?id=1706&MID=2";
        } else if (mid == "3"){
            window.location = "../AboutNygardCay/MapDay.aspx?MID=3";
        } else if (mid == "5"){
            window.location = "../AboutNygardCay/AccommodationDay.aspx?FlashID=1&MID=5";
        } else if (mid == "6"){
            window.location = "../AboutNygardCay/DiningDay.aspx?FlashID=4&MID=6";
        } else if (mid == "7"){
            window.location = "../AboutNygardCay/ActivityDay.aspx?FlashID=5&MID=7";               
        }else if (mid == "8"){
              window.location = "../Video/VideoListingDay.aspx?id=1824&FlashID=1&MID=8";
        }else if (mid == "9"){
             window.location = "../News/NewsDay.aspx?id=1820&MID=9";      
        }else if (mid == "10"){
               window.location = "../BookCay/BookDetailsDay.aspx?id=1972&MID=10"; 
        }else if (mid == "11"){
               window.location = "../BookCay/BookReviewDay.aspx?id=1974&MID=11";
         }else if (mid == "12"){
               window.location = "../BookCay/BookingFormDay.aspx?id=1766&MID=12";
         }else if (mid == "13"){
               window.location = "../BookCay/EmploymentDay.aspx?MID=13";
         }else if (mid == "14"){
             window.location = "../360Videos/NygardCay.aspx?MID=14&FlashID=1";
         }else if (mid == "15"){
             window.location = "../Photo/GalleryDay.aspx?MID=15&FlashID=21"; 
         }else if (mid == "16"){
               window.location = "../PlayCay/ActivityDay.aspx?id=1794&MID=16";       
         }else if (mid == "17"){
               window.location = "../PlayCay/NightLifeDay.aspx?id=1796&MID=17";   
        }else if (mid == "18"){
               window.location = "../EventPhoto/LoginDay.aspx?id=1978&MID=18";          
        }    
    }
}


//=================================================
function OpenIntroDayNight(e) 
{
    ///<summary>Integer 1-Day 2-Night</summary>
  
    var currentTime = new Date()
    var hours = currentTime.getHours()
    
    //Night view
    if(hours > 11){  
       //Evening 6 PM central time
       if (hours >= 18){
            window.location = "../AboutNygardCay/OverviewNight.aspx?id=1716&MID=1";
       }else{
            window.location = "../AboutNygardCay/Overview.aspx?id=1716&MID=1";
       }     
    }else{
        window.location = "../AboutNygardCay/Overview.aspx?id=1716&MID=1";
    }
}

//=============================
function ShowVirtualTour()
{
   var Map = document.getElementById("MapDiv");
   if (Map.style.display == "block")
   {
        Map.style.display = "none";
        document.getElementById("MenuDiv").style.display = "block";
   }
   else
   {
        Map.style.display = "block";
        document.getElementById("MenuDiv").style.display = "none";
   }
}



//=============================
function correctPNG() {
    //alert('OK');
	for(var i=0; i<document.images.length; i++) {
		var img = document.images[i]
		var imgName = img.src.toUpperCase()
		if (imgName.substring(imgName.length-3, imgName.length) == "PNG") {
			//debugger;
			
			//img.outerHTML = "<span title='Peter Signature'  style='filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);' src='http://localhost/uploadedImages/Community/pns-signature-white-logo.png'></span>"

			var imgID = (img.id) ? "id='" + img.id + "' " : ""
			var imgClass = (img.className) ? "class='" + img.className + "' " : ""
			var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
			var imgStyle = "display:inline-block;" + img.style.cssText 
			if (img.align == "left") imgStyle = "float:left;" + imgStyle
			if (img.align == "right") imgStyle = "float:right;" + imgStyle
			if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle		
			var strNewHTML = "<span " + imgID + imgClass + imgTitle
			+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + " " 
			+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
			+ "(src='" + img.src + "');\"></span>" 
			img.outerHTML = strNewHTML
			i = i-1
		}
	}
}

//====================================
function HostMap() {
    var HostName = window.location.hostname;
    //alert(HostName);
    for (var i = 0; i < document.images.length; i++) {
        var img = document.images[i];
        if (HostName == "iknt72v.nygard.com") {
            var src = new String();
            src = img.src;
            //src.replace("http://iknt72v.nygard.com:8080", "http://ncedge.nygardcay.com" )
            
             src = "http://ncedge.nygardcay.com" + src.substring(30);
            img.src = src;
            //alert(img.src);
        }
        if (HostName.toUpperCase() == "WWW.NYGARDCAY.COM") {
            var src = new String();
            src = img.src;
            src = "http://ncedge.nygardcay.com" + src.substring(24);
            img.src = src;
            //alert(img.src);
        }
    }
}



