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 - 70 + scrolledY;
	document.getElementById("calling").style.top = newoffset + "px";
}

function CallToAction() {
	toggle=getCookie('toggle');
	if (toggle!=null && toggle!="") {
	  document.all['calling'].style.visibility = "hidden";
	  } else {
	  topm = myHeight - 70;
	  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); 
}


var contactDisplay = document.getElementById('contact-us');
contactDisplay.innerHTML = '<div id=\"contact-form\"><h5 align=\"center\">Schedule a Free Estimate</h5><form action=\"contact-mainstreamhi.php\" method=\"POST\"><input type=\"hidden\" name=\"formtest\" value=\"test\"><font color=\"#FF0000\">*</font> Name:<br><input class=\"shortform\" style=\"width: 150px\" name=\"realname\"><br><font color=\"#FF0000\">*</font> Phone:<br><input class=\"shortform\"  style=\"width: 150px\" name=\"homephone\"><br><font color=\"#FF0000\">*</font> E-mail Address:<br><input class=\"shortform\"  style=\"width: 150px\" name=\"email\"><br>Brief Job Description:<br><textarea class=\"cshortform\" style=\"width: 150px\" name=\"comment\" rows=\"4\"></textarea><br><br><input type=\"submit\" name=\"submit\" value=\"submit\" id=\"sfsub\"><br></form></div>';
  

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("CallToAction()",500);
