
var siteUrl = "http://www.fclm.ru/";
var siteName = 'ФК "Локомотив"';

function setAsStartPage(){
	var obj = window.event.srcElement;
	if (obj != undefined){
		obj.style.behavior = "url(#default#homepage)";
		obj.setHomePage(siteUrl);
	}
	return false;
}

function addToFavorites(){
	if (window.external != undefined)
		window.external.addFavorite(siteUrl, siteName);
	return false;
}

function copyshortcut(url) {
	if(window.clipboardData) {
		window.clipboardData.setData("Text", url);
		alert("Ссылка скопирована в буфер обмена");
	} else {
		window.prompt("Ссылка на сообщение.", url);
	}
	
}

function IsEMail(value) {
    if(value=="")
        return true;
	else {
	    re = /.@{1}[0-9A-Za-z\-]{1,}\.{1}[A-Za-z]{2,4}/
	    return re.test(value)
	}
}

function validatePost(thisForm) {

	if(thisForm.author.value.length == 0){
		alert("Author name must be specified!");
		window.event.returnValue = false;
		return false;
	}

	if(!IsEMail(thisForm.authoremail.value)){
		alert("Author Email is not correct e-mail address!");
		window.event.returnValue = false;
		return false;
	}

	if(thisForm.message.value.length < 20){
		alert("Message must contain at least 20 digits!");
		window.event.returnValue = false;
		return false;
	}
	
	return true;
}

function validateQuestion(thisForm) {

	if(thisForm.fio.value.length == 0){
		alert("Author name must be specified!");
		window.event.returnValue = false;
		return false;
	}

	if(!IsEMail(thisForm.email.value)){
		alert("Author Email is not correct e-mail address!");
		window.event.returnValue = false;
		return false;
	}

	if(thisForm.question.value.length < 20){
		alert("Message must contain at least 20 digits!");
		window.event.returnValue = false;
		return false;
	}
	
	return true;
}

function getAbsoluteLeft(object) {
	var x = 0;
	var p = object;
	while(p!=document.body) {
		x = x + p.offsetLeft;
		p = p.offsetParent;
	}
	return x;
}

function getAbsoluteTop(object) {
	var x = 0;
	var p = object;
	while(p!=document.body) {
		x = x + p.offsetTop;
		p = p.offsetParent;
	}
	return x;
}

function repositBottomBar(el) {
	if(document.getElementById('idimagedesc')) {
		document.getElementById('idimagedesc').style.top=getAbsoluteTop(el)+el.offsetHeight-16+'px';
		document.getElementById('idimagedesc').style.left=getAbsoluteLeft(el)+'px';
		document.getElementById('idimagedesc').style.width=el.offsetWidth+'px';
		document.getElementById('idimagedesc').style.display='';
	}
}

function showMenu(el){
	if(document.getElementById('idPhotosTree').style.display == 'none') {
		document.getElementById('idPhotosTree').style.display=''; 
		document.getElementById('idPhotosTree').style.top=(getAbsoluteTop(el)+el.offsetHeight+1)+'px';
		document.getElementById('idPhotosTree').style.left=(getAbsoluteLeft(el))+'px';
		document.getElementById('idPhotosTree').opener = el;
		document.getElementById('idPhotosTree').focus();
	}else{
		document.getElementById('idPhotosTree').style.display = 'none';
	}
}

function blurlayer(el) {
	if(!el.contains(document.activeElement) && !el.opener.contains(document.activeElement)) {
		el.style.display = "none";
	}
}

function op(src, w, h, scrollBars) { 
   var wnd = window.open(src, "custom", "status=no,help=no,resizable=no,scrollbars="+scrollBars+",width=" + w + ",height=" + h); 
   wnd.opener = window; 
   wnd.focus();
} 

function op(src, w, h, scrollBars) { 
   var wnd = window.open(src, "custom", "status=no,help=no,resizable=no,scrollbars="+scrollBars+",width=" + w + ",height=" + h); 
   wnd.opener = window; 
   wnd.focus();
} 


function postRedirect(formid, url, postdata) {
	document.write("<form action='"+url+"' name='"+formid+"' method='post'>\n");
	if(postdata) {
		for(post in postdata) {
			document.write("<input type=hidden name='"+post[0]+"' value='"+post[1]+"'>\n");
		}
	}
	else {
		document.write("<input type=hidden name='dummy' value='1'>\n");
	}
	document.write("</form>\n");
	document.write("<"+"script language='javascript'>"+formid+".submit();</"+"script>\n");
	try {
		window.event.returnValue = false;
		window.event.cancelBubble = true;
	}
	catch(e) {
	}
	return false;
}