var isDHTML = 0;
var isLayers = 0;
var isAll = 0;
var isID = 0;

if (document.getElementById) {isID = 1; isDHTML = 1;}
else {
browserVersion = parseInt(navigator.appVersion);
if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4)) {isLayers = 1; isDHTML = 1;}
else {
if (document.all) {isAll = 1; isDHTML = 1;}
}}

function findDOM(objectID,withStyle) {
var menuArea = "menuArea";
        if (withStyle == 1) {
                if (isID) { return (document.getElementById(objectID).style) ; }
                else {
                        if (isAll) { return (document.all[objectID].style); }
                else {
                        if (isLayers) { return (document.layers[menuArea].layers[objectID]); }
                };}
        }
        else {
                if (isID) { return (document.getElementById(objectID)) ; }
                else {
                        if (isAll) { return (document.all[objectID]); }
                else {
                        if (isLayers) { return (document.layers[menuArea].layers[objectID]); }
                };}
        }
}

function znik(a)
{
//t.className="jezyki";
//t.innerHTML=v.title;v.title="";
//alert(document.getElementById("jezyki_id"));
//jezyki=document.getElementById("jezyki_id");
jezyki.value=a;
//var jezyki=document.createElement("div");
    //jezyki.className="jezyki";
x=window.event.clientX + document.body.scrollLeft; 
y=window.event.clientY + document.body.scrollTop; 
jezyki.style.left=x+5+"px";
jezyki.style.top=y+20+"px";
jezyki.style.height=18
jezyki.style.width=65
}
function wys()
{
jezyki.value=""
jezyki.style.height=0
jezyki.style.width=0
}


function blinkIt(tag) {
 if (!document.all) return;
 else {
   for(i=0;i<document.all.tags(tag).length;i++){
      s=document.all.tags(tag)[i];
      s.style.visibility=(s.style.visibility=='visible')?'hidden':'visible';
   }
 }
}


function countPrice(ileKredytow,cena1kr) {
	kosztEuro=ileKredytow.value*cena1kr;
	kosztPL=kosztEuro*4;
	document.getElementById("suma").value=kosztEuro+"EUR ("+kosztPL+"PLN)";
	document.getElementById("sumahidden").value=kosztPL;
}
function MemberInfo(id) {
	var okno=window.open("member_info2?idt="+id,"subWind","HEIGHT=250,WIDTH=780,status=1,menubar=0");
}

function InfoAboutProfilePhoto() {
	var okno=window.open("photoProfileInfo.php","subWind","HEIGHT=250,WIDTH=780,status=1,menubar=0");
}
function InfoAboutPhoto() {
	var okno=window.open("photoInfo.php","subWind","HEIGHT=570,WIDTH=780,status=1,menubar=0");
}
function ShowGirlData(id) {
	var okno=window.open("showgirldata?id="+id,"subWind","HEIGHT=280,WIDTH=740,status=1,menubar=0");
}

function ShowBoughtProfiles(id) {
	var okno=window.open("boughtprofiles.php?id="+id,"subWind2","HEIGHT=580,WIDTH=800,status=1,menubar=0,scrollbars=yes");
}
function redirect()  {  
{ window.location.href="http://www.site.com/confirm.a4d"; }  
}  

function select(id,gid) {
	//alert(window.parent.document.getElementById("s60"));
	window.opener.document.getElementById(id).value=gid;
	window.parent.close();

}

function not_equal_mail(email, re_email) {
	var input1 = new String(email.value);
	var input2 = new String(re_email.value);
	if (input1.match(input2))	{	
		email.style.backgroundColor="white";
		re_email.style.backgroundColor="white";
		return false
	} else	{
		email.style.backgroundColor="palevioletred";
		re_email.style.backgroundColor="palevioletred";
		email.focus();
		email.select();
		return true;
	} 	

}

function isEmpty(elem) {
	var inputStr = elem.value;
	if (inputStr == null || inputStr == "") {
		elem.style.backgroundColor="palevioletred";
		elem.focus();
		elem.select();
		return true;
	}
	elem.style.backgroundColor="white";
	return false;
}


