<!--

function echeck(str) {
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)

		if (str.indexOf(at)==-1){
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }
	
		 if (str.indexOf(" ")!=-1){
		    return false
		 }

 		 return true					
	}

function ValidateEmail(nameid){

	var emailID=window.document.getElementById(nameid)

	if ((emailID.value==null)||(emailID.value=="")){
		return false
	}

	if(emailID.value.length>0)

	if (echeck(emailID.value)==false){
		return false
	}

	return true
 }

function isInteger(s)

{   var i;

	var sep=0;

	if (s.length==0) return false;

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.

        var c = s.charAt(i);

        if(c==".") sep++;

        if(c=="."&&(i==0||(i==(s.length-1)))) return false;

        if(sep>1) return false;

        if ((((c < "0") || (c > "9")) && (c != "."))) return false;

    }

    // All characters are numbers.

    return true;

}

function isLogin(s)
{   
	if(s.length<5) return false;

  	var login_char="1234567890abcdefghijklmnopqrstuvwxyz_";

    for (i = 0; i < s.length; i++)
    {   
      	var good=false;

        var c = s.charAt(i);

        for (x = 0;x<login_char.length;x++)
        {
        var l = login_char.charAt(x);          
           if(c==l) {
					good=true;
					 }
		}
        if(good==false) return false;
    }

    // All characters are numbers.

    return true;
}

function isNick(s)
{   
	if(s.length<5) return false; 							  

    for (i = 0; i < s.length; i++)
    {   
      	var good=true;

 		 var c = s.charAt(i);
        if(c=='"'||c=="'"||c=="/"||c=="\\"||c==",") good=false;

        if(good==false) return false;
    }

    // All characters are numbers.

    return true;
}

function ValidateFormLogin(){

var validate=true; 
window.document.getElementById('msg_user_login').innerHTML='';
window.document.getElementById('msg_user_nick').innerHTML='';
window.document.getElementById('msg_user_email').innerHTML='';
window.document.getElementById('msg_user_password').innerHTML='';
window.document.getElementById('msg_user_password2').innerHTML='';
window.document.getElementById('msg_user_email2').innerHTML='';
window.document.getElementById('msg_user_reg').innerHTML='';

	// login validation
		
if(!isLogin(window.document.getElementById('user_login').value))
		{window.document.getElementById('msg_user_login').innerHTML="* nie mniej niż 5 znaków; tylko małe litery (bez polskich znaków), cyfry i znak podkreślenia";
		validate=false;}
	
	// nick validation
	
if(!isNick(window.document.getElementById('user_nick').value))
		{window.document.getElementById('msg_user_nick').innerHTML="* nie mniej niż 5 znaków; bez , \\ \/ ' \"";
		validate=false;}		
	
	// password validation		
					
if(!isNick(window.document.getElementById('user_password').value))
		{window.document.getElementById('msg_user_password').innerHTML="* nie mniej niż 5 znaków; bez , \\ \/ ' \"";
		validate=false;}		
	
	// password 2 validation
if(window.document.getElementById('user_password').value!=window.document.getElementById('user_password2').value)
	{window.document.getElementById('msg_user_password2').innerHTML="* powtórz dokładnie hasło";
		validate=false;}	
		
	// email validation			
		
if(!ValidateEmail('user_email'))
		{window.document.getElementById('msg_user_email').innerHTML="* wpisz poprawnie adres email ";
		validate=false;}		
		
// email 2 validation
if(window.document.getElementById('user_email').value!=window.document.getElementById('user_email2').value)
	{window.document.getElementById('msg_user_email2').innerHTML="* powtórz dokładnie adres email ";
		validate=false;}	

// read reg validation
if(window.document.getElementById('user_regulamin').checked==false)
	{window.document.getElementById('msg_user_reg').innerHTML="* musisz zaakceptować regulamin, jeśli chcesz się zarejestrować";
		validate=false;}
		
		if(validate)			
			return true;
			else
			return false;
}



function ValidateFormFieldsM(){

var d = new Date();
var curr_year = d.getFullYear();

var validate=true; 
window.document.getElementById('msg_plec').innerHTML='';
window.document.getElementById('msg_dataUrodzenia').innerHTML='';
window.document.getElementById('msg_miejscowosc').innerHTML='';
window.document.getElementById('msg_orientacja').innerHTML='';
window.document.getElementById('msg_informacja').innerHTML='';


	// plec validation
		
if(window.document.getElementById('plec').value==0)
		{window.document.getElementById('msg_plec').innerHTML="* wybierz płeć";
		validate=false;}
	
	// data urodzenia validation
if(window.document.getElementById('miesiac').value==0||window.document.getElementById('dzien').value==0||!isInteger(window.document.getElementById('rok').value))
		{
		  window.document.getElementById('msg_dataUrodzenia').innerHTML="* podaj poprawnie datę urodzenia";
		validate=false;
		}
		  if(isInteger(window.document.getElementById('rok').value))
		  	if(parseFloat(window.document.getElementById('rok').value)<curr_year-100||parseFloat(window.document.getElementById('rok').value)>curr_year-15)
		  	{
			window.document.getElementById('msg_dataUrodzenia').innerHTML="* podana data wydaje się być nieprawidłowa, podaj poprawną";	
			validate=false;
			}

	// miejscowosc validation
if(window.document.getElementById('miejscowosc').value==''&&window.document.getElementById('lista_miejscowosc').value==0)
		{window.document.getElementById('msg_miejscowosc').innerHTML="* wybierz miasto z listy lub wpisz jego nazwę";
		validate=false;}
	
	// orientacja validation		
if(window.document.getElementById('orientacja').value==0)
		{window.document.getElementById('msg_orientacja').innerHTML="* wybierz orientację seksualną";
		validate=false;}
		
	// informacja validation
if(window.document.getElementById('informacja').value==''||window.document.getElementById('informacja').value.length>100)
		{window.document.getElementById('msg_informacja').innerHTML="* napisz krótką informację o sobie, nie więcej niż 100 znaków";
		validate=false;}		
	

		if(validate)			
			return true;
			else
			return false;
			
}

