// Dynamic Images by Kaosweaver
// Copyright 2007, All rights reserved
var rI = { 
	init:function(o,t) {rI.obj=o;rI.rT=t;},
	addImg:function() { 
		var a=arguments;rI.imgList.push(a[0]);rI.altList.push((a[1]?a[1]:''));
		rI.linkList.push((a[2]?a[2]:''));rI.tgtList.push((a[3]?a[3]:''));},
	showImg:function() {
		if (rI.rT==0){var j=parseInt(Math.random()*rI.imgList.length);
		j=(isNaN(j))?0:j;}else{var oneDay=60*60*24*1000, d=new Date();
		jk=d.getTimezoneOffset()*60*1000;
		j=(parseInt((d.getTime()-jk)/oneDay))%rI.imgList.length;}
		d=document;	newImg=d.createElement("img");
		newImg.src=rI.imgList[j];newImg.alt=rI.altList[j];
		tO=d.getElementById(rI.obj);if (tO) {if (rI.linkList[j]!='') {
		newLink=d.createElement("a");newLink.href=rI.linkList[j];
		newLink.target=rI.tgtList[j];newLink.appendChild(newImg);
		tO.appendChild(newLink);} else {tO.appendChild(newImg);}}},
	addEvent: function(o,evt, fn) {
		if (o.addEventListener) {o.addEventListener(evt, fn, false);
		} else if (o.attachEvent) {o.attachEvent('on'+evt, fn);
		} else {o['on'+evt]=fn;}},
	imgList:[],altList:[],linkList:[],tgtList:[],obj:"",rT:0
}

// JavaScript Document
// Core DOM scripts - Copyright 2007 Kaosweaver
function $(){eS=new Array();for (i=0;i<arguments.length;i++) {el=arguments[i]; if (typeof el == 'string')
  el=document.getElementById(el);if (arguments.length==1) return el; es.push(el);} return es;}
var gO= {addEvent: function(obj,evt, fn) {if (obj.addEventListener) {obj.addEventListener(evt, fn, false);
  } else if (obj.attachEvent) {obj.attachEvent('on'+evt, fn);} else {obj['on'+evt]=fn;}},
  fTarget: function(e) {var T;if (window.event && window.event.srcElement) {
  T=window.event.srcElement;}	else if (e && e.target) {T=e.target}if (!T) return null;return T;},
  gPlace:function(e) {var xT=gO.fTarget(e);if (!xT) return;var o=new Object();if (xT.offsetWidth) {
  o.width=xT.offsetWidth;o.height=xT.offsetHeight;}else if (xT.style && xT.style.pixelWidth) {
  o.width=xT.style.pixelWidth;o.height=xT.style.pixelHeight;}if (xT.offsetParent) {o.left=xT.offsetLeft;
  o.top=xT.offsetTop;while (xT=xT.offsetParent) {o.left+=xT.offsetLeft;o.top+=xT.offsetTop;}}return o;}}