function isEmpty2(elem) {//z Alertem ze jest pole puste.
	var inputStr = elem.value;
	if (inputStr == null || inputStr == "") {
		elem.style.backgroundColor="palevioletred";
		elem.focus();
		elem.select();
		alert("Wypelnij "+elem.name);
		return true;
	}
	elem.style.backgroundColor="white";
	return false;
}

function isEmpty3(elem) {
	var inputStr = elem.value;
	if (inputStr == 0) {
		elem.style.backgroundColor="palevioletred";
		//elem.focus();
		//elem.select();
		return true;
	}
	elem.style.backgroundColor="white";
	return false;
}

function whiteBG(elem) {
	   elem.style.backgroundColor="white";
}

function isEMailAddr(elem,lang,p_email) {
	var str = elem.value;
	var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
	if (!str.match(re)) {
		elem.focus();
		elem.select();
	    elem.style.backgroundColor="palevioletred";
		if (lang=="ru" || lang=="pl")
		  {
		  alert(p_email);
		  }
		  else
		  {
		  alert("Please type your correct email address");
		  }
		return false;
	} else {
		whiteBG(elem);
		return true;
}
}

function isEMailAddr(elem,lang,p_email) {
	var str = elem.value;
	var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
	if (!str.match(re)) {
		elem.focus();
		elem.select();
	    elem.style.backgroundColor="palevioletred";
		if (lang=="ru" || lang=="pl")
		  {
		  alert(p_email);
		  }
		  else
		  {
		  alert("Please type your correct email address");
		  }
		return false;
	} else {
		whiteBG(elem);
		return true;
}
}


function isProfileID(elem) {
	var str = elem.value;
	var re = /^\D{2}\d+$/i;
	if (!str.match(re)) {
		elem.focus();
		elem.select();
	    elem.style.backgroundColor="palevioletred";
		return false;
	}
	return true;
}

function isDigit(elem) {
	var str = elem.value;
	var re = /^[1-9]+$/i;
	if (!str.match(re)) {
		elem.focus();
		elem.select();
	    elem.style.backgroundColor="palevioletred";
		return false;
	}
	return true;
}

function searchByID(elem) {
	var str = elem.value;
	var re = /^\w\w\d+$/;
	if (!str.match(re)) 
	{
		elem.focus();
		elem.select();
	    	elem.style.backgroundColor="palevioletred";
		alert("Please type a correct Profile ID (ex.RU23)");
		return false;
	} 
	else 
	{
		whiteBG(elem);
		return true;
	}
}

function validateSearch(form) {
	if (!isEmpty(form.bid)) 
	{
	searchByID(form.bid);	
	}
    return true;
}

function isFoto(elem){

var inputStr = elem.value;
	if (inputStr == null || inputStr == "") {
		return false;
	} else
	return true;

}
function copyMessage(lang){
if(lang=="pl")
alert("Copyright 2005 Slavic-romance. OSTRZE¯ENIE ! Zawarto¶æ tej witryny internetowej jest chroniona prawem autorskim. Nieupowa¿nione wykorzystywanie znajduj±cych siê tu materia³ów jest zabronione");
else
if(lang=="fr")
alert("Tous droits de reproduction et ou représentation réserves. Les textes et le logo Slavic-romance sont couverts par le droit de la propriété intellectualle. Copyright Slavic-romance 2005. Nous n'hésiteron pas à poursuivre en justice les personnes ou enterprises utilisant sans notre accord préalable les textes inscrits sur ce site ");
else
alert("Copyright 2005 Slavic-romance. WARNING ! All content containded within this site is protected by copyright laws. Unauthorized use of our material is strictly prohibited");
return false;

}