function ValidateFormFieldsS(){

var validate=true; 
window.document.getElementById('msg_user_login').innerHTML='';
window.document.getElementById('msg_user_pass').innerHTML='';
window.document.getElementById('msg_user_email').innerHTML='';
window.document.getElementById('msg_user_password').innerHTML='';
window.document.getElementById('msg_user_password2').innerHTML='';
window.document.getElementById('msg_user_email2').innerHTML='';


	// old pass validation
		
if(!isNick(window.document.getElementById('user_pass').value))
		{window.document.getElementById('msg_user_pass').innerHTML="* nie mniej niż 5 znaków; bez , \\ \/ ' \"";
		validate=false;}		
	
	// login pass validation	
if(!isLogin(window.document.getElementById('user_login').value))
		{window.document.getElementById('msg_user_login').innerHTML="* nie mniej niż 5 znaków; tylko małe litery (bez polskich znaków), cyfry i znak podkreślenia";
		validate=false;}
		
	
	// password validation		
					
if(!isNick(window.document.getElementById('user_password').value))
		{window.document.getElementById('msg_user_password').innerHTML="* nie mniej niż 5 znaków; bez , \\ \/ ' \"";
		validate=false;}		
	
	// password 2 validation
if(window.document.getElementById('user_password').value!=window.document.getElementById('user_password2').value)
	{window.document.getElementById('msg_user_password2').innerHTML="* powtórz dokładnie hasło";
		validate=false;}	
		
	// email validation			
		
if(!ValidateEmail('user_email'))
		{window.document.getElementById('msg_user_email').innerHTML="* wpisz poprawnie adres email ";
		validate=false;}		
		
// email 2 validation
if(window.document.getElementById('user_email').value!=window.document.getElementById('user_email2').value)
	{window.document.getElementById('msg_user_email2').innerHTML="* powtórz dokładnie adres email ";
		validate=false;}	

		
		if(validate)			
			return true;
			else
			return false;
}

function autofitIframe(id){
 parent.document.getElementById(id).style.height=this.document.body.scrollHeight+"px" 
} 
 
function showHide(obj) {
if (document.getElementById)
   {
   var nodeObj = document.getElementById(obj)
   if(nodeObj.style.display == 'none') nodeObj.style.display = 'block';
   		else nodeObj.style.display = 'none';
   }  
}
 
function shrink_expand(iframeId)
{

if(direction==-1)
	{
	direction=1;
	window.document.getElementById('control').innerHTML='zwiń';
	speed_of_change=20;
	}
	else
	{
	direction=-1;
	speed_of_change=20;
	window.document.getElementById('control').innerHTML='więcej';
	}
	
if(!changing)
	{

		window.setTimeout('change_height("'+iframeId+'")', motion/3);	
	}
}


function change_height(iframeId)
{
	var div_element=window.document.getElementById('element');

	var current_height=parseInt(div_element.style.height);	

	if( (direction==-1&&(max_height>=current_height&&min_height<(current_height-speed_of_change)))
		||
		(direction==1&&(max_height>=(current_height+speed_of_change)&&min_height<=current_height))
		)

		{
		changing=true;			

		div_element.style.height=(current_height+speed_of_change*direction)+'px';	
	
		var top_controll=parseInt(window.document.getElementById('control').style.top);
		window.document.getElementById('control').style.top=(top_controll+speed_of_change*direction)+'px';	
		autofitIframe(iframeId);
		
		if(direction==1)
		{
		speed_of_change=Math.abs((max_height-current_height))/10+1;
		}
		else
		speed_of_change=Math.abs((min_height-current_height))/10+1;
		
			window.setTimeout('change_height("'+iframeId+'")', motion/3);
		}
	else
		{	
		changing=false;			
		}
	
}

function toggleChecked(oElement) 
      { 
        oForm = oElement.form; 
        oElement = oForm.elements[oElement.name]; 
        if(oElement.length) 
        { 
          bChecked = oElement[0].checked; 
          for(i = 1; i < oElement.length; i++) 
            oElement[i].checked = bChecked; 
        } 
      }

function textCounter(field, countfield, maxlimit)
{
	if (field.value.length > maxlimit) field.value = field.value.substring(0, maxlimit);
	else countfield.value = maxlimit - field.value.length;
}

function reloadImg(id) {
	var obj = document.getElementById(id);
	var src = obj.src;
	var pos = src.indexOf('?');
	if (pos >= 0) {
		src = src.substr(0, pos);
	}
	var date = new Date();
	obj.src = src + '?v=' + date.getTime();
	return false;
}

-->
