gulOpened = false;
//------------------------------------------------------------------------------
function showTerms ()
{
  var url = "/terms.php";
  var parameters;
  parameters = "";
  parameters += "toolbar=0,";
  parameters += "location=0,";
  parameters += "directories=0,";
  parameters += "status=0,";
  parameters += "menubar=0,";
  parameters += "scrollbars=0,";
  parameters += "resizable=1,";
  parameters += "width=500,";
  parameters += "height=350";
  window.open (url, "_blank", parameters);
}
//------------------------------------------------------------------------------
function validateDataRegistration()
{
  var f = document.forms['registrationform'];
  var msg = "";
  var country = f.cboCountry.options[f.cboCountry.selectedIndex].text;
  var invalidInput = null;
  

  if (isNaN(f.txtICQ.value)) {invalidInput = f.txtICQ}
  if (f.txtEmail.value != f.txtEmail2.value) {invalidInput = f.txtEmail2}
  if (confirmEmail(f.txtEmail.value)) {invalidInput = f.txtEmail}
  if (f.txtZip.value == "") {invalidInput = f.txtZip}
  if (f.txtCity.value == "") {invalidInput = f.txtCity}
  if ((f.txtState.value == "") && ((country == "United States") || (country == "Canada"))) {invalidInput = f.txtState}
  if (f.cboCountry.selectedIndex == 0) {invalidInput = f.cboCountry}
  if (f.cboBdayYear.selectedIndex == 0) {invalidInput = f.cboBdayYear}
  if (f.cboBdayDay.selectedIndex == 0) {invalidInput = f.cboBdayDay}
  if (f.cboBdayMonth.selectedIndex == 0) {invalidInput = f.cboBdayMonth}
  if (f.cboSexuality.selectedIndex == 0) {invalidInput = f.cboSexuality}
  if (f.cboGender.selectedIndex == 0) {invalidInput = f.cboGender}
  //if (f.txtLastName.value == "") {invalidInput = f.txtLastName}
  if (f.txtFirstName.value == "") {invalidInput = f.txtFirstName}
  if (f.txtNickname.value == "") {invalidInput = f.txtNickname}
  if (CheckForInvalidChar(f.txtPassword.value, " ")) {invalidInput = f.txtPassword}
  if (f.txtPassword.value.length < 6) {invalidInput = f.txtPassword}
  if (f.txtPassword.value.toLowerCase() == f.txtLogin.value.toLowerCase()) {invalidInput=f.txtPassword}
  if (CheckForNonAlphanumeric(f.txtLogin.value)) {invalidInput = f.txtLogin}
  if (f.txtLogin.value == "") {invalidInput = f.txtLogin}
  if (!isNaN(f.txtLogin.value)) {invalidInput = f.txtLogin}
  if ((f.txtLogin.value.length < 3) || (f.txtLogin.value.length > 30)) {invalidInput = f.txtLogin}

  if (invalidInput != null)
  {
    msg="Oops, you have forgotten something or made a mistake!";

    if(invalidInput == f.cboGender)
    {
      msg = "Please select your gender."
    }
    if(invalidInput == f.cboSexuality)
    {
      msg = "Please select your sexuality."
    }
    if(invalidInput == f.cboBdayMonth)
    {
      msg = "Please select your birthday month."
    }
    if(invalidInput == f.cboBdayDay)
    {
      msg = "Please select your birthday day."
    }
    if(invalidInput == f.cboBdayYear)
    {
      msg = "Please select your birthday year."
    }
    if(invalidInput == f.cboCountry)
    {
      msg = "Please select your country."
    }
    if(invalidInput == f.txtICQ)
    {
      msg = "ICQ number should be entirely numeric."
    }
    if(invalidInput == f.txtState)
    {
      msg = "Please enter your state."
    }
    if(invalidInput == f.txtZip)
    {
      msg = "Please enter your postal code."
    }
    if(invalidInput == f.txtCity)
    {
      msg = "Please enter your city."
    }
    if(invalidInput == f.txtFirstName)
    {
      msg = "Please enter your first name."
    }
    //if(invalidInput == f.txtLastName)
    //{
    //  msg = "Please enter your last name."
    //}
    if(invalidInput == f.txtNickname)
    {
      msg = "Please enter your nickname."
    }
    if(invalidInput == f.txtLogin)
    {
      msg = "Please enter your login. It cannot contain spaces or punctuation, nor can it be entirely numeric.\nYour login can have a maximum of 30 characters only and a minimum of 3."
    }
    if(invalidInput == f.txtPassword)
    {
      msg = "There is a problem with your password. It must include AT LEAST 6 characters and cannot include any spaces. It must be different from your login.";
    }
    if(invalidInput == f.txtEmail)
    {
      msg = confirmEmail(f.txtEmail.value)
    }
    if(invalidInput == f.txtEmail2)
    {
      msg = "Emails doesn't match.";
    }

    alert(msg);
    invalidInput.focus();
  }
  else
  {
    f.SubmitRegistration.disabled = true;
    return true;
  }
  return false;
}
//------------------------------------------------------------------------------
function validateDataProfile()
{
  var f = document.forms['profileform'];
  var msg = "";
  var country = f.cboCountry.options[f.cboCountry.selectedIndex].text;
  var invalidInput = null;

  if (f.txtareaMoreAboutPartner.value.length > 1000) {invalidInput = f.txtareaMoreAboutPartner}
  if (f.txtareaFavFilms.value.length > 255) {invalidInput = f.txtareaFavFilms}
  if (f.txtareaFavMusic.value.length > 255) {invalidInput = f.txtareaFavMusic}
  if (f.txtareaFavBooks.value.length > 255) {invalidInput = f.txtareaFavBooks}
  if (f.txtareaWhatGetsMeHot.value.length > 255) {invalidInput = f.txtareaWhatGetsMeHot}
  if (f.txtareaLostVirginity.value.length > 255) {invalidInput = f.txtareaLostVirginity}
  if (f.txtareaMyFavSexPosition.value.length > 255) {invalidInput = f.txtareaMyFavSexPosition}
  if (f.txtareaMyFantasyIs.value.length > 255) {invalidInput = f.txtareaMyFantasyIs}
  if (f.txtareaMoreAboutYou.value.length > 1000) {invalidInput = f.txtareaMoreAboutYou}
  if (isNaN(f.txtWeightKilos.value)) {invalidInput = f.txtWeightKilos}
  if (isNaN(f.txtWeightPounds.value)) {invalidInput = f.txtWeightPounds}
  if (isNaN(f.txtHeightCm.value)) {invalidInput = f.txtHeightCm}
  if (isNaN(f.txtHeightInches.value)) {invalidInput = f.txtHeightInches}
  if (isNaN(f.txtHeightFeet.value)) {invalidInput = f.txtHeightFeet}
  if (isNaN(f.txtICQ.value)) {invalidInput = f.txtICQ}
  if (confirmEmail(f.txtEmail.value)) {invalidInput = f.txtEmail}
  if (f.txtZip.value == "") {invalidInput = f.txtZip}
  if (f.txtCity.value == "") {invalidInput = f.txtCity}
  if ((f.txtState.value == "") && ((country == "United States") || (country == "Canada"))) {invalidInput = f.txtState}
  if (f.cboCountry.selectedIndex == 0) {invalidInput = f.cboCountry}
  if (f.cboBdayYear.selectedIndex == 0) {invalidInput = f.cboBdayYear}
  if (f.cboBdayDay.selectedIndex == 0) {invalidInput = f.cboBdayDay}
  if (f.cboBdayMonth.selectedIndex == 0) {invalidInput = f.cboBdayMonth}
  if (f.cboSexuality.selectedIndex == 0) {invalidInput = f.cboSexuality}  
  if (f.cboGender.selectedIndex == 0) {invalidInput = f.cboGender}
  //if (f.txtLastName.value == "") {invalidInput = f.txtLastName}
  if (f.txtFirstName.value == "") {invalidInput = f.txtFirstName}
  if (f.txtNickname.value == "") {invalidInput = f.txtNickname}
  if (CheckForInvalidChar(f.txtPassword.value, " ")) {invalidInput = f.txtPassword}
  if (f.txtPassword.value.length < 6) {invalidInput = f.txtPassword}
  if (f.txtPassword.value.toLowerCase() == f.txtLogin.value.toLowerCase()) {invalidInput=f.txtPassword}
  if (CheckForNonAlphanumeric(f.txtLogin.value)) {invalidInput = f.txtLogin}
  if (f.txtLogin.value == "") {invalidInput = f.txtLogin}
  if (!isNaN(f.txtLogin.value)) {invalidInput = f.txtLogin}

  if (invalidInput != null)
  {
    msg="Oops, you have forgotten something or made a mistake!";

    if(invalidInput == f.cboGender)
    {
      msg = "Please select your gender."
    }
    if(invalidInput == f.cboSexuality)
    {
      msg = "Please select your sexuality."
    }
    if(invalidInput == f.cboBdayMonth)
    {
      msg = "Please select your birthday month."
    }
    if(invalidInput == f.cboBdayDay)
    {
      msg = "Please select your birthday day."
    }
    if(invalidInput == f.cboBdayYear)
    {
      msg = "Please select your birthday year."
    }
    if(invalidInput == f.cboCountry)
    {
      msg = "Please select your country."
    }
    if(invalidInput == f.txtICQ)
    {
      msg = "ICQ number should be entirely numeric."
    }
    if(invalidInput == f.txtState)
    {
      msg = "Please enter your state."
    }
    if(invalidInput == f.txtZip)
    {
      msg = "Please enter your postal code."
    }
    if(invalidInput == f.txtCity)
    {
      msg = "Please enter your city."
    }
    if(invalidInput == f.txtFirstName)
    {
      msg = "Please enter your first name."
    }
    //if(invalidInput == f.txtLastName)
    //{
    //  msg = "Please enter your last name."
    //}
    if(invalidInput == f.txtNickname)
    {
      msg = "Please enter your nickname."
    }


    if(invalidInput == f.txtLogin)
    {
      msg = "Please enter your login. It cannot contain spaces or punctuation, nor can it be entirely numeric."
    }
    if(invalidInput == f.txtPassword)
    {
      msg = "There is a problem with your password. It must include AT LEAST 6 characters and cannot include any spaces. It must be different from your login.";
    }
    if(invalidInput == f.txtEmail)
    {
      msg = confirmEmail(f.txtEmail.value)
    }

    if(invalidInput == f.txtHeightFeet)
    {
      msg = "Please enter your height. It should be entirely numeric."
    }
    if(invalidInput == f.txtHeightInches)
    {
      msg = "Please enter your height. It should be entirely numeric."
    }
    if(invalidInput == f.txtHeightCm)
    {
      msg = "Please enter your height. It should be entirely numeric."
    }

    if(invalidInput == f.txtWeightKilos)
    {
      msg = "Please enter your weight. It should be entirely numeric."
    }
    if(invalidInput == f.txtWeightPounds)
    {
      msg = "Please enter your weight. It should be entirely numeric."
    }

    if(invalidInput == f.txtareaMoreAboutYou)
    {
      msg = "Information about you is too long! You have entered " + f.txtareaMoreAboutYou.value.length + " symbols!"
    }
    if(invalidInput == f.txtareaMyFantasyIs)
    {
      msg = "Information about your fantasy is too long! You have entered " + f.txtareaMyFantasyIs.value.length + " symbols!"
    }
    if(invalidInput == f.txtareaMyFavSexPosition)
    {
      msg = "Information about your favorite sexual position is too long! You have entered " + f.txtareaMyFavSexPosition.value.length + " symbols!"
    }
    if(invalidInput == f.txtareaLostVirginity)
    {
      msg = "Information about your losten virginity is too long! You have entered " + f.txtareaLostVirginity.value.length + " symbols!"
    }
    if(invalidInput == f.txtareaWhatGetsMeHot)
    {
      msg = "Information about what gets you hot is too long! You have entered " + f.txtareaWhatGetsMeHot.value.length + " symbols!"
    }
    if(invalidInput == f.txtareaFavBooks)
    {
      msg = "Information about your favorite book(s) is too long! You have entered " + f.txtareaFavBooks.value.length + " symbols!"
    }
    if(invalidInput == f.txtareaFavMusic)
    {
      msg = "Information about your favorite band or musician(s) is too long! You have entered " + f.txtareaFavMusic.value.length + " symbols!"
    }
    if(invalidInput == f.txtareaFavFilms)
    {
      msg = "Information about your favorite film(s) is too long! You have entered " + f.txtareaFavFilms.value.length + " symbols!"
    }
    if(invalidInput == f.txtareaMoreAboutPartner)
    {
      msg = "Information about your partner is too long! You have entered " + f.txtareaMoreAboutPartner.value.length + " symbols!"
    }

    alert(msg);
    invalidInput.focus();
  }
  else
  {
    return true;
  }
  return false;
}
//------------------------------------------------------------------------------
function validateDataPictureUpload()
{
  var f = document.forms['galleryform'];
  var msg = "";
  var invalidInput = null;

  var end_of_filename = f.PictureFile.value.toLowerCase();
  end_of_filename = end_of_filename.substring(end_of_filename.length - 4, end_of_filename.length);

  if ((end_of_filename != ".jpg") && (end_of_filename != "jpeg")) {invalidInput = f.PictureFile};
  if (f.txtPhotoName.value.length > 50) {invalidInput = f.txtPhotoName};

  if (invalidInput != null)
  {
    msg="Oops, you have forgotten something or made a mistake!";

    if(invalidInput == f.txtPhotoName)
    {
      msg = "Name of picture is too long! You have entered " + f.txtPhotoName.value.length + " symbols!";
    }
    if(invalidInput == f.PictureFile)
    {
      msg = "Allowed picture format is jpeg";
    }


    if(msg != "") 
    {
      alert(msg);
    }
    invalidInput.focus();
  }
  else
  {
    return true;
  }
  return false;
}
//------------------------------------------------------------------------------
function validateBugReport()
{
  var f = document.forms['bugreport'];
  var msg = "";
  var invalidInput = null;

  if (f.txtareaMessageText.value == "") {invalidInput = f.txtareaMessageText}
  if (confirmEmail(f.txtEmail.value)) {invalidInput = f.txtEmail}

  if (invalidInput != null)
  {
    msg="Oops, you have forgotten something or made a mistake!";

    if(invalidInput == f.txtEmail)
    {
      msg = confirmEmail(f.txtEmail.value)
    }

    if(invalidInput == f.txtareaMessageText)
    {
      msg = "Please enter your message text.";
    }

    alert(msg);
    invalidInput.focus();
  }
  else
  {
    return true;
  }
  return false;
}
//------------------------------------------------------------------------------
function validateComment()
{
  if (txtMessage.value == "")
  {
    alert("Please enter your comment");
    txtMessage.focus();
    return false;
  }

  tmpString = txtMessage.value;

  flag = false;

  while ((tmpString.indexOf(" ") > -1) || (tmpString.indexOf("\r\n") > -1))
  {
    if (tmpString.indexOf(" ") == -1)
    {
      SpecialSymbol = "\r\n";
    }
    else
    {
      if (tmpString.indexOf("\r\n") == -1)
      {
        SpecialSymbol = " ";
      }
      else
      {
        if (tmpString.indexOf(" ") < tmpString.indexOf("\r\n"))
        {
          SpecialSymbol = " ";
        }    
        else
        {
          SpecialSymbol = "\r\n";
        }
      }
    }

    tmpString2 = tmpString.substring(0, tmpString.indexOf(SpecialSymbol));
    tmpString = tmpString.substring(tmpString.indexOf(SpecialSymbol) + SpecialSymbol.length, tmpString.length);

    if (tmpString2.length > 40)
    {
      flag = true;
      break;
    }
  }
  if (tmpString.length > 40)
  {
    flag = true;
  }
  if (flag)
  {
    alert("Length of word in your message couldn't be more than 40 symbols");
    f.txtMessage.focus();
    return false;
  }

  return true;
}
//------------------------------------------------------------------------------
function validateDataSearch()
{
  var f = document.forms['searchform'];

  if ((f.cboAgeFrom.value > f.cboAgeTo.value) && (f.cboAgeTo.value != 0))
  {
    alert("Please correct age values!");
    f.cboAgeFrom.focus();
    return false;
  }

  return true;
}
//------------------------------------------------------------------------------
function confirmEmail(strEmail)
{
  var indexAt = strEmail.indexOf("@");
  if (indexAt == -1)
  {
    return "Missing @ sign, expecting address like myname@myisp.com";
  }
  else
  {
    var saEmail = strEmail.split("@");
    if (saEmail.length > 2)
    {
      return "Too many @ signs, expecting address like myname@myisp.com";
    }
    else
    {
      if (saEmail[0].length == 0)
      {
	return "Name too short, expecting address like myname@myisp.com";
      }
      else
      {
        if (saEmail[1].length == 0)
	{
	  return "Domain name too short, expecting address like myname@myisp.com";
	}
	else
	{
	  if ((saEmail[1].indexOf(".") == -1) |
	      (saEmail[1].indexOf(".") == 0) |
	      (saEmail[1].indexOf(".") == (saEmail[1].length - 1)))
	  {
	    return "Domain name invalid, expecting address like myname@myisp.com";
	  }
	  else
	  {
	    return "";
	  }
	}
      }
    }
  }
}
//------------------------------------------------------------------------------
function CheckForInvalidChar(sField, sInvalidList)
{
  /* check for invalid chars */
  for (i=0; i<sInvalidList.length; i++)
  {
    lvChar = sInvalidList.charAt(i);
    if (sField.indexOf(lvChar) > -1)
    {
      return true;
    }
  }
  return false;
}
//------------------------------------------------------------------------------
function CheckForNonAlphanumeric(sField)
{
  for (i=0; i<sField.length; i++)
  {
    var asc = sField.charCodeAt(i);
    if (((asc >= 48) && (asc <= 57)) || ((asc >= 65) && (asc <= 90)) || ((asc >= 97) && (asc <= 122)))
    {
    }
    else
    {
      return true;
    }
  }
  return false;
}
//------------------------------------------------------------------------------
function findObj(id)
{
  if(document.all)
  {
    return document.all[id];
  }
  else
  {
    return document.getElementById(id);
  }
}
//------------------------------------------------------------------------------
function validateSexTest1()
{
  var f = document.forms['sextest1'];
  var msg = "";
  var invalidInput = null;

  if (confirmEmail(f.txtEmail.value)) {invalidInput = f.txtEmail}
  if (!f.radio_gender_1.checked && !f.radio_gender_2.checked) {invalidInput = f.radio_gender_1}
  if (f.cboBdayYear.selectedIndex == 0) {invalidInput = f.cboBdayYear}
  if (f.cboBdayDay.selectedIndex == 0) {invalidInput = f.cboBdayDay}
  if (f.cboBdayMonth.selectedIndex == 0) {invalidInput = f.cboBdayMonth}
  if (f.txtFullName.value == "") {invalidInput = f.txtFullName}

  if (invalidInput != null)
  {
    msg="Oops, you have forgotten something or made a mistake!";

    if(invalidInput == f.txtEmail)
    {
      msg = confirmEmail(f.txtEmail.value)
    }
    if(invalidInput == f.radio_gender_1)
    {
      msg = "Please select your gender."
    }
    if(invalidInput == f.cboBdayYear)
    {
      msg = "Please select your birthday year."
    }
    if(invalidInput == f.cboBdayDay)
    {
      msg = "Please select your birthday day."
    }
    if(invalidInput == f.cboBdayMonth)
    {
      msg = "Please select your birthday month."
    }
    if(invalidInput == f.txtFullName)
    {
      msg = "Please enter your full name."
    }

    alert(msg);
    invalidInput.focus();
  }
  else
  {
    return true;
  }
  return false;
}
//------------------------------------------------------------------------------
function validateSexTest2()
{
  var f = document.forms['qst'];
  var msg = "";
  var invalidInput = null;
  
  if (f.cboMySize.selectedIndex == 0) {invalidInput = f.cboMySize}
  if (!f.radio_dream_friend_1.checked && !f.radio_dream_friend_2.checked) {invalidInput = f.radio_dream_friend_1}
  if (f.radio_dream_friend_1.checked)
  {
    if (!f.radio_dream_friend_sex_1.checked && !f.radio_dream_friend_sex_2.checked) {invalidInput = f.radio_dream_friend_sex_1}
    if (f.txtDreamFriendName.value == "") {invalidInput = f.txtDreamFriendName}
  }
  if (!f.radio_sex_homo_1.checked && !f.radio_sex_homo_2.checked) {invalidInput = f.radio_sex_homo_1}
  if (!f.radio_have_homo_1.checked && !f.radio_have_homo_2.checked) {invalidInput = f.radio_have_homo_1}
  if (f.cboSexTest.selectedIndex == 0) {invalidInput = f.cboSexTest}
  if (!f.radio_have_porno_1.checked && !f.radio_have_porno_2.checked) {invalidInput = f.radio_have_porno_1}
  if (f.radio_have_porno_1.checked)
  {
    if (f.cboPornoInterest.selectedIndex == 0) {invalidInput = f.cboPornoInterest}
  }
  if (f.cboHowMuchMasturbate.selectedIndex == 0) {invalidInput = f.cboHowMuchMasturbate}
  if (!f.radio_sex_ok_1.checked && !f.radio_sex_ok_2.checked) {invalidInput = f.radio_sex_ok_1}
  if (!f.radio_have_friend_1.checked && !f.radio_have_friend_2.checked) {invalidInput = f.radio_have_friend_1}
  if (f.radio_have_friend_1.checked)
  {
    if (!f.radio_friend_infidelity_1.checked && !f.radio_friend_infidelity_2.checked) {invalidInput = f.radio_friend_infidelity_1}
    if (f.txtFriendName.value == "") {invalidInput = f.txtFriendName}
  }
  if (f.cboFirstSex.selectedIndex == 0) {invalidInput = f.cboFirstSex}
  else
  {
    if (f.cboFirstSex.selectedIndex != 1)
    {
      if (f.cboSexLong.selectedIndex == 0) {invalidInput = f.cboSexLong}
      if (f.cboHowMuchOrgasm.selectedIndex == 0) {invalidInput = f.cboHowMuchOrgasm}
      if (f.cboHowMuchSex.selectedIndex == 0) {invalidInput = f.cboHowMuchSex}
      if (f.cboHavePartnerNow.selectedIndex == 0) {invalidInput = f.cboHavePartnerNow}
      if (f.cboHavePartner.selectedIndex == 0) {invalidInput = f.cboHavePartner}
    }
  }

  if (invalidInput != null)
  {
    msg="Oops, you have forgotten something!";
    alert(msg);
    invalidInput.focus();
  }
  else
  {
    return true;
  }
  return false;
}
//------------------------------------------------------------------------------
// sajax functions
function startRequestUrl(url, c_id) 
	{
	var xmlHttp = false; 

        if (window.XMLHttpRequest) { xmlHttp = new XMLHttpRequest(); }
	else if (window.ActiveXObject) { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); }
	
	if (xmlHttp) 
		{
                xmlHttp.open("GET", url, true);
                xmlHttp.onreadystatechange = function() {
	        if(xmlHttp.readyState == 4) {
		if(xmlHttp.status == 200) {
                if (xmlHttp.responseText.length > 0) {
		document.getElementById("comm"+c_id).innerHTML = xmlHttp.responseText;
//		window.location.hash = "#comm";
		}
                delete xmlHttp;
		xmlHttp = null;
	        }}}

		xmlHttp.send(null);
		}
	}
