/***************************/
//@Author: Adrian "yEnS" Mato Gondelle
//@website: www.yensdesign.com
//@email: yensamg@gmail.com
//@license: Feel free to use it, but keep this credits please!					
/***************************/

//SETTING UP OUR POPUP
//0 means disabled; 1 means enabled;
var popupStatus = 0;

//loading popup with jQuery magic!
function loadPopup(){
	//loads popup only if it is disabled
	if(popupStatus==0){
		$("#backgroundPopup").css({
			"opacity": "0.7"
		});
		$("#backgroundPopup").fadeIn("slow");
		$("#popupContact").fadeIn("slow");
		popupStatus = 1;
	}
}

//disabling popup with jQuery magic!
function disablePopup(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("slow");
		$("#popupContact").fadeOut("slow");
		popupStatus = 0;
	}
}

//centering popup
function centerPopup(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popupContact").height();
	var popupWidth = $("#popupContact").width();
	//centering
	$("#popupContact").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	
	$("#backgroundPopup").css({
		"height": windowHeight
	});
	
}


//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){
	
	//LOADING POPUP
	//Click the button event!
	$("#button a").click(function(){
		//centering with css
		centerPopup();
		//load popup
		loadPopup();
		return false;	
	});
				
	//CLOSING POPUP
	//Click the x event!
	$("#popupContactClose").click(function(){disablePopup();});
	//Click out event!
	$("#backgroundPopup").click(function(){disablePopup();});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus==1){disablePopup();}
	});

});

	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 emptyfield(obj)
{
	if(obj.value==''){obj.value='Enter Your Email Address'};
}

function focusfield(obj)
{
	if(obj.value=='Enter Your Email Address'){obj.value=''};
}

