
// ..................................................................

function valReg(form)
{
	if(!form.login.value.length) { form.login.focus(); return false; }
	if(!form.password1.value.length) { form.password1.focus(); return false; }
	if(!form.password2.value.length) { form.password2.focus(); return false; }
	if(form.password1.value != form.password2.value) { alert("Пароли не совпадают!"); form.password1.focus(); return false; }
	if(!form.email.value.length) { form.email.focus(); return false; }

	return true;
}

// ..................................................................

function valMy(form)
{
	if(!form.firstname.value.length) { form.firstname.focus(); return false; }
	if(!form.email.value.length) { form.email.focus(); return false; }

	return true;
}

// ..................................................................

function valPassChange(form)
{
	if(!form.pass1.value.length) { form.pass1.focus(); return false; }
	if(!form.pass2.value.length) { form.pass2.focus(); return false; }
	if(form.pass1.value != form.pass2.value) { alert("Пароли не совпадают!"); form.pass1.focus(); return false; }

	return true;
}

// ..................................................................

function valAuth(form)
{
	if(!form.login.value.length) { form.login.focus(); return false; }
	if(!form.password.value.length) { form.password.focus(); return false; }

	return true;
}

// ..................................................................

function valPass(form)
{
	if(!form.login.value.length) { form.login.focus(); return false; }
	if(!form.email.value.length) { form.email.focus(); return false; }

	return true;
}

// ..................................................................

function getImageY(imgElem)
{
	yPos = eval(imgElem).offsetTop;
	tempEl = eval(imgElem).offsetParent;
	while(tempEl != null)
	{
		yPos += tempEl.offsetTop;
		tempEl = tempEl.offsetParent;
	}

	return yPos;
}

// ..................................................................

function showCoffeehouse(number)
{
	document.getElementById("selectedCoffeehouse").className = "kofeini_photo_" + number;

	return false;
}

// ..................................................................

function hideCoffeehouse()
{
	document.getElementById("selectedCoffeehouse").className = "kofeini_photo_nophoto";

	return false;
}

// ..................................................................
/*
function showJobPopup(job_id)
{
	y = getImageY(document.getElementById("job_img_" + job_id));
	document.getElementById("job_popup_" + job_id).style.top = y - 33 + "px";
	document.getElementById("job_popup_" + job_id).style.display = "block";

	return false;
}
*/
// ..................................................................

function hideJobPopup(job_id)
{
	document.getElementById("job_popup_" + job_id).style.display = "none";

	return false;
}

// ..................................................................

function MP_getWindowSize()
{
	var x, y;
	if(self.innerHeight)
	{
		x = self.innerWidth;
		y = self.innerHeight;
	}
	else if(document.documentElement && document.documentElement.clientHeight)
	{
		x = document.documentElement.clientWidth;
		y = document.documentElement.clientHeight;
	}
	else if(document.body)
	{
		x = document.body.clientWidth;
		y = document.body.clientHeight;
	}
	retval = new Object;
	retval.x = x;
	retval.y = y; 

	return retval;
}

// ..................................................................

function showPromoPopup(popup)
{
	document.getElementById(popup).style.display = "block";
	w = parseInt(document.getElementById(popup).offsetWidth); 
	h = parseInt(document.getElementById(popup).offsetHeight);
	document.getElementById(popup).style.display = "none";
	ws = MP_getWindowSize();
	this_top_offset = 0;
	if(document.body.scrollTop)
	{
		this_top_offset = document.body.scrollTop;
	}
	else if(document.documentElement.scrollTop)
	{
		this_top_offset = document.documentElement.scrollTop;
	}
	this_top = this_top_offset + ws.y / 2 - h / 2;
	this_left = ws.x / 2 - w / 2;

	if(this_top < 0) this_top = 0;
	if(this_left < 0) this_left = 0;

	document.getElementById(popup).style.top = this_top + "px";
	document.getElementById(popup).style.left= this_left + "px";
	document.getElementById(popup).style.display = "block";

	return false;
}

// ..................................................................

function MP_openWindow(href, title, scroll, resizable, width, height, position)
{
	if(scroll != "yes")
	{
		scroll = "no";
	}

	if(resizable != "yes")
	{
		resizable = "no";
	}

	if(position != 'center')
	{
		xx = window.open(href, title, 'toolbar=no, scrollbars=' + scroll + ', menubar=no, directories=no, status=no, resizable=' + resizable + ', width=' + width + ', height=' + height);
	}
	else
	{
		this_top = (screen.height - height) / 2;
		this_left = (screen.width - width) / 2;
		xx = window.open(href, title, 'toolbar=no, scrollbars=' + scroll + ', menubar=no, directories=no, status=no, resizable=' + resizable + ', width=' + width + ', height=' + height + ', top=' + this_top + ', left=' + this_left);
	}

	xx.focus();

	return false;
}

// ..................................................................

function openDailyphoto(width, height)
{
	MP_openWindow("/engine/dailyphoto/image/", "dailyphoto", "no", "yes", width, height, "center");

	return false;
}

// ..................................................................

