function showDiv(id){
    if( document.getElementById(id).style.display == "block" ) document.getElementById(id).style.display = "none";
    else document.getElementById(id).style.display = "block";
}

function swapNews(show, hide){
    document.getElementById(show).style.display = "block";
    document.getElementById(hide).style.display = "none";
}

function showTabs(tab){
    switch( tab ){
        case "description":
            document.getElementById("features").style.display = "none";
            document.getElementById("specifications").style.display = "none";
            document.getElementById("features_a").className = "";
            document.getElementById("specifications_a").className = "";
            break;
        case "features":
            document.getElementById("description").style.display = "none";
            document.getElementById("specifications").style.display = "none";
            document.getElementById("description_a").className = "";
            document.getElementById("specifications_a").className = "";
            break;
        case "specifications":
            document.getElementById("description").style.display = "none";
            document.getElementById("features").style.display = "none";
            document.getElementById("description_a").className = "";
            document.getElementById("features_a").className = "";
            break;
    }
    document.getElementById(tab + "_a").className = "active";
    document.getElementById(tab).style.display = "block";
}

function checkSignupForm() {
	var firstname = document.getElementById("txtFirstname").value;
	var lastname = document.getElementById("txtLastname").value;
	var address = "";/*document.getElementById("txtAddress").value;*/
	var city = document.getElementById("txtCity").value;
	var county = document.getElementById("lstCounty").value;
	var postcode = document.getElementById("txtPostcode").value;
	var email = document.getElementById("txtEmail").value;
	var emailconfirm = document.getElementById("txtEmailConfirm").value;
	var mobilenumber = document.getElementById("txtMobile").value;
	var dobD = document.getElementById("ddb_day").value;
	var dobM = document.getElementById("ddb_month").value;
	var dobY = document.getElementById("ddb_year").value;
	
	if ( firstname!="" && lastname!="" && city!="" && county!="" && postcode!="" && email!="" && emailconfirm!="" && dobD!="99" && dobM!="99" && dobY!="99" ) {
		if ( email == emailconfirm ) {
			var mail_filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
			if( mail_filter.test(email) ) {
				return true;
			} else {
				alert("Invalid email address");
				return false;
			}
		}
		else {
			alert("The email addresses do not match.");
			return false;
		}
	} else {
		alert("Please fill in all the required fields before submitting your details.");
		return false;
	}
}

function treatContent(type, id, boxid){	// type = [-pdf] [-print]
	var str = document.getElementById(id).innerHTML;
	
	switch(type) {
		case "view":
			var buttons = new Array();
			var bl = document.getElementsByName("buttons").length;
			newwin=window.open('','viewwin','left=100,top=100,width=800,height=600');
			newwin.document.write('<html>\n<head>\n');
			newwin.document.write('<link rel="stylesheet" href="styles.css" type="text/css"/>\n');
			newwin.document.write('<style>body { background-color:#fff;margin:15px; }</style>');
			newwin.document.write('<title>View Page</title>\n');
			newwin.document.write('</head>\n');
			newwin.document.write('<body>\n');
			newwin.document.write(str);
			newwin.document.write('</body>\n');
			newwin.document.write('</html>\n'); 
			newwin.document.getElementById('evBtns').style.display="none"; 
			break;
		case "print":
			var buttons = new Array();
			var bl = document.getElementsByName("buttons").length;
			newwin=window.open('','printwin','left=100,top=100,width=800,height=600');
			newwin.document.write('<html>\n<head>\n');
			newwin.document.write('<link rel="stylesheet" href="styles.css" type="text/css"/>\n');
			newwin.document.write('<style>body { background-color:#fff; }</style>');
			newwin.document.write('<title>Print Page</title>\n');
			newwin.document.write('<script>\n');
			newwin.document.write('function chkstate(){\n');
			newwin.document.write('if(document.readyState=="complete"){\n');
			newwin.document.write('window.close()\n');
			newwin.document.write('}\n');
			newwin.document.write('else{\n');
			newwin.document.write('setTimeout("chkstate()",2000)\n');
			newwin.document.write('}\n');
			newwin.document.write('}\n');
			newwin.document.write('function print_win(){\n');
			newwin.document.write('window.print();\n');
			newwin.document.write('chkstate();\n');
			newwin.document.write('}\n');
			newwin.document.write('<\/script>\n');
			newwin.document.write('<link rel="stylesheet" href="styles.css" type="text/css"/>');
			newwin.document.write('<style>body{background-color:#FFF;}</style>');
			newwin.document.write('</head>\n');
			newwin.document.write('<body onload="print_win()">\n');
			newwin.document.write(str);
			newwin.document.write('</body>\n');			
			newwin.document.write('</html>\n');
			if (newwin.document.getElementById('evBtns'))
				newwin.document.getElementById('evBtns').style.display='none';
			newwin.document.close();
			break;
		case "pdf":
			var inner = document.getElementById(id).innerHTML;
			//ajax("ajax/createPdf.php", "content="+inner);
			newwin=window.open('','pdfwin','left=100,top=100,width=800,height=600');
			newwin.document.location.href="ajax/createPdf.php?bi="+boxid;
			newwin.document.close();
			//newwin.window.close();
			break;
	}
}
var iTimerID="";
function startScrollerList() {
	iTimerID = window.setInterval("moveScrollerList()", 100);
}
function stopScrollerList() {
	iTimerID = window.clearInterval(iTimerID);
}
function moveScrollerList() {
	if ( - parseInt(document.getElementById("scrollerListInside").offsetHeight) < parseInt(document.getElementById("scrollerListInside").style.top) ) {
	} else {
		document.getElementById("scrollerListInside").style.top = "100px";
	}
	document.getElementById("scrollerListInside").style.top = parseInt(document.getElementById("scrollerListInside").style.top) - 1 + "px";
}