var cookie_obj=null;
var email_obj=null;

function init(){
	var isNew = getCookie('eaddr');
	if(isNew != 'captured'){
		MM_effectAppearFade('mailReg', 500, 0, 100, false);
	}
}

function dismiss()
{
	setCookie('eaddr', 'captured', 365,'seeanz.com');
	MM_effectAppearFade('mailReg', 500, 100, 0, false);
}

function captureEmailComplete()
{
	setCookie('eaddr', 'captured', 365,'seeanz.com');
	MM_effectAppearFade('mailReg', 500, 100, 0, false);
}

function MM_effectAppearFade(targetElement, duration, from, to, toggle)
{
	Spry.Effect.DoFade(targetElement, {duration: duration, from: from, to: to, toggle: toggle});
}



function setCookie(k, v, xp, d){
  var e=(xp?new Date(new Date().getTime()+(3600000*24*xp)):null);
  document.cookie=k+'='+v+((e)?'; expires='+e.toGMTString():'')+'; path=/'+((d)?'; domain='+d:'');
  if(cookie_obj)cookie_obj[k]=v;
}

function getCookie(n){
  if(!document.cookie)return null;
  if(!cookie_obj){
    cookie_obj=new Object();
    var cs=document.cookie.split(/; ?/);
    for(var i=0;i<cs.length;i++){
      var c=cs[i].indexOf('=');
      cookie_obj[cs[i].substr(0,c)]=unescape(cs[i].substr(c+1));
    }
  }
  return cookie_obj[n];
}

function MM_validateForm() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
    } if (errors) alert('The following error(s) occurred:\n'+errors);
    if (!errors) {
	dismiss();
	}
	else  {
	document.MM_returnValue = (errors == '');
	}
} }