function validateAddProfileForm(form,lang,imie,nazwisko,telefon,email,pemail,adres,miasto,kod,oczy,wlosy,stan,religia,
				wyksztalcenie,jezyk,pije,pali,opiss,opiso,foto) {

var i=0;
/*	if (isEmpty(form.input1)) {
		alert("Musisz okresclic date przujazdu (DD-MM-YYYY)");
		return false;	}
	if (isEmpty(form.input2)) {
		alert("Musisz okresclic date wyjazdu (DD-MM-YYYY)");
		return false;	}
 if (!checkDate(form.input1,form.input2)) {
        return false;   }
*/


if (lang=="ru" || lang=="pl")
  {
	if (isEmpty(form.imie))
           {
 	   alert(imie);
           return false;
           }
           
	if (isEmpty(form.nazwisko))
           {
           alert(nazwisko);
           return false;
           }
         
/*        if (isEmpty(form.email_tel))
           {
           alert(telefon);
	   return false;
	   }
*/	   
        if (!isEMailAddr(form.email_kontakt,lang,pemail)) {return false;}

        if (isEmpty(form.adres))
           {
           alert(adres);
           return false;
           }

	if (isEmpty(form.miasto))
           {
           alert(miasto);
           return false;
           }

        if (isEmpty(form.kod))
           {
           alert(kod);
           return false;
           }
         
/*	if (!isBirdthDate(form.data_ur)){return false;}
	
        if (isEmpty3(form.narodowosc))
           {
           alert("Please choose your nationality");
           return false;
           }
/* 
       if (isEmpty(form.wzrost))
           {
           alert("Please type your height");
           return false;
           }

        if (isEmpty(form.waga))
           {
           alert("Please type your weight");
           return false;
           }
*/
        if (isEmpty3(form.oczy))
           {
           alert(oczy);
           return false;
           }

        if (isEmpty3(form.wlosy))
           {
           alert(wlosy);
           return false;
           }

        if (isEmpty3(form.stan_cywilny))
           {
           alert(stan);
           return false;
           }

        if (isEmpty3(form.religia))  
	   {
           alert(religia);
           return false;
           }

        if (isEmpty3(form.edukacja))
           {
           alert(wyksztalcenie);
           return false;
           }

        if (isEmpty3(form.jezyk_nar))
           {
           alert(jezyk);
           return false;
           }
	if (isEmpty3(form.czy_pije))
           {
           alert(pije);
           return false;
           }
	if (isEmpty3(form.czy_pali))
           {
           alert(pali);
           return false;
           }
	if (isEmpty3(form.wlasny_opis))
           {
           alert(opiss);
           return false;
           }
	if (isEmpty3(form.kogo_szuka))
           {
           alert(opiso);
           return false;
           }
	
	if (isFoto(form.profile)) i++;
	if (isFoto(form.foto1)) i++;
	if (isFoto(form.foto2)) i++;
	if (isFoto(form.foto3)) i++;
	if (isFoto(form.foto4)) i++;

	//alert(">"+i);
	if (i<2){ 
	for(i=0;i<2;i++)
	  if(isEmpty(form.foto1) || isEmpty(form.foto2) ||isEmpty(form.foto3) ||isEmpty(form.foto4)) 
	   {
		alert(foto);
		return false;
		break;
	   }
	}
/*
	if (isEmpty(form.email_tel))
           {
           if (confirm(telefon)) return false;
	    else return true;
	   }
*/	
/*	if (isEmpty(form.foto1))
           {
           alert(foto);
           return false;
           }
  	if (isEmpty(form.foto2))
           {
           alert(foto);
           return false;
           }

	if (form.regulamin.value=="nie") {
	    form.regulamin.style.backgroundColor="red";
		alert("Wybierz akceptacje regulaminu");
		return false;
	}
	whiteBG(form.regulamin);
*/
  }
  else
  {
	if (isEmpty(form.imie))
           {
	   
           alert("Please type your first name");
           return false;
           }
           
	if (isEmpty(form.nazwisko))
           {
           alert("Please type your last name");
           return false;
           }
	 
        
   /*     if (isEmpty(form.email_tel))
           {
           alert("Please type your phone number");
	   return false;
	   }*/
	   
        if (!isEMailAddr(form.email_kontakt,lang,pemail)) {return false;}

        if (isEmpty(form.adres))
           {
           alert("Pleae type your address");
           return false;
           }

	if (isEmpty(form.miasto))
           {
           alert("Please type your city");
           return false;
           }

        if (isEmpty(form.kod))
           {
           alert("Please type your ZIP Code");
           return false;
           }
         
//	if (!isBirdthDate(form.data_ur)){return false;}
	
        if (isEmpty3(form.narodowosc))
           {
           alert("Please choose your nationality");
           return false;
           }
/* 
       if (isEmpty(form.wzrost))
           {
           alert("Please type your height");
           return false;
           }

        if (isEmpty(form.waga))
           {
           alert("Please type your weight");
           return false;
           }
*/
        if (isEmpty3(form.oczy))
           {
           alert("Please choose the color of your eyes");
           return false;
           }

        if (isEmpty3(form.wlosy))
           {
           alert("Please choose the color of your hair");
           return false;
           }

        if (isEmpty3(form.stan_cywilny))
           {
           alert("Please choose your marital status");
           return false;
           }

        if (isEmpty3(form.religia))  
	   {
           alert("Please choose your religion");
           return false;
           }

        if (isEmpty3(form.edukacja))
           {
           alert("Please choose your education");
           return false;
           }

        if (isEmpty3(form.jezyk_nar))
           {
           alert("Please choose your native language");
           return false;
           }
	if (isEmpty3(form.czy_pije))
           {
           alert("Please choose the Drinking field");
           return false;
           }
	if (isEmpty3(form.czy_pali))
           {
           alert("Please choose the Smoking field");
           return false;
           }
	if (isEmpty3(form.wlasny_opis))
           {
           alert("Please describe Yourself");
           return false;
           }
	if (isEmpty3(form.kogo_szuka))
           {
           alert("Please describe the person You seek");
           return false;
           }
	if (isEmpty(form.profile))
           {
           alert("Please choose a pictures to upload");
           return false;
           }

	if (isFoto(form.foto1)) i++;
	if (isFoto(form.foto2)) i++;
	if (isFoto(form.foto3)) i++;
	if (isFoto(form.foto4)) i++;
	//alert(">"+i);
	if (i<2){ 
	for(i=0;i<2;i++)
	  if(isEmpty(form.foto1) || isEmpty(form.foto2) ||isEmpty(form.foto3) ||isEmpty(form.foto4)) 
	   {
		alert(foto);
		return false;
		break;
	   }
	}
/*	if (isEmpty(form.email_tel))
           {
           if (confirm("Would you like to type your phone number")) return false;
	    else return true;
	   }
*/
	if (form.regulamin.value=="nie") {
	    form.regulamin.style.backgroundColor="red";
		alert("Wybierz akceptacje regulaminu");
		return false;
	}
	whiteBG(form.regulamin);
  }
 
    return true;
}

