// JavaScript Document

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.01
  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 && d.getElementById) x=d.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 box()
{
	MOOdalBox.open( 'welcome.html', 'Welcome', '500 425' );
}

function boxLogin()
{
	//MOOdalBox.open( 'welcome_cv.html', 'New employment opportunities in Velika Plaza', '500 425' );
}

function zoningBox()
{
	MOOdalBox.open( 'zoning.html', 'Velika Plaza - Zoning video', '730 600' );
}


function questionBox()
{
	MOOdalBox.open( 'questions.html', 'Velika Plaza - Questions and answers', '550 425' );
}

function zoningFlashBox()
{
	window.open('zoning_flash.html','ZoningFlash', 'width=1440,height=800');
}

function verifyEmail(Address)
{
	AtPos = Address.indexOf("@")
	StopPos = Address.lastIndexOf(".")
	r = true
	
	if (Address == "") r = false
	if (AtPos == -1 || StopPos == -1) r = false
	if (StopPos < AtPos) r = false
	if (StopPos - AtPos == 1) r = false
	
	return r
}

function verifyPassword(Password1, Password2)
{
	r = true
	
	if (Password1 == "") r = false
	if (Password2 == "") r = false
	if (Password1 != Password2) r = false
	
	return r
}

function verifyRegister(Forma)
{
	var sMsg = "";
	var sN = "\r\n";
	var sHeader = "You failed to fill these fields correctly:" + sN + sN;
	
	if (Forma.Name.value == "") { sMsg += " - Name" + sN; Forma.Name.style.backgroundColor = '#ff0000'; } else { Forma.Name.style.backgroundColor = 'white'; }
	if (Forma.NameLast.value == "") { sMsg += " - Last name" + sN; Forma.NameLast.style.backgroundColor = '#ff0000'; } else { Forma.NameLast.style.backgroundColor = 'white'; }
	if (!verifyEmail(Forma.Email.value)) { sMsg += " - Email" + sN; Forma.Email.style.backgroundColor = '#ff0000'; } else { Forma.Email.style.backgroundColor = 'white'; }
	if (!verifyPassword(Forma.Password.value, Forma.Password2.value))
	{
		sMsg += " - Password" + sN;
		Forma.Password.style.backgroundColor = '#ff0000';
		Forma.Password2.style.backgroundColor = '#ff0000';
		Forma.Password.value = '';
		Forma.Password2.value = '';
	}
	else
	{
		Forma.Password.style.backgroundColor = 'white';
		Forma.Password2.style.backgroundColor = 'white';
	}
	if (Forma.Country.value == "") { sMsg += " - Country" + sN; Forma.Country.style.backgroundColor = '#ff0000'; } else { Forma.Country.style.backgroundColor = 'white'; }
	if (Forma.Accept.checked == false) { sMsg += " - You must accept terms and conditions" + sN; document.getElementById("dAccept").style.backgroundColor = '#ff0000'; } else { document.getElementById("dAccept").style.backgroundColor = 'transparent'; }

	
	if (sMsg != "") {
		alert(sHeader + sMsg);
		return false;
	} else {
		return true;
	}
}
function verifyLogin(Forma)
{
	var sMsg = "";
	var sN = "\r\n";
	var sHeader = "You failed to fill these fields correctly" + sN + sN;
	
	if (!verifyEmail(Forma.u.value)) { sMsg += " - Email" + sN; Forma.u.style.backgroundColor = '#ff0000'; } else { Forma.u.style.backgroundColor = 'white'; }
	if (Forma.p.value == "") { sMsg += " - Password" + sN; Forma.p.style.backgroundColor = '#ff0000'; } else { Forma.p.style.backgroundColor = 'white'; }
	
	if (sMsg != "") {
		alert(sHeader + sMsg);
		return false;
	} else {
		return true;
	}
}

function cvNewEducation()
{
	new Ajax('./test.php',
		{
			method: 'get',
			onComplete:
				function()
				{
					$("tbEducation").appendText($("tbEducation").innerHTML);
				}
		}).request();
}