function getCookie(c_name) {
	if (document.cookie.length>0) {
	  c_start=document.cookie.indexOf(c_name + "=");
	  if (c_start!=-1) { 
		c_start=c_start + c_name.length+1; 
		c_end=document.cookie.indexOf(";",c_start);
		if (c_end==-1) c_end=document.cookie.length;
		return unescape(document.cookie.substring(c_start,c_end));
	  } 
    }
	return "";
}

function setCookie(c_name,value,expiredays) {
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" + escape(value) + ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function myPopupRelocate() {
	var newoffset, scrolledY;
	if( self.pageYOffset ) {
	  scrolledY = self.pageYOffset;
	} else if( document.documentElement && document.documentElement.scrollTop ) {
	  scrolledY = document.documentElement.scrollTop;
	} else if( document.body ) {
	  scrolledY = document.body.scrollTop;
	}
	newoffset = myHeight - 75 + scrolledY;
	document.getElementById("calling").style.top = newoffset + "px";
	newoffsethelp = 0 + scrolledY;
	document.getElementById("help").style.top = newoffsethelp + "px";
}

function CallToAction() {
	toggle=getCookie('toggle');
	if (toggle!=null && toggle!="") {
	  document.all['calling'].style.visibility = "hidden";
	  } else {
	  topm = myHeight - 75;
	  document.getElementById("calling").style.top = topm + "px";
	  document.all['calling'].style.visibility = "visible";
	  document.body.onscroll = myPopupRelocate;
	  window.onscroll = myPopupRelocate;
	}
}

function hideObject() {
  document.all['calling'].style.visibility = "hidden";
  toggle = 'closed';
  setCookie('toggle',toggle,1); 
}

function CallForHelp() {
	document.body.onscroll = myPopupRelocate;
	window.onscroll = myPopupRelocate;
  }
  
function initiatepopup(){
	document.getElementById("help-menu-box").style.top =  document.getElementById("help").style.top;
	document.all['help-menu-box'].style.visibility = "visible";
	document.all['help'].style.visibility = "hidden";
  }

function closehelp(){
	document.all['help-menu-box'].style.visibility = "hidden";
	document.all['help'].style.visibility = "visible";
  }
  
function helpFunction(){
	var ajaxRequest;
	try{ajaxRequest = new XMLHttpRequest();
	} catch (e){try{ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {try{ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			var ajaxDisplay = document.getElementById('help-menu-box');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
	}
	ajaxRequest.open("GET", "http://www.nlslimo.com/call-to-action.php", true);
	ajaxRequest.send(null); 
}

var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
	
	
  setTimeout("helpFunction()",1);
  setTimeout("CallForHelp()",100);
  setTimeout("CallToAction()",500);