//--------------------------------------------------------------------------------
function commentPost(url, data) 
	{
	var xmlHttp = false; 

        if (window.XMLHttpRequest) { xmlHttp = new XMLHttpRequest(); }
	else if (window.ActiveXObject) { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); }
//alert(data);	
	if (xmlHttp) 
		{
                xmlHttp.open("POST", url);
		xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
                xmlHttp.setRequestHeader('Charset', 'utf-8')
		xmlHttp.onreadystatechange = function() {
	        if(xmlHttp.readyState == 4) { if 
		(xmlHttp.status == 200) 
			{
			if (act.value == "post_comment") { 
			document.getElementById("commentp").innerHTML = xmlHttp.responseText; 
//			alert(xmlHttp.responseText); 
			}
			if (act.value == "answer_comment") { document.getElementById("comm"+a_id.value+"a").innerHTML = xmlHttp.responseText; }
			if (act.value == "post_answer") { document.getElementById("comm"+a_id.value+"a").innerHTML = xmlHttp.responseText; }
//			alert(data);
			}
                delete xmlHttp;
		xmlHttp = null;
	        }}

		xmlHttp.send(data);
		}
	}
//--------------------------------------------------------------------------------
function each(object, callback) {
var name, i = 0, length = object.length;

if ( length === undefined ) {
for ( name in object )
if ( callback.call( object[ name ], name, object[ name ] ) === false )
break;
} else
for ( var value = object[0];
i < length && callback.call( value, i, value ) !== false; value = object[++i] ){}

return object;
};
//-------------------------------------------------------------
function ge() {
var ea;
for (var i = 0; i < arguments.length; i++) {
var e = arguments[i];
if (typeof e == 'string')
e = document.getElementById(e);
if (arguments.length == 1)
return e;
if (!ea)
ea = new Array();
ea.push(e);
}
return ea;
}
//--------------------------------------------------------------------------------
function geByClass(searchClass, node, tag) {
var classElements = new Array();
if ( node == null )
node = document;
if ( tag == null )
tag = '*';
if (node.getElementsByClassName) {
classElements = node.getElementsByClassName(searchClass);
if (tag != '*') {
for (i = 0; i < classElements.length; i++) {
if (classElements.nodeName == tag)
classElements.splice(i, 1);
}
}
return classElements;
}
var els = node.getElementsByTagName(tag);
var elsLen = els.length;
var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
for (i = 0, j = 0; i < elsLen; i++) {
if ( pattern.test(els[i].className) ) {
classElements[j] = els[i];
j++;
}
}
return classElements;
}
//-------------------------
function setCover(url, act, aid, pid) 
	{
	var xmlHttp = false; 

        if (window.XMLHttpRequest) { xmlHttp = new XMLHttpRequest(); }
	else if (window.ActiveXObject) { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); }
	if (xmlHttp) 
		{
                xmlHttp.open("POST", url);
		xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
                xmlHttp.setRequestHeader('Charset', 'utf-8')
		xmlHttp.onreadystatechange = function() {
	        if(xmlHttp.readyState == 4) { if 
		(xmlHttp.status == 200 && xmlHttp.responseText == 'ok') 
			{
			var btns = geByClass('triggerBtn');
                        if (act == "make_cover") { check_triger = 'coverBtn'; check_triger2 = 'activeBtn'; }
                        else { check_triger2 = 'coverBtn'; check_triger = 'activeBtn'; }
                        each(btns, function(i, btn)
                          {
                            var saBtn = btn.id.split("_");
                            if (saBtn[0] == check_triger & saBtn[1] == pid) { btn.className = 'triggerBtn triggerBtnOn'; }
                            else if (saBtn[0]!=check_triger2) { btn.className = 'triggerBtn triggerBtnOff'; }
                          });
			}
                delete xmlHttp;
		xmlHttp = null;
	        }}

		xmlHttp.send('act='+act+'&aid='+aid+'&pid='+pid);
		}
	}	