$("docuent").ready(function() {
   if (readCookie("mp_nl_like") != "shown") {
       var divTag = document.createElement("div");
	   var currenturl=document.URL ;
	   var gethwe=" ";
//alert(currenturl);
if(currenturl=="http://www.motherpedia.com.au/article/5-ways-to-reduce-fluid-retention-during-pregnancy" || currenturl=="http://www.motherpedia.com.au/article/5-ways-to-reduce-fluid-retention-during-pregnancy/" )
	{
		
		divTag.id = "divDyn";
       divTag.className = "classA";
       divTag.innerHTML = "<div><style type='text/css'>#mc_embed_signup{position:absolute; top:0; left:0; width:100%; height:100%; background-color:rgba(0,0,0,.8);z-index:10000; }#mc_embed_signup form{position:absolute; right:50%; width:475px; margin: 100px -237px 0 0; font:normal 100% Helvetica,Arial,sans-serif; font-size:14px; border-radius:4px; border:none; padding:20px; background-color:#fff; color:#000; text-align:left;}#mc_embed_signup a.mc_embed_close{background:transparent url(http://downloads.mailchimp.com/img/closebox.png) no-repeat; display:block; height:30px; width:30px; text-indent:-999em; position:absolute; top:-12px; right:-15px; }#subscribe-field {background-image: url(/images/keep-up-to-date-background.png');height: 25px;width: 300px;}</style><div id='mc_embed_signup'><form action='//totstyle.us10.list-manage.com/subscribe/post?u=d6fcf0f075627f20c9946493f&amp;id=ad54268611' method='post' id='mc-embedded-subscribe-form' name='mc-embedded-subscribe-form' class='secondhwe'><table border='0' cellpadding='0' cellspacing='0' width='475'><tr><td><img style='width:100%; height:250px;' src='/images/headings/moms-pregancys.png' /></td></tr><tr><td width='475' height='170' style='background:url(/images/stay-updated.png) no-repeat scroll 0 0 / 100% 115%; height: 161px;'><table border='0' cellpadding='0' cellspacing='0' width='440' align='center'><tr><td height='93'></td></tr><tr><td height='35'><div style='color: #ffffff; font-size: 12px; font-family: arial;'>Subscribe to get the latest news, tips, free samples and giveaways on Motherpedia sent straight to your inbox.</div></td></tr><tr><td height='50'><table border='0' cellpadding='0' cellspacing='0' width='437'><tr><td><div id='subscribe-field-2' style='height:25px; width:170px;'><input style='width:150px;' id='mce-EMAIL-2' type='email' onfocus='focusfield(this);' onblur='emptyfield(this);' value='' name='EMAIL' placeholder='Enter email address' required/></div></td></tr><tr><td><div id='subscribe-field-2' style='height:25px; width:170px;'><input style='width:150px;' id='mce-EMAIL-2' type='text' onfocus='focusfield(this);' value='' name='FNAME' placeholder='Enter your name' required/></div></td></tr><tr><td><input id='mc-embedded-subscribe' type='image' border='0' name='subscribe' value='Subscribe' src='/images/buttons/btn-subscribe-home.png'></td></tr></table></td></tr></table></td></tr></table><a id='#mc_embed_close' class='mc_embed_close' onclick='$(\"#mc_embed_signup\").hide(); return false;' href='#'>Close</a>	<div id='mce-responses' class='clear'><div class='response' id='mce-error-response' style='display:none'></div><div class='response' id='mce-success-response' style='display:none'></div></form></div>";
	}
	else
	{
		divTag.id = "divDyn";
       divTag.className = "classA";
       divTag.innerHTML = "<div><style type='text/css'>#mc_embed_signup{position:absolute; top:0; left:0; width:100%; height:100%; background-color:rgba(0,0,0,.8);z-index:10000; }#mc_embed_signup form{position:absolute; right:50%; width:475px; margin: 100px -237px 0 0; font:normal 100% Helvetica,Arial,sans-serif; font-size:14px; border-radius:4px; border:none; padding:20px; background-color:#fff; color:#000; text-align:left;}#mc_embed_signup a.mc_embed_close{background:transparent url(http://downloads.mailchimp.com/img/closebox.png) no-repeat; display:block; height:30px; width:30px; text-indent:-999em; position:absolute; top:-12px; right:-15px; }#subscribe-field {background-image: url(/images/keep-up-to-date-background.png');height: 25px;width: 300px;}</style><div id='mc_embed_signup'><form action='//totstyle.us10.list-manage.com/subscribe/post?u=d6fcf0f075627f20c9946493f&amp;id=ad54268611' method='post' id='mc-embedded-subscribe-form' name='mc-embedded-subscribe-form' class='firsthwe' style='display:block;'><table border='0' cellpadding='0' cellspacing='0' width='475'><tr><td><img src='/images/main-image-home-page.png' /></td></tr><tr><td width='475' height='170' style='background:url(/images/stay-updated.png) no-repeat;'><table border='0' cellpadding='0' cellspacing='0' width='440' align='center'><tr><td height='75'></td></tr><tr><td height='35'><div style='color: #ffffff; font-size: 12px; font-family: arial;'>Subscribe to get the latest news, tips, free samples and giveaways on Motherpedia sent straight to your inbox.</div></td></tr><tr><td height='50'><table border='0' cellpadding='0' cellspacing='0' width='437'><tr><td><div id='subscribe-field-2' style='height:25px; width:170px;'><input style='width:150px;' id='mce-EMAIL-2' type='email' onfocus='focusfield(this);' onblur='emptyfield(this);' value='' name='EMAIL' placeholder='Enter email address' required/></div></td><td><div id='subscribe-field-2' style='height:25px; width:170px;'><input style='width:150px;' id='mce-EMAIL-2' type='text' onfocus='focusfield(this);' value='' name='FNAME' placeholder='Enter your name' required/></div></td><td><input id='mc-embedded-subscribe' type='image' border='0' name='subscribe' value='Subscribe' src='/images/buttons/btn-subscribe-home.png'></td></tr></table></td></tr></table></td></tr></table><a id='#mc_embed_close' class='mc_embed_close' onclick='$(\"#mc_embed_signup\").hide(); return false;' href='#'>Close</a>	<div id='mce-responses' class='clear'><div class='response' id='mce-error-response' style='display:none'></div><div class='response' id='mce-success-response' style='display:none'></div></form><form action='//totstyle.us10.list-manage.com/subscribe/post?u=d6fcf0f075627f20c9946493f&amp;id=ad54268611' method='post' id='mc-embedded-subscribe-form' name='mc-embedded-subscribe-form' class='secondhwe' style='display:none;'><table border='0' cellpadding='0' cellspacing='0' width='475'><tr><td><img style='width:100%; height:250px;' src='/images/headings/moms-pregancys.png' /></td></tr><tr><td width='475' height='170' style='background:url(/images/stay-updated.png) no-repeat;'><table border='0' cellpadding='0' cellspacing='0' width='440' align='center'><tr><td height='75'></td></tr><tr><td height='35'><div style='color: #ffffff; font-size: 12px; font-family: arial;'>Subscribe to get the latest news, tips, free samples and giveaways on Motherpedia sent straight to your inbox.</div></td></tr><tr><td height='50'><table border='0' cellpadding='0' cellspacing='0' width='437'><tr><td><div id='subscribe-field-2' style='height:25px; width:170px;'><input style='width:150px;' id='mce-EMAIL-2' type='email' onfocus='focusfield(this);' onblur='emptyfield(this);' value='' name='EMAIL' placeholder='Enter email address' required/></div></td><td><div id='subscribe-field-2' style='height:25px; width:170px;'><input style='width:150px;' id='mce-EMAIL-2' type='text' onfocus='focusfield(this);' value='' name='FNAME' placeholder='Enter your name' required/></div></td><td><input id='mc-embedded-subscribe' type='image' border='0' name='subscribe' value='Subscribe' src='/images/buttons/btn-subscribe-home.png'></td></tr></table></td></tr></table></td></tr></table><a id='#mc_embed_close' class='mc_embed_close' onclick='$(\"#mc_embed_signup\").hide(); return false;' href='#'>Close</a>	<div id='mce-responses' class='clear'><div class='response' id='mce-error-response' style='display:none'></div><div class='response' id='mce-success-response' style='display:none'></div></form></div>";
	
	}
       
       setTimeout(function() {
       	document.body.appendChild(divTag);
      	 createCookie("mp_nl_like", "shown", 7);
       }, 5000);
   }
   else {/*eraseCookie("mp_nl_like");*/}
});