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 validateContact(){
	
	var name = document.getElementById('fname').value;
	var sname = document.getElementById('sname').value;
	var email = document.getElementById('email').value;
	var company = document.getElementById('company').value;
	var contact = document.getElementById('contact').value;
	var info = document.getElementById('info').value;
	var position = document.getElementById('position').value;
	var showError="";
	
		if (name == ''){
			showError += 'Please enter your Name\r\n';
		}
		if (sname == ''){
			showError += 'Please enter your Surname\r\n';
		}
		if (email.indexOf('@') == -1){
			showError += 'Please enter a valid Email Address\r\n';
		}
		if (company == ''){
			showError += 'Please enter your Company\r\n';
		}
		if (showError != ''){
			alert (showError);
			return false;
		}else{
			return true;
	}
}

function expand_home(id){
	if(document.getElementById(id).style.display == "block"){
		document.getElementById(id).style.display = "none";
	}else{
		document.getElementById(id).style.display = "block";
	}
}
function validateLogin(){
	
	var username = document.getElementById('username').value;
	var pword = document.getElementById('pword').value;
	var showError="";

		if (username.indexOf('@') == -1){
			var showError = 'Please enter a valid Email Address';
		}
		if (pword == ''){
			var showError = 'Please enter your Password';
		}
		if (showError != ''){
			alert (showError);
			return false;
		}else{
			return true;
	}
}

function validateLogin1(){
	
	var username = document.getElementById('username1').value;
	var pword = document.getElementById('pword1').value;
	var showError="";

		if (username.indexOf('@') == -1){
			var showError = 'Please enter a valid Email Address';
		}
		if (pword == ''){
			var showError = 'Please enter your Password';
		}
		if (showError != ''){
			alert (showError);
			return false;
		}else{
			return true;
	}
}

function validateReg(){
	
	var r_name = document.getElementById('r_name').value;
	var r_surname = document.getElementById('r_surname').value;
	var r_username = document.getElementById('r_username').value;
	var r_pword = document.getElementById('r_pword').value;
	var r_cpword = document.getElementById('r_cpword').value;
	var showError="";
		if (r_name == ''){
			var showError = 'Please enter your Name';
		}
		if (r_surname == ''){
			var showError = 'Please enter your Surname';
		}
		if (r_username.indexOf('@') == -1){
			var showError = 'Please enter a valid Email Address';
		}
		if (r_pword == ''){
			var showError = 'Please enter your Password';
		}
		if (r_cpword == ''){
			var showError = 'Please confirm your Password';
		}
		if (r_cpword != r_pword){
			var showError = 'Your Password is not the same';
		}
		if (showError != ''){
			alert (showError);
			return false;
		}else{
			return true;
	}
}

function validatePword(){
	var p_username = document.getElementById('p_username').value;
	var showError="";

		if (p_username.indexOf('@') == -1){
			var showError = 'Please enter a valid Email Address';
		}
		if (showError != ''){
			alert (showError);
			return false;
		}else{
			return true;
		}
}
function changeimg(id){
	if(document.getElementsByName('img_'+id)[0].src == 'http://www.profishinsea.co.uk/client_area/profishinsea/site/images/hand.jpg'){
		document.getElementsByName('img_'+id)[0].src = 'http://www.profishinsea.co.uk/client_area/profishinsea/site/images/hand1.jpg'
	}else{
		document.getElementsByName('img_'+id)[0].src = 'http://www.profishinsea.co.uk/client_area/profishinsea/site/images/hand.jpg'
	}
}
function ShowPicture(id,Source) {
	if (Source=="1"){
		document.getElementById(''+id+'').style.display = "block";
	}else{
		document.getElementById(''+id+'').style.display = "none";
	}
} 
function contact_package(val, title){
	
	var fname = document.getElementById("fname_"+val).value;
    var lname = document.getElementById("lname_"+val).value;
	var email = document.getElementById("email_"+val).value;
	var tel = document.getElementById("tel_"+val).value;
	var comments = document.getElementById("comments_"+val).value;
	
	var errorMSG = '';
	
	if (fname == ''){
		errorMSG += 'Please enter a name\r\n';	
	}
	if(lname == ''){
		errorMSG += 'Please enter a surname\r\n';
	}
	if(tel == '' && email == ''){
		errorMSG += 'Please enter an email or a telephone number\r\n';	
	}
	if(tel == '' && email != ''){
		if(email.indexOf('@') == -1){
			errorMSG += 'Please enter a valid email address\r\n';
		}
	}
	
	if (errorMSG != ''){
		alert(errorMSG);
		return false;
	}else{
		var id = ajax("ajax/emailPackage.php", "fname="+fname+"&lname="+lname+"&email="+email+"&tel="+tel+"&comments="+comments+"&title="+title);
		if( id != "0" && id != "" ){
			document.getElementById("contact_package_"+val).innerHTML = "<div class='thank_you'>Thank you for your enquiry.<br><br>We will get back to you shortly.</div>";

		} else alert("Error while executing this operation.");
	}
}
function _doResize(){
	
	if (document.getElementsByName('lightbox_main').length > 0){
		for (i = 0; i < document.getElementsByName('lightbox_main').length; i++) {	
		
			var bodyHeight = document.body.clientHeight;
			var bodyVal = document.body.clientWidth;
			var mainVal = document.getElementById("main").clientWidth;
			var widthVal = (bodyVal - mainVal) / 2;
			if(widthVal <= 0){
				widthVal = 0;		
			}
			//document.getElementById("s"+id).style.left = widthVal+"px";
			document.getElementsByName('lightbox_main')[i].style.left = widthVal+"px";
			document.getElementById('ebox1').style.width=bodyVal+"px";
			document.getElementById('ebox1').style.height=bodyHeight+"px";
	
		}
	}
}

