// JavaScript Document

//Popup function that allows pages to be trawled.
function popup(mylink, windowname)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;
window.open(href, windowname, 'width=650,height=600,scrollbars=yes');
return false;
}

function targetopener(mylink, closeme, closeonly)
{
if (! (window.focus && window.opener))return true;
window.opener.focus();
if (! closeonly)window.opener.location.href=mylink.href;
if (closeme)window.close();
return false;
}

//Accendo JS

var message = new Array();
message[0] = "Accendo Carer Management";
message[1] = "Career Support";
message[2] = "Career Coaching";
message[3] = "Expert Guidance";
message[4] = "A Support Continuim";
message[5] = "Specific Industry Expertise";
message[6] = "Prepare For Sucess";

var reps = 2;
var speed = 100;  
var p = message.length;
var T = "";
var C = 0;
var mC = 0;
var s = 0;
var sT = null;
if (reps < 1) reps = 1;
function doTheThing() {
T = message[mC];
A();
}
function A() {
s++;
if (s > 8) { s = 1;}
if (s == 1) { document.title = '||||||====||| '+T+' -----'; }
if (s == 2) { document.title = '|||=|||===||| '+T+' -----'; }
if (s == 3) { document.title = '|||==|||==||| '+T+' -----'; }
if (s == 4) { document.title = '|||===|||=||| '+T+' -----'; }
if (s == 5) { document.title = '|||====|||||| '+T+' -----'; }
if (s == 6) { document.title = '|||===|||=||| '+T+' -----'; }
if (s == 7) { document.title = '|||==|||==||| '+T+' -----'; }
if (s == 8) { document.title = '|||=|||===||| '+T+' -----'; }
if (C < (8 * reps)) {
sT = setTimeout("A()", speed);
C++;
}
else {
C = 0;
s = 0;
mC++;
if(mC > p - 1) mC = 0;
sT = null;
doTheThing();
   }
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function checkValue(field,field_title)
{
	var temp = eval("document.review."+field+".value;");
	if(temp== "" || temp==" ")
	{
		alert("Please fill in your " + field_title + ", and try again.");
		eval("document.review."+field+".focus();");
		return false;
	} else {
		return true;
	}

}

function checkForm()
{
	if(checkValue("First_name","First name") && checkValue("Last_Name","Last name"))
	{
		if(emailCheck(document.review.email.value)
			&& emailCheck(document.review.confirm_email.value))
		{
			if(document.review.email.value == document.review.confirm_email.value)
			{
				if(document.review.terms.checked)
				{
					document.review.submit();
				}
				else
				{
					alert("Please agree to our terms and conditions");
				}
				
			}
			else
			{
				alert("Please check your email addresses, they do not matach");
			}
			

		} else {
			alert("Please fill in your email addresses, and try again.\nIf you have filled in your email address, check the '.' and '@' sign are correct, an email address will look something like this:\n\nyourname@somewhere.com or yourname@somewhere.co.uk\n");
			document.review.email.focus();
		}
	}
}
function checkRegisterForm()
{

	if(emailCheck(document.review.email.value)
			&& emailCheck(document.review.confirm_email.value))
		{
			if(document.review.email.value == document.review.confirm_email.value)
			{
				if(checkValue("pword","Password") && checkValue("confirm_pword","Confirmation Password"))
				{
				
					if(document.review.pword.value == document.review.confirm_pword.value)
					{

						if(checkValue("First_name","First name") && checkValue("Last_Name","Last name") && checkValue("Address","Address") && checkValue("City","City") && checkValue("Post_Code","Post Code") && checkValue("Country","Country"))						
							{
								if(document.review.terms.checked)
								{
									document.review.submit();
								}
								else
								{
									alert("Please agree to our terms and conditions");
								}
						
						}
						
					}
					else
					{
						alert("Please check your passwords, they do not match");
					}
				}
				else
				{
					alert("Please check your password and confirmation");
				}
				
			}
			else
			{
				alert("Please check your email addresses, they do not matach");
			}
			

		} else {
			alert("Please fill in your email addresses, and try again.\nIf you have filled in your email address, check the '.' and '@' sign are correct, an email address will look something like this:\n\nyourname@somewhere.com or yourname@somewhere.co.uk\n");
			document.review.email.focus();
		}
	
}

$(document).ready(function() {

  $('.dialog').each(function() {
    title = $(this).attr('title');

    $(this).dialog({
      autoOpen: false,
      modal: true,
      buttons: {
	Ok: function() {
	  $(this).dialog('close');
	}
      },
      title: title
    });
  });
});