﻿// JScript File
var HolidyreceiveReq = getXmlHttpRequestObject();
var holidayhtmltext;
var exp = new Date();
var expDays = 1; 
 exp.setTime(exp.getTime() + (1*24*60*60*1000));
function getXmlHttpRequestObject() 
{
	if (window.XMLHttpRequest) {
			return new XMLHttpRequest(); //Not IE
		} else if(window.ActiveXObject) {
			return new ActiveXObject("Microsoft.XMLHTTP"); //IE
		} else {
			//Display your error message here. 
			//and inform the user they might want to upgrade
			//their browser.
			alert("Your browser doesn't support the XmlHttpRequest object.  Better upgrade to Firefox.");
		}
}
			
function handlepopup() {
 var hh=HolidayGetCookie('holidayexpdate');
 
	   if(hh==null)
	    {
	if (HolidyreceiveReq.readyState == 4) {
	if( HolidyreceiveReq.status== 200)
	{
	            try{
	            
	         holidayhtmltext= HolidyreceiveReq.responseText;
	            //alert(holidayhtmltext);
	            if(holidayhtmltext.length>0)
	            {
                    document.getElementById('holidaydiv').innerHTML = holidayhtmltext;
				   //document.write(holidayhtmltext);
				}
				}catch(Ex)
				{
				}
		}
		}
		}
}
			
						
function Holidy_close()
{
	
    var popup=document.getElementById('holidaydiv').style.display = "none";
}
			
function Holidy_today_Close()
{
    var dd=exp.setTime(exp.getTime() + (1*24*60*60*1000));
    HolidaySetCookie('holidayexpdate','holidayexpire')
     var popup=document.getElementById('holidaydiv').style.display = "none";
}
  
function getHolidayPopupLayer()
{
   
	    var hh=HolidayGetCookie('holidayexpdate');
		
		
	   if(hh==null)
	    {
	         var url='http://dartp.manualww.com/mpa/giftbox/Holiday.html';
			// var url="http://localhost/Holiday/Holiday.html";
	         HolidyreceiveReq.onreadystatechange=function(){
                   Holidyloaddata();
            }
	        HolidyreceiveReq.open("GET", url, true);
	        HolidyreceiveReq.send(null)
	  }
	}		
					
function Holidyloaddata() 
{
	if (HolidyreceiveReq.readyState == 4 || HolidyreceiveReq.readyState == 0)
	 {
	     
	    var hh=HolidayGetCookie('holidayexpdate');
	   if(hh==null)
	    {
	        holidayhtmltext=HolidyreceiveReq
	     // var ni = document.getElementById('form1');
          var newdiv = document.createElement('div');
          newdiv.setAttribute('id','holidaydiv');
          newdiv.setAttribute('style','position:absolute;z-index:1; left:200px; top:10px');
          document.body.appendChild(newdiv);
              
	        handlepopup();
		
		 }
		}			
}

	// number of days the cookie should last

//var page = receiveReq.open("GET", 'HTMLPage.htm', true);		
function HolidayGetCookie (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 HolidaySetCookie (name, value) {
  
 var date = new Date();
 date.setTime(date.getTime()+(1*24*60*60*1000));
  var expires = date.toGMTString();
  
  document.cookie = name + "=" + escape (value) +
    ((expires == null) ? "" : ("; expires=" +expires));
}