//-----------------------------------
  
  function setCover2(el, fid, aid) {
    if (hasClass(el, 'triggerBtnOn')) {
		fid = -1;
	}
	var d = {act:'a_cover', fid:fid, aid:aid};
	Ajax.Post( { url:'photos.php', query:d, onDone:function() {
		var btns = geByClass('triggerBtn', ge('editphotoalbum'));
		each(btns, function(i, btn) {
			if (btn.id == 'coverBtn' + fid) {
				btn.className = 'triggerBtn triggerBtnOn';
			}else {
				btn.className = 'triggerBtn triggerBtnOff';
			}
		});
	}});
  }

//-----------------------------------
function menuopener(sId, dir)
{
  if(!dir)
  {
    dir = "";
  }
  e = findObj('menu' + sId);
  i = findObj('menuImg' + sId);

  if(!e)
  {
    //alert('Not found ' + sId);
    return;
  }

  if(!i)
  {
    //alert('Not found ' + sId);
    return;
  }

  if (e.style.display == "block")
  {
    e.style.display = "none";
    if(i && i.src) i.src = "/images/" + dir + "plus.gif";
  }
  else
  {
    e.style.display = "block";
    if(i && i.src) i.src = "/images/" + dir + "minus.gif";
  }
}
//-----------------------------------------------------------------
function openWriteSMS(forWho)
{
  open("sms2.php?act=new&to=" + forWho,"_blank","toolbar=0,location=0,menubar=0,scrollbars=0,resizable=1,status=0,width=460,height=200,top=0,left=0");
}
//====================================================
function openSMSHistory(user)
{
  open("sms2.php?act=history&uid=" + user,"_blank","toolbar=0,location=0,menubar=0,scrollbars=1,resizable=1,status=0,width=490,height=670,top=0,left=0");
}
//====================================================
function RandomNotReapited(maximum, not_this_value)
{
  while (true)
  {
    var now = new Date();
    tmp_random_digit = Math.abs(Math.sin(now.getTime()));
    tmp_random_digit = (tmp_random_digit * maximum);
    tmp_random_digit = Math.floor(tmp_random_digit);
    if (tmp_random_digit != not_this_value)
    {
      break;
    }
  }
  return tmp_random_digit;
}

function openSMS(typesms, heightsms)
{
open("/sms2.php?act=read&typesms="+typesms+"&nocache="+RandomNotReapited(9999, 0),"_blank","toolbar=0,location=0,menubar=0,scrollbars=1,resizable=1,status=0,width=460,height=" +heightsms+ ",top=0,left=0");
}
//====================================================
function menush(sId, dir)
{
  if(!dir)
  {
    dir = "";
  }
  e = findObj('menu' + sId);
  i = findObj('menuImg' + sId);

  if(!e)
  {
    //alert('Not found ' + sId);
    return;
  }

  if (e.style.display == "block")
  {
    e.style.display = "none";
    if(i && i.src) i.src = "/images/" + dir + "plus.gif";
  }
  else
  {
    e.style.display = "block";
    if(i && i.src) i.src = "/images/" + dir + "minus.gif";
  }
}
//------------------------------------------