function newWindow(url, name, w, h, scroll, resizable, menubar) {
  var l = (screen.availWidth && screen.availWidth > w) ? (Math.floor((screen.availWidth - w) / 2)) : 0;
  var t = (screen.availHeight && screen.availHeight > h) ? (Math.floor((screen.availHeight - h) / 2)) : 0;
  var mb = menubar ? menubar : 0;
  popUp = window.open(url, name,'width='+w+',height='+h+',top='+t+',left='+l+',toolbar=0,directories=0,menubar='+mb+',status=0,resizable='+resizable+',location=0,scrollbars='+scroll+',copyhistory=0');
  popUp.focus();
}

function toggleBtn(el, btnid) {
 	var btn = document.getElementById(btnid);  
 	if(el.checked) {
	   btn.className = 'btn';
	   btn.onclick = retValT;
	} else {
	  btn.className = 'btn-disabled';
	  btn.onclick = retValF;
	}
}

function retValF() {
	alert('Please read and agree to our terms and conditions!');
	return false;
}

function retValT() { 
	var f = document.getElementById('billinginfoform') || document.getElementById('optinform');
	if(null !== f) {
        f.submit();
    }
    this.className = 'btn-disabled'; 
    this.onclick = function(){return false;};                          
	return false;
}

function setCookie(name,value,days) {
	 var expires;
	 if (days) {
	  	var date = new Date();
	  	date.setTime(date.getTime()+(days*24*60*60*1000));
	  	expires = "; expires="+date.toGMTString();
	 }
	 else 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;
} 

String.prototype.ucFirst = function () {
   return this.substr(0,1).toUpperCase() + this.substr(1,this.length);
};