function doResize(){
	
	var bodyHeight = document.body.clientHeight;
	var bodyVal = document.body.clientWidth;	
	var targetLightbox = document.getElementById('targetLightbox').clientWidth;
	if(targetLightbox < 500){
		var mainVal = targetLightbox;
	}else{
		var mainVal = document.getElementById("main").clientWidth;
	}
	var widthVal = (bodyVal - mainVal) / 2;
	if(widthVal <= 0){
		widthVal = 0;		
	}else{
		widthVal = widthVal + 5;	
	}
	//document.getElementById("s"+id).style.left = widthVal+"px";
	document.getElementById('targetLightbox').style.left = widthVal+"px";
	document.getElementById('ebox1').style.width=bodyVal+"px";
	document.getElementById('ebox1').style.height=bodyHeight+"px";
}

function getQuote(){
	var name = encodeURIComponent(document.getElementById('quote_name').value);
	var email = document.getElementById('quote_email').value;
	var tel = document.getElementById('quote_tel').value;
	var package = document.getElementById('quote_packages').value;
	var info = encodeURIComponent(document.getElementById('quote_info').value);
	var errorMsg = "";
	
	if(name == ""){
		errorMsg += 'Please enter a Name\r\n';
	}
	if(email.indexOf('@') == -1){
		errorMsg += 'Please enter a valid Email Address\r\n';
	}
	
	if(errorMsg != ''){
		alert(errorMsg);	
	}else{
		var id = ajax("ajax/freeQuote.php", "name="+name+"&email="+email+"&tel="+tel+"&info="+info+"&package="+package);
		if( id != "0" && id != "" ){
			alert("Thank you.\n\rOur team will contact you shortly.")
			document.getElementById('quote_name').value = "";
			document.getElementById('quote_email').value = "";
			document.getElementById('quote_tel').value = "";
			document.getElementById('quote_packages').value = "";
			document.getElementById('quote_info').value = "";
			
		} else alert("Sending failed.\n\rPlease try again.");
	}
	
}

function validateContact_form(){
	
	var name = document.getElementsByName('fname_form')[1].value;
	var sname = document.getElementsByName('sname_form')[1].value;
	var email = document.getElementsByName('email_form')[1].value;
	var company = document.getElementsByName('company_form')[1].value;
	var contact = document.getElementsByName('contact_form')[1].value;
	var info = document.getElementsByName('info_form')[1].value;
	var position = document.getElementsByName('position_form')[1].value;
	var title = document.getElementById('package_lightbox_header').innerHTML;
	var showError="";
	
		if (name == ''){
			showError += 'Please enter your Name\r\n';
		}
		if (sname == ''){
			showError += 'Please enter your Surname\r\n';
		}
		if (email.indexOf('@') == -1){
			showError += 'Please enter a valid Email Address\r\n';
		}
		if (showError != ''){
			alert (showError);
			return false;
		}else{
			var id = ajax("ajax/contactUs.php", "name="+name+"&sname="+sname+"&email="+email+"&company="+company+"&info="+info+"&contact="+contact+"&position="+position+"&title="+title);
			if( id != "0" && id != "" ){
				alert("Thank you.\n\rOur team will contact you shortly.")
				document.getElementById('targetLightbox').style.display='none';
				document.getElementById('ebox1').style.display='none';
				document.getElementsByName('fname_form')[1].value = "";
				document.getElementsByName('sname_form')[1].value = "";
				document.getElementsByName('email_form')[1].value = "";
				document.getElementsByName('company_form')[1].value = "";
				document.getElementsByName('info_form')[1].value = "";
				document.getElementsByName('position_form')[1].value = "";
				document.getElementById('package_lightbox_header').innerHTML = "";
				
			} else alert("Sending failed.\n\rPlease try again.");
	}
}

function show_video(){
	
	var so = new SWFObject('flash/player-viral.swf','mpl','450','250','9');
	so.addParam('allowfullscreen','true');
	so.addParam('allowscriptaccess','always');
	so.addParam('wmode','opaque');
	so.addVariable('file','../content_images/interlude.flv');
	so.write('videobox1');
	
	var so2 = new SWFObject('flash/player-viral.swf','mpl','450','250','9');
	so2.addParam('allowfullscreen','true');
	so2.addParam('allowscriptaccess','always');
	so2.addParam('wmode','opaque');
	so2.addVariable('file','../content_images/prism.flv');
	so2.write('videobox2');
}
function showColour(id, img1, img2){
	document.getElementById("img_"+id).src = "clients_images/"+img2;
}
function showGrey(id, img1, img2){
	document.getElementById("img_"+id).src = "clients_images/"+img1;
}