function validateAddKontaktForm(form,lang,p_pemail) {
	
	if (isEmpty(form.message_name))           {
           alert("Please type your full name");
           return false;
           }
           
	if (!isEMailAddr(form.message_email,lang,p_pemail))           {
           
           return false;
           }
           
        if (isEmpty(form.message_))           {
           alert("Please type your message");
           return false;
           }
return true;
}

function validateAddPartnersForm(form) {
	
	if (isEmpty(form.message_name))           {
           alert("Please type your full name");
           return false;
           }
           
	if (!isEMailAddr(form.message_email))           {
           alert("Please type your email");
           return false;
           }
           
        if (isEmpty(form.message_))           {
           alert("Please type your message");
           return false;
           }
return true;
}

function validateBuyProfileByIDs(form) {
	var empty=true;
	for (i=0;i<form.length-1;i++) {
		if (form[i].value != null && form[i].value != "") {
			if (!isProfileID(form[i])) {
					alert("Wrong profile number: "+form[i].value+" e.g. PL22.");
					return false;
			}
			empty=false;
		}    	
	}
	if (empty==true) {
		alert("Please give at least one profile");
		return false;
	}
return true;
}


function validateServcie1(form) {
	empty=true;
	for (i=0;i<form.length-1;i++) {
		if (form[i].value != null && form[i].value != "") {
			if (!isDigit(form[i])) {
					alert("Field:( "+form[i].value+") must be number e.g. 2.");
					return false;
			}
			empty=false;
		}    	
	}
	if (empty==true) {
		alert("Please give at least one number");
		return false;
	}
}

function validateServcie2(form,profiles) {
	empty=true;

	for (i=0;i<form.length-1;i++) {
		if (form[i].type=="text") {
			if (form[i].value != null && form[i].value != "") {
				if (!isProfileID(form[i])) {
					alert("Wrong profile number: "+form[i].value+" e.g RU212.");
					return false;
				}else	{
					 if (!(new String(profiles.toString()).match(form[i].value))) {
						form[i].focus();
				                form[i].select();
					        form[i].style.backgroundColor="palevioletred";
						alert("You don't bought profiler: "+form[i].value+".");
						return false;
							
					}
					
				}
				empty=false;
			}    	
		}
	}
	if (empty==true) {
		alert("Please give at least one profile");
		return false;
	}
}

