function readCookie(name)

{

  var cookieValue = "";

  var search = name + "=";

  if(document.cookie.length > 0)

  { 

    offset = document.cookie.indexOf(search);

    if (offset != -1)

    { 

      offset += search.length;

      end = document.cookie.indexOf(";", offset);

      if (end == -1) end = document.cookie.length;

      cookieValue = unescape(document.cookie.substring(offset, end))

    }

  }

  return cookieValue;

}

function writeCookie(name, value, hours, path)

{

  var expire = "";

  if(hours != null)

  {

    expire = new Date((new Date()).getTime() + hours * 3600000);

    expire = "; expires=" + expire.toGMTString();

  }
  if(path!=null)
  {
	   path = "; path=" + path;
  }

  document.cookie = name + "=" + escape(value) + expire + path;

}
function showpop(id)
{
	//var onsurvey=readCookie("onsurvey");
	//var already=readCookie("already");
	var popup=readCookie("popup_begin");	
	writeCookie("back",id,3,"/");
	//Neu co already, onsurvey thi khong hien ra
	
		if(popup==null || popup=="")
		{
			if(id!="46")
			{
				writeCookie("popup_begin","1",1,"/");	
				//writeCookie("popup1234","1",1,"/");	Khong set cai nay de cho 10% hien ra
				var agreewin=dhtmlmodal.open("agreebox", "iframe", "/SurveyAttention_Begin.aspx", "Tell Us About Your Dog's Situation", "width=654px,height=375px,center=1,resize=0,scrolling=0", "recal");
			
				agreewin.onclose=function(){ //Define custom code to run when window is closed
				}	
			}
		}				
	
}

function showpop_close(id)
{
	//var onsurvey=readCookie("onsurvey");
	//var already=readCookie("already");
	var popup=readCookie("popup1234");
	//Neu co already, onsurvey thi khong hien ra
	writeCookie("back",id,3,"/");

		if(popup==null || popup=="")
		{					
			writeCookie("popup1234","1",1,"/");		
			//writeCookie("popup_begin","1",1,"/");
			var agreewin1=dhtmlmodal.open("agreebox1", "iframe", "/surveyattention_end.html", "10% Discount Offer For New Customers", "width=654px,height=375px,center=1,resize=0,scrolling=0", "recal");
		
			agreewin1.onclose=function(){ //Define custom code to run when window is closed
			}	
		}				
	
}

function showpop_cart()
{
	//var already=readCookie("already");
	var popup=readCookie("popup1234");
	//Neu co already, onsurvey thi khong hien ra
		
		if(popup==null || popup=="")
		{		
				
			writeCookie("popup1234","1",1,"/");		
			//writeCookie("popup_begin","1",1,"/");
			var agreewin2=dhtmlmodal.open("agreebox2", "iframe", "/surveyattention_end.html", "10% Discount Offer For New Customers", "width=654px,height=375px,center=1,resize=0,scrolling=0", "recal");
		
			agreewin2.onclose=function(){ //Define custom code to run when window is closed
			}	
		}				
	
}


function showpop_close_newv2(id)
{
	var popup=readCookie("popup1234");
	var already=readCookie("already");
	var o10=readCookie("o10");
	
	writeCookie("back",id,3,"/");
	
	//Neu co cac popup tren thi khong hien nua
	if(already!="" || o10!="")
	{}else{
		if(popup==null || popup=="")
		{					
			writeCookie("popup1234","1",2,"/");		
			var agreewin1=dhtmlmodal.open("agreebox1", "div", "popupend", "10% Discount Offer For New Customers", "width=654px,height=355px,center=1,resize=0,scrolling=0","recal");
		
			agreewin1.onclose=function(){ //Define custom code to run when window is closed
			}	
		}			
	}
}

function showpop_beginv2(id)
{
	var popup=readCookie("popup_begin");	
	var onsurvey=readCookie("onsurvey");
	var already=readCookie("already_survey");
	writeCookie("back",id,3,"/");
	
	if(onsurvey!="" || already!="")
	{}else{
		if(popup==null || popup=="")
		{
			if(id!="46")
			{
				writeCookie("popup_begin","1",1,"/");	var agreewin=dhtmlmodal.open("agreebox", "div", "popupbegin", "Tell Us About Your Dog's Situation To Receive Recommended Products", "width=654px,height=355px,center=1,resize=0,scrolling=0", "recal");
			
				agreewin.onclose=function(){ //Define custom code to run when window is closed
				}	
			}
		}				
	}
}