var f="";
function hov(loc,cls){
   if(loc.className)
      loc.className=cls;}

function onColor(blah){ blah.style.backgroundColor='#E0C0C0';} //FCBBCB'; }

function offColor(blah){ blah.style.backgroundColor='#F0F0F0'; }

function checkLength(field,maxLetters,pmes) {
	var len = field.value.length;
	if (len > maxLetters) {
		field.value = field.value.substr(0,maxLetters);
		alert(pmes+' ' + maxLetters + '.');
	}
}

var popUpWin=0;
function popUpWindow(URLStr,p){
  var width=580;
  var height=600;
  if (p==1) height=300; 
  var left=(screen.width-width)/2;
  var top=(screen.height-height)/2;
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  
  if (height==300)
  {  
   	  popUpWin = window.open(URLStr,"","height="+height+",width="+width+",top="+top+",left="+left+",location=no,menubar=no,resizable=no,scrollbars=no,status=no,titlebar=no,toolbar=no,directories=no");
  	  return;
  }

  if (screen.height>600) 
  {	  
  	  popUpWin = window.open(URLStr,"","height="+height+",width="+width+",top="+top+",left="+left+",location=no,menubar=no,resizable=no,scrollbars=yes,status=no,titlebar=no,toolbar=no,directories=no");
  	  return;
  }
  popUpWin = window.open(URLStr,"","height=520 ,width="+width+",top="+top+",left="+left+",location=no,menubar=no,resizable=no,scrollbars=yes,status=no,titlebar=no,toolbar=no,directories=no");  
}

function popUp(URLStr,w,h){
  if (w > screen.width) w=screen.width*9/10;
  if (h > screen.height) w=screen.height*9/10;
  var width=w+20;
  var height=h+20;
  var left=(screen.width-width)/2;
  var top=(screen.height-height)/2;
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = window.open(URLStr,"","height="+height+" ,width="+width+",top="+top+",left="+left+",location=no,menubar=no,resizable=no,scrollbars=no,status=no,titlebar=no,toolbar=no,directories=no");  
}


function ViewAgreement(p){
	var openedWindow = window.open( 'dating-agreement-' + p + '.php?p=show', 'Regulament','toolbar=no,location=0,directories=no,status=no,width=850,height=500,resizable=no,top=100,left=100,scrollbars=yes');

	openedWindow.focus();
}

function ViewMark(){
	var openedWindow = window.open( "relationships-alert.php", "Alert", 'width=550,height=220,resizable=no,scrollbars=no,menubar=no,align=center,status=no,titlebar=no,toolbar=no,directories=no');
	openedWindow.focus();
}

function VerifyMessage(form,m){
	var v=form.mes.value;
	if (v.length==0)
	{
	  alert(m);
	  return false;
	}
	form.operation.value="s";
	return true;
}


function chkStringValue(checkStr){
var checkOK = "0123456789abcdefghijklmnoprstuvwxyz-.'";
var allValid = true;
var decPoints = 0;
var allNum = "";
checkStr=checkStr.toLowerCase();	
for (i = 0;  i < checkStr.length;  i++){
	ch = checkStr.charAt(i);
	for (j = 0;  j < checkOK.length;  j++)
	if (ch == checkOK.charAt(j))
		break;
	if (j == checkOK.length){
		allValid = false;
		break;
	}
	if (ch != ",")
		allNum += ch;
	}
	if (!allValid){	
		alertsay = "Trebuie sa introduci numai caractere  \""
		alertsay = alertsay + checkOK + "\" in acest camp!"
		alert(alertsay);
		return (false);
	}
	return (true)
}

function UnCheckTop(form_object) {
	form_object[0].checked = false;
}

function UnCheckAll(form_object,n) {
    if (form_object[0].checked == true)
	for (var i=1;i<=n;i++)
	form_object[i].checked = false;
}

function Checki(form_object,i) {
	form_object[i].checked = true;
}

function Checked(form_object,n) {
	return form_object[n].checked;
}

function valid(form_objectn,n,form_objecth){
form_objecth.value="";
var first="0";
for (var i=0;i<n;i++){
   if (Checked(form_objectn,i)==1){
	   if (i==0) first="1";
	   form_objecth.value=form_objecth.value+"1";
   }
   else{
	   form_objecth.value=form_objecth.value+first;
	}
}
}

function validall(){
	valid(document.f.DesiredSmoker,6,document.f.HDesiredSmoker);
	valid(document.f.DesiredHasChildren,4,document.f.HDesiredHasChildren);
	valid(document.f.DesiredMaritalStatus,5,document.f.HDesiredMaritalStatus);
}

function validalls(){

/*BodyType
HairColor
EysColor
HasChildren
WantChildren
Smoker
SearchRelation
Religion
RecordDate*/

valid(document.f.MaritalStatus,6,document.f.HMaritalStatus);
valid(document.f.BodyType,7,document.f.HBodyType);
valid(document.f.HairColor,8,document.f.HHairColor);
valid(document.f.EysColor,7,document.f.HEysColor);
valid(document.f.HasChildren,4,document.f.HHasChildren);
valid(document.f.WantChildren,4,document.f.HWantChildren);
valid(document.f.Smoker,6,document.f.HSmoker);
//valid(document.p.SearchRelation,7,document.p.HSearchRelation);
valid(document.f.Religion,11,document.f.HReligion);

}