function validateBulildMail(form) {
	var empty=true;
	for (i=0;i<form.length-1;i++) {
		if (form[i].checked) {
			empty=false;
		}    	
	}
	if (empty==true) {
		alert("Please give at least one profile");
		return false;
	}
return true;
}



function validateFavouritesForm(form) {
	var empty=true;
	for (i=0;i<form.length-1;i++) {
		if (form[i].checked) empty=false;
	}
	if (empty==true) {
		alert("Please give at least one profile");
		return false;
	}
return true;
}



function validateAddKlientForm(form,lang,imie,nazwisko,telefon,email,pemail,adres,kod,miasto) {
if(lang == "en")
  {
	if (isEmpty(form.imie))           {
           alert("Please type your first name");
           return false;
           }
           
	if (isEmpty(form.nazwisko))           {
           alert("Please type your last name");
           return false;
           }
           
        if (isEmpty(form.telefon))           {
           alert("Please type your phone number");
           return false;
           }
	if (isEmpty(form.email))           {
           alert("Please type your email");
           return false;
           }
	if (isEmpty(form.re_email))           {
           alert("Please repeat your email");
           return false;
           }
	if (not_equal_mail(form.email, form.re_email))           {
           alert("Your email and repeated email are not equal");
           return false;
           }
	if (isEmpty(form.adres))
           {
           alert("Please type your address");
           return false;
           }
	 if (isEmpty(form.kod))
           {
           alert("Please type your zip code");
           return false;
           }
        
	if (isEmpty(form.miasto))
           {
           alert("Please type your city");
           return false;
           }
   }
    else
   {
	if (isEmpty(form.imie))
           {
 	   alert(imie);
           return false;
           }
           
	if (isEmpty(form.nazwisko))
           {
           alert(nazwisko);
           return false;
           }
         
        if (isEmpty(form.telefon))
           {
           alert(telefon);
	   return false;
	   }
	 if (isEmpty(form.email)){
           alert(email);
           return false;
           }
	if (isEmpty(form.re_email)){
           alert(pemail);
           return false;
           }
	if (not_equal_mail(form.email, form.re_email)){
           alert(pemail);
           return false;
           }
 	if (isEmpty(form.adres))
           {
           alert(adres);
           return false;
           }
	 if (isEmpty(form.kod))
           {
           alert(kod);
           return false;
           }
	if (isEmpty(form.miasto))
           {
           alert(miasto);
           return false;
           }
     
/*        if (!isEMailAddr(form.email)) {return false;}

	if (form.regulamin.value=="nie") {
	    form.regulamin.style.backgroundColor="red";
		alert("Wybierz akceptacje regulaminu");
		return false;
	}*/
//	whiteBG(form.regulamin);
  }
    return true;}


function validateSearchForm(form) {

	 if ((form.age_from.value)!=(form.age_to.value)) {
            alert("Age FROM are bigger than TO");
            return false;
	}

    return true;
}

function checkage(first,secund,k) {
	var drugi=document.getElementById(secund);
	if (k==true && drugi.value<first.value) 
		drugi.value=first.value;
	if (k==false && drugi.value>first.value) 
		first.value=drugi.value;
	//alert(first.value+" "+drugi.value);
}


function openFullscreen(page)
{
var yes = 1;
var no = 0;

var menubar = yes;      // The File, Edit, View Menus
var scrollbars = yes;   // Horizontal and vertical scrollbars
var locationbar = no;  // The location box with the site URL
var directories = no;  // the "What's New", "What Cool" links
var resizable = yes;    // Can the window be resized?
var statusbar = no;    // Status bar (with "Document: Done")
var toolbar = yes;      // Back, Forward, Home, Stop toolbar

windowprops = "width=" + (screen.width-10) + ",height=" + (screen.height-90) + ",top=0,left=0";

windowprops += (menubar ? ",menubars" : "") +
(scrollbars ? ",scrollbars" : "") +
(locationbar ? ",location" : "") +
(directories ? ",directories" : "") +
(resizable ? ",resizable" : "") +
(statusbar ? ",status" : "") +
(toolbar ? ",toolbar" : "");

window.open(page,'', windowprops);
}