var cO={get: function(k){var v=document.cookie.match('(?:^|;)\\s*'+cO.eRE(k)+'=([^;]*)');
  return v?decodeURIComponent(v[1]):false;},eRE: function(k){return k.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1');},
  set:function createCookie(n,v,d) {if(d){var date=new Date();date.setTime(date.getTime()+(d*24*60*60*1000));
  var e="; expires="+date.toGMTString();}else var e = "";document.cookie = n+"="+v+e+"; path=/";}}  
function $_(o) {return document.createElement(o);}  

var aFF={ // Auto Form Fill Copyright 2007 Kaosweaver
	p:function(){a=arguments;for(var i=0;i<a.length;i=i+2) {aFF.list[a[i]]=a[i+1];}},obj:function(f,t){this.f=f;this.t=t;},
	i:function(){for (var t in aFF.list) {gO.addEvent($(t),"focus",aFF.f);gO.addEvent($(t),"blur",aFF.b);}},f:function(e) {
	var xT=gO.fTarget(e);if (!xT) return;if ($(xT.id).value==aFF.list[xT.id]) $(xT.id).value="";},b:function(e) {
	var xT=gO.fTarget(e);if (!xT) return;if ($(xT.id).value=="") $(xT.id).value=aFF.list[xT.id];},list:[]}

var fF={ // Form Styler, Copyright 2007 Kaosweaver
	i:function() {fet=["input","select","textarea"];for(var i=0;i<3;i++){e=document.getElementsByTagName(fet[i]);
	for(var j=0;j<e.length;j++){gO.addEvent(e[j],"focus",fF.f);gO.addEvent(e[j],"blur",fF.b);}}},f:function(e) {
	var xT=gO.fTarget(e);if (!xT) return;xT.setAttribute("xclass",xT.className);xT.className=fF.cl;},b:function(e) {
	var xT=gO.fTarget(e);if (!xT) return;xT.className=xT.getAttribute("xclass");},cl:"formFocus"}
gO.addEvent(window,"load",fF.i);

var fO= { // Form Validator, Copyright 2008 Kaosweaver
	isInteger: function(tV) {return (tV.match(/^[0-9]+$/))?true:false;},
	isIntegerRange: function(tV,a,b) {return (fO.isInteger(tV)&&tV>=a&&tV<=b)?true:false;},
	isNumber: function(tV) {return (tV.match(/^[-+]?\d+(\.\d+)?$/))?true:false;},
	isNumberRange:function(tV,a,b) {return (fO.isNumber(tV)&&tV>=a&&tV<=b)?true:false;},
	isAlphaNumeric:function(tV) {return (tV.match(/^[0-9a-zA-Z]+$/))?true:false;},
	isLength:function(tV,a,b) {return (tV.length>=a && tV.length<=b)?true:false;},
	isPhone:function(tV) {return (tV.match(/^[\(]?(\d{0,3})[\)]?[\s]?[\-]?[\.]?(\d{3})[\s]?[\-]?[\.]?(\d{4})[\s]?[x]?(\d*)$/))?true:false;},
	isSSN:function(tV) {return (tV.match(/^(\d{3})[\s]?[\-]?(\d{2})[\s]?[\-]?(\d{4})$/))?true:false;},	
	isZip:function(tV) { return (tV.match(/^\d{5}([\-]\d{4})?$/))?true:false; },	
	isURL:function(tV) {return (tV.match(/(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/))?true:false;},	
	isCompare:function(tV,tV2,m) {return (eval("'"+tV+"'"+m+"'"+tV2+"'"))?true:false},
	isSelected:function(tV) {return (tV>0)?true:false},
	isPicked:function() {
		a=arguments;rV=false;n=a[0];ff=a[1];nCnt=0;if ($(ff).type=="radio") {for (var i=0;i<$(ff).length;i++)
		if ($(ff)[i].checked==true) rV=true;} else {for (var i=1;i<a.length;i++) {if ($(a[i]).checked==true) nCnt++;
		}if (nCnt>=n) rV=true;}return rV;},
	isEmail:function(tV) {
		return (tV.match(/^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/))?true:false},
	isRequired:function(tV) {return (tV!="")?true:false;},
	isCreditCard:function(tV) {
		var c,i=n=0,s=tV,r=t="";for (i=0;i<s.length;i++){c=fO.pI(s,i);if(c>=0&&c<=9)r=c+r;}
		if (r.length>1) {for (i=0;i<r.length;i++){c=fO.pI(r,i);if(i%2!=0)c*=2;t=t+c;}
		for (i=0;i<t.length;i++){c=fO.pI(t,i);n+=c;}}
		return (n!=0&&n%10==0)?true:false},
	isDate:function() {
		a=arguments;subDate=a[0].split(a[2]);rV=true;if (subDate.length==3){nd=[];for (var i=0;i<3;i++) {
		tV=subDate[i];if (!fO.isInteger(tV)){ rV=false; break;}if (a[i*2+1]=="M"){if (tV<1 || tV>12) rV=false;
		nd[0]=tV-1;} else if (a[i*2+1]=="D") {if (tV<1 || tV>31) rV=false;nd[1]=tV;} else if (a[i*2+1]=="Y") {					
		nd[2]=tV;}}if (rV) {tDate=new Date(nd[2],nd[0],nd[1]);if (tDate.getMonth()!=nd[0]) {rV=false;}}
		} else {rV=false;}return rV;},
	pI:function(o,i) {return parseInt(o.charAt(i),10); },
	getLabel:function(fI) {
		rV=fI;lL=document.getElementsByTagName("label");for (var i=0;i<lL.length;i++) {
		if (lL[i].getAttribute('htmlfor')==fI ||lL[i].getAttribute('for')==fI)rV=lL[i].innerHTML;}return rV;}
}

var vF = {
	p:function(){for (var i=0;i<arguments.length;i++) {vF.fName[vF.fName.length]=arguments[i];}},
	init:function() {		
		for (var i=0;i<vF.fName.length;i++) {gO.addEvent($('Submit'+vF.fName[i]),"click",vF.doForm);}
		for (var i=0;i<vF.list.length;i++) {gO.addEvent($(vF.list[i].n),"blur",vF.validate);}},
	doForm:function(e) {
		tf=$(vF.fName[0]);var xT=gO.fTarget(e);tfn=(xT)?xT.id.replace("Submit",""):tf.name;		
		vF.err="";for (var i=0;i<vF.list.length;i++) {if (vF.list[i].f==tfn) {
		o=vF.list[i].v; fld=$(vF.list[i].n);r=o.split("|");for (var j=0;j<r.length;j++) {vF.valField(fld,r[j]);			
		}}}if (vF.err=="") {tf.submit();} else {alert(vF.err);}},
	validate:function(e) {
		var xT=gO.fTarget(e);
		var o,fld;vF.err="";for (var i=0;i<vF.list.length;i++) {if (vF.list[i].n==xT.id) {o=vF.list[i].v; 
		}}r=o.split("|");rV=true;for (var j=0;j<r.length;j++) {vF.valField(xT,r[j]);}},
	valField:function(f,v) {
		thisR=v.charAt(0);rM="";switch (thisR) {case 'R':rM=fO.isRequired(f.value);break;case 'N':
		rM=fO.isNumber(f.value);break;case 'O':break;case 'I':rM=fO.isInteger(f.value);break;case 'J':break;
		case 'E':rM=fO.isEmail(f.value);break;case 'A':rM=fO.isAlphaNumeric(f.value);break;case 'D':break;
		case 'P':rM=fO.isPhone(f.value);break;case 'S':rM=fO.isSSN(f.value);break;case 'Z':rM=fO.isZip(f.value);
		break;case 'L':break;case 'C':rM=fO.isCreditCard(f.value);break;case 'U':rM=fO.isURL(f.value);break;
		case 'G':break;case 'T':break;case 'X':rM=fO.isSelected(f.selectedIndex);break;}if (rM==false) {			
		$(f.id+"Error").innerHTML=fO.getLabel(f.name)+" "+vF.getMsg(thisR);
		vF.err+=fO.getLabel(f.name)+" "+vF.getMsg(thisR)+"\n";} else {$(f.id+"Error").innerHTML="";}},
	getMsg:function(v) {for (var i=0;i<vF.msg.length;i+=2) if (v==vF.msg[i]) rV=vF.msg[i+1];return rV;},
	addMsg:function(v,m) {for (var i=0;i<vF.msg.length;i+=2) if (v==vF.msg[i]) vF.msg[i+1]=m;},
	addField:function(f,n,v) {vF.list[vF.list.length]=new vF.pObj(f,n,v);},
	pObj:function(formName,fieldName,validation) {this.f=formName;this.n=fieldName;this.v=validation},
	list:[], fName:[], msg:["R"," is required","N"," must be a number","O"," needs to be a number between @@A@@ and @@b@@","I"," must be an integer","J"," need to be an integer between @@A@@ and @@B@@","E"," is not a valid email address","A"," contains invalid characters, all characters should be letters or numbers","D"," is not a valid date, the format is @@A@@","P"," is not a valid phone number","S"," is not a valid social security number","Z"," is not a valid zipcode","L"," needs to be between @@A@@ and @@B@@ characters in length","C"," is not a valid credit card number","U"," is not a valid URL","G"," a selection is required is the group of @@A@@ options","T"," the values in the @@A@@ field needs to be @@B@@ then the value in the @@C@@ field","X"," needs to have a selected value"], err:""
}

var sHL= { // Show Hide Layer DOM Script, Copyright 2007 Kaosweaver
	p:function(l,a,e,o){sHL.list.push(new sHL.obj(l,a,e,o));},
	i:function(){var x=sHL.list;
	 for (var i=0;i<x.length;i++) {gO.addEvent($(x[i].o),x[i].e,eval("sHL."+x[i].a));}},
	s:function(e){
	 var x=sHL.list;var xT=gO.fTarget(e);if (!xT) return;for (var i=0;i<x.length;i++) {if (xT.id==x[i].o) {
	 $(x[i].l).style.display="block";}}},
	h:function(e) {var x=sHL.list;var xT=gO.fTarget(e);if (!xT) return;
	 for (var i=0;i<x.length;i++) {if (xT.id==x[i].o) {$(x[i].l).style.display="none";}}},
	obj:function(l,a,e,o){this.l=l;this.a=a;this.e=e;this.o=o;},list:[]}

var ajaxRV;
function ajaxCall(target){
   try {ajaxRV=new XMLHttpRequest();} catch (e) {
      try { ajaxRV=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {
         try { ajaxRV=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {
            alert("Your browser does not support AJAX!"); return false;
         }
      }
   }
    ajaxRV.onreadystatechange=function(){
    if(ajaxRV.readyState==4) {
		if (document.getElementById(target).outerHTML) {
			document.getElementById(target).innerHTML="";
			hold=document.getElementById(target).outerHTML
			hold=hold.substring(0,hold.indexOf(">")+1)+ajaxRV.responseText+"</select>";
			document.getElementById(target).outerHTML=hold;
		} else {
	    	document.getElementById(target).innerHTML=ajaxRV.responseText;
		}
	}

  }
}
function doAjax(obj,url,target) {
  ajaxCall(target);
  oVal=url+obj.options[obj.selectedIndex].value;
  ajaxRV.open("GET",oVal,true);
  ajaxRV.send(null);
 
}
function clearDD() {
	a=arguments;
	for(var i=0;i<a.length;i++) {
		$(a[i]).options.length=0;
		$(a[i]).options[0]=new Option("Please select...","-1");
	}
}
var eI={
	p:function(t,s,a,c,l,p) {eI.iList.push(new eI.iObj(t,s,a,c,l,p));},
	a:function(o,a,t,p,c) {eI.aList.push(new eI.aObj(o,a,t,p,c));},
	i:function() {
		for (var i=0;i<eI.aList.length;i++) {
			eval("eI."+eI.aList[i].a+"("+i+",'"+eI.aList[i].p+"',"+eI.aList[i].t+",'"+eI.aList[i].c+"')");
		}
	},
	dC:function(i,c) {
		if ($(i)) $(i).innerHTML=eI.iList[(iL[c])].c;
	},
	set:function(j,c) {
		n=eI.sI(iL[j]);
		tO=$(eI.iList[(iL[j])].t)
		tO.appendChild(n);
		if ($(c)) $(c).innerHTML=eI.iList[(iL[j])].c;
	},
	replace:function(j,c) {
		/*n=eI.sI(iL[j]);
		tO=$(eI.iList[(iL[j])].t)
		oC=$(n.id)
		oC=tO.replaceChild(n,oC); */
		if (eI.iList[(iL[j])].l!="")$(eI.iList[(iL[j])].t+"_eI").href=eI.iList[(iL[j])].l
//crossfade($(eI.iList[(iL[j])].t+"_img"), eI.iList[(iL[j])].s, '2', eI.iList[(iL[j])].a)
iE.cFM($(eI.iList[(iL[j])].t+"_img"), eI.iList[(iL[j])].s, 2, eI.iList[(iL[j])].a)

		if ($(c)) $(c).innerHTML=eI.iList[(iL[j])].c;	
	},
	r:function(i,p,t,c) {
		iL=eI.gL(eI.aList[i].o);
		var j=parseInt(Math.random()*iL.length);
		j=isNaN(j)?0:j;
		eI.set(j,c);
	},
	d:function(i,p,t,c) {
		iL=eI.gL(eI.aList[i].o);
		var oneDay=60*60*24*1000, d=new Date();
		jk=d.getTimezoneOffset()*60*1000;
		j=(parseInt((d.getTime()-jk)/oneDay))%iL.length;
		eI.set(j,c);	
	},
	w:function(i,p,t,c) {
		iL=eI.gL(eI.aList[i].o);
		dt=new Date();j=dt.getDay()
		eI.set(j,c);		
	},
	t:function(i,p,t,c) {
		iL=eI.gL(eI.aList[i].o);
		dt=new Date();j=dt.getDate()
		eI.set(j,c);	
	},
	m:function(i,p,t,c) {
		iL=eI.gL(eI.aList[i].o);
		dt=new Date();j=dt.getMonth()
		eI.set(j,c);	
	},
	c:function(i,p,t,c) {
		x=eI.aList[i].o;
		iL=eI.gL(x);
		j=0;
		if ((j=cO.get(x))===false) j=-1;
		j++;
		if (j==iL.length) j=0;		
		cO.set(x,j,30);
		eI.set(j,c);	
	},
	rs:function(i,p,t,c) {
		iL=eI.gL(eI.aList[i].o);
		var j=parseInt(Math.random()*iL.length);
		j=isNaN(j)?0:j;
		eI.set(j,c);
		setTimeout("eI.rsR("+i+",'"+p+"',"+t+",'"+c+"')",eI.aList[i].t);
	},
	ss:function(i,p,t,c) {	
		iL=eI.gL(eI.aList[i].o);
		eI.set(0,c);
		ni=new Image();
		ni.src=eI.iList[(iL[1])].s;
		setTimeout("eI.ssR("+i+",'"+p+"',"+t+",0,'"+c+"')",eI.aList[i].t);
	},
	ssR:function(i,p,t,j,c) {
		iL=eI.gL(eI.aList[i].o);
		j++;
		if (j==iL.length) j=0;		
		eI.replace(j,c);
		if (j+1<iL.length) {
			ni=new Image();
			ni.src=eI.iList[(iL[j+1])].s;
		}
		setTimeout("eI.ssR("+i+",'"+p+"',"+t+","+j+",'"+c+"')",eI.aList[i].t);
	},
	rsR:function(i,p,t,c) {
		iL=eI.gL(eI.aList[i].o);
		var j=parseInt(Math.random()*iL.length);
		j=isNaN(j)?0:j;		
		eI.replace(j,c);
		setTimeout("eI.rsR("+i+",'"+p+"',"+t+",'"+c+"')",eI.aList[i].t);		
	},
	gL:function(i) {
		gl=[];
		for (var j=0;j<eI.iList.length;j++)
			if (eI.iList[j].t==i) gl.push(j);
		return gl;
	},
	sI:function(j) {
		d=document;	x=eI.iList[j]
		n=d.createElement("img");
		n.src=x.s;
		n.alt=x.a;
		n.id=x.t+"_img";
		n.setAttribute("title",n.alt);
		if (x.l!='') {
			l=d.createElement("a");
			l.id=x.t+"_eI"
			l.href=x.l;
			l.target=x.p;
			l.appendChild(n);
			return l;
		} else {
			n.id=x.t+"_eI"
			return n;
		}
	},
	aObj:function(o,a,t,p,c) {this.o=o;this.a=a;this.t=t;this.p=p;this.c=c},
	iObj:function(t,s,a,c,l,p) {this.t=t;this.s=s;this.a=unescape(a);this.c=unescape(c);this.l=unescape(l);this.p=p},
	iList:[],aList:[]
}
function do_email_signup(){
	var email = document.getElementById('email_signup').value;
	if(email)
	{
		if(isValidEmail(email))
		{
			checkEmail(this,'/newsletter/checkemail','email_signup',email);
			 
			 //ajaxCall(email);
		}
		else
		{
				alert("Your email address is not formatted correctly, please check your email address and try again.");
		}
	}
	else
	{
		alert("Please enter your email address.");
	}
		
}
/*function doAjax(obj,url,target) {
  ajaxCall(target);
  alert(obj.options[obj.selectedIndex].value)
  oVal=url+obj.options[obj.selectedIndex].value;
  ajaxRV.open("GET",oVal,true);
  ajaxRV.send(null);
  function ajaxCall(target){
   try {ajaxRV=new XMLHttpRequest();} catch (e) {
      try { ajaxRV=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {
         try { ajaxRV=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {
            alert("Your browser does not support AJAX!"); return false;
         }
      }
   }
    ajaxRV.onreadystatechange=function(){
    if(ajaxRV.readyState==4) {
		if (document.getElementById(target).outerHTML) {
			document.getElementById(target).innerHTML="";
			hold=document.getElementById(target).outerHTML
			hold=hold.substring(0,hold.indexOf(">")+1)+ajaxRV.responseText+"</select>";
			document.getElementById(target).outerHTML=hold;
		} else {
	    	document.getElementById(target).innerHTML=ajaxRV.responseText;
		}
	}

  }
}
 
}*/
function ajaxCall_new(target){
   try {ajaxRV=new XMLHttpRequest();} catch (e) {
      try { ajaxRV=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {
         try { ajaxRV=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {
            alert("Your browser does not support AJAX!"); return false;
         }
      }
   }
    ajaxRV.onreadystatechange=function(){
    if(ajaxRV.readyState==4) {
		if (document.getElementById(target).outerHTML) {
		
		} else {
	    	var email = document.getElementById(target).value;
			var values = ajaxRV.responseText;
			if(!values.indexOf(email)) 
				alert('Your email address already exists in our system, please visit the contact us page to change your subscription.');
			else  document.ccoptin.submit();
			//document.getElementById(target).innerHTML=ajaxRV.responseText;
		}
	}

  }
}
function checkEmail(obj,url,target,value) {
   ajaxCall_new(target);
 
  oVal=url;
  ajaxRV.open("GET",oVal,true);
  ajaxRV.send(null);
}
function isValidEmail(str) {
	return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}

