
function pagefinder(p,i) {
 document.getElementById('error').action="?action=club&stage=finder&op=find&pages="+p+"&currpage="+i;
 document.getElementById("error").submit();
};

function viewfinder(item,p,i) {
 document.getElementById('error').action="?action=club&stage=finder&op=view&item="+item+"&pages="+p+"&currpage="+i;
 document.getElementById("error").submit();
};
function backresult() {
 document.getElementById("error").submit();
};
function settofriend(item,p,i) {
 document.getElementById('error').action="?action=club&stage=finder&op=bemyfriend&item="+item+"&pages="+p+"&currpage="+i;
 document.getElementById("error").submit();
};
function backtofind() {
 document.getElementById('error').action="?action=club&stage=finder";
 document.getElementById("error").submit();
};

function pageLoader() {
	sweetTitles.init();
};

function SA_mail(n, d)
{
	m=n+"@"+d;
	location.href="mailto:"+m;
}

//Vйrifie que le mot de passe Mpasse conrresponde au mot de passe MpasseConfirmation.
//Renvoie 'true' dans ce cas, 'false' sinon.
function SA_verifieMPasse( formulaire )
{
	var VSI_form = formulaire;

	if ( VSI_form.MPasse.value == VSI_form.MPasseConfirmation.value ){
		return true;
	}
	else
	{
		return false;
	}
}

//Vйrifie que l'e-mail envoyй en paramиtre corresponde au
//schйma suivant 'x@x.xx'. Renvoie 'true' dans ce cas, 'false' sinon.
function SA_verifieEmail( Email )
{
	var VSI_at = Email.indexOf('@',1);
	var VSI_point = Email.indexOf( '.', VSI_at+2 );

	if ( Email == "" || VSI_at < -1 || VSI_point < 1 || VSI_point+3 > Email.length ){
		return false;
	}
	else
	{
		return true;
	}
};


function addEvent( obj, type, fn ) {
	if (obj.addEventListener) {
		obj.addEventListener( type, fn, false );
		EventCache.add(obj, type, fn);
	}
	else if (obj.attachEvent) {
		obj["e"+type+fn] = fn;
		obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
		obj.attachEvent( "on"+type, obj[type+fn] );
		EventCache.add(obj, type, fn);
	}
	else {
		obj["on"+type] = obj["e"+type+fn];
	}
};

var EventCache = function(){
	var listEvents = [];
	return {
		listEvents : listEvents,
		add : function(node, sEventName, fHandler){
			listEvents.push(arguments);
		}
	};
}();

var ie=0;  //идентификатор интернет эксплорера
var sweetTitles = {
	xCord : 0,								// @Number: x pixel value of current cursor position
	yCord : 0,								// @Number: y pixel value of current cursor position
	obj : Object,							// @Element: That of which you're hovering over
	tip : Object,							// @Element: The actual toolTip itself
	active : 0,								// @Number: 0: Not Active || 1: Active
	init : function() {
		if ( !document.getElementById ||
			!document.createElement ||         // проверка на поддержку методов
			!document.getElementsByTagName ) {
			return;
		}
		var i,j;
		this.tip = document.createElement('div');
		this.tip.id = 'toolTip';
		document.getElementsByTagName('body')[0].appendChild(this.tip);   //добавляем объект div
		this.tip.style.top = '0';
		this.tip.style.visibility = 'hidden';
		var current = document.getElementsByTagName('a'); //создает новый объект NodeList, состоящий из всех объектов Element
		var curLen = current.length;
		for ( j=0; j<curLen; j++ ) {   //в документе все подсказки, которые мы хотим вывести должны находиться в теге <а> и иметь id="alt"
			if(current[j].getAttribute("id")=="alt"){ // проверяем текущий элемент на принадлежность к подсказке которую мы хотим вывести
				addEvent(current[j],'mouseover',this.tipOver);
				addEvent(current[j],'mouseout',this.tipOut);
				current[j].setAttribute('tip',current[j].name);
				current[j].removeAttribute('name');
			}
		}

	},
	updateXY : function(e) {
         if ( document.captureEvents ) {
			sweetTitles.xCord = e.pageX;
			sweetTitles.yCord = e.pageY;
		 } else if ( window.event.clientX ) {
			ie=1;     // устанавливаем флаг интернет эксплорера
			sweetTitles.xCord = window.event.clientX;
			sweetTitles.yCord = window.event.clientY;
		   }


	},
	tipOut: function() {

		sweetTitles.tip.style.visibility = 'hidden';
	},
	tipOver : function(e) {
		sweetTitles.obj = this;
		tID = window.setTimeout("sweetTitles.tipShow()",500);
		sweetTitles.updateXY(e);
	},
	tipShow : function() {
		var scrX = Number(this.xCord);
		var scrY = Number(this.yCord);
		var tp = parseInt(scrY);
		var lt = parseInt(scrX);
		re = new RegExp("\r","g");
		str=this.obj.getAttribute('tip');
		this.tip.innerHTML = "<p>"+str.replace(re,"<br>")+"</p>";
     	dx=10;//смещение подскаки вправо и влево относительно координат мыши
    	left=false;right=false;
    	if(parseInt(dx+lt+this.tip.clientWidth)>document.body.clientWidth+document.body.scrollLeft){lt=parseInt(document.body.clientWidth+document.body.scrollLeft-this.tip.clientWidth-dx*2);left=true;}
    	if(parseInt(dx+tp+this.tip.clientHeight)>document.body.clientHeight+document.body.scrollTop){tp=parseInt(document.body.clientHeight+document.body.scrollTop-this.tip.clientHeight-dx*2);right=true;}
    	//если объект в нижнем правом углу, подсказка всплывает над курсором
    	if(left&&right)tp=parseInt(document.body.clientHeight+document.body.scrollTop-this.tip.clientHeight-dx*4);
    	//помещение подсказки в найденные коородинаты
    	this.tip.style.left = (ie*document.body.scrollLeft)+dx+lt+'px';
    	this.tip.style.top = (ie*document.body.scrollTop)+dx+tp+'px';
    	this.tip.style.visibility = 'visible';
	}
};

function inputother(ot) {
 document.getElementById('oth').innerHTML="<input name='other' type='text' maxlength='60'  class='area2' value='"+ot+"'>"
};
function closeother() {
 document.getElementById('oth').innerHTML=""
};

function CalCh()
{ var year1=document.getElementById('year1').value;
  var month1=document.getElementById('month1').value;
  var day1=document.getElementById('day1').value;
  month1--;
  var firstDay = 1
  var s="";
  var now = new Date(year1,month1,1);   // Получаем дату.
  var currentMonth = now.getMonth();   // Узнаём месяц.
  var lastDay = 28;   // Устанавливаем минимально возможное число дней в месяце (меньше не бывает).
  while (currentMonth == now.getMonth())   // Проверяем в цикле, не изменился ли месяц при попытке установить невозможное число.
    now.setDate(++lastDay);   // Увеличиваем число.
  lastDay--;
  str="<select name='day' id='day1' class='day'>";
  for(i=firstDay;i<=lastDay;i++)
    {if(i==day1)s='selected';
     else s="";
     str+="<option "+s+" value='"+i+"'>"+i+"</option>";
    }
  str+="</select>";
  //alert(str);
  document.getElementById('agr').innerHTML=str;
 // alert(document.getElementById('agr').outerHTML);
};

addEvent(window,'load',pageLoader);