<!--
var win;
var xmlHttp;

timedouturl = "index";
function Display(min, sec) {
       var disp;
       if (min <= 9) disp = " 0";
       else disp = " ";
       disp += min + ":";
       if (sec <= 9) disp += "0" + sec;
       else disp += sec;
       return (disp);
}
function Down() {
       sec--;
       if (sec == -1) { sec = 59; min--; }
       if (min == 5 && sec == 0) {
               var truthBeTold = window.confirm("LargeFriends.com ANNOUNCEMENT\nYour session will expire in 5 minutes. Click OK to continue.");
               if (truthBeTold) {
               window.location.href = window.location.href;
               }
       }
       if (min == 0 && sec == 0) {
               window.location.href = timedouturl;
       }
       else down = setTimeout("Down()", 1000);
}
function timeIt() {
       min = 115 ;
       sec = 0 ;
       Down();
}

String.prototype.trim = function()
{
return this.replace(/(^\s*)|(\s*$)/g, "");
}

function createXMLHttpRequest() {
    if (window.ActiveXObject) {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    } 
    else if (window.XMLHttpRequest) {
        xmlHttp = new XMLHttpRequest();
    }
}

function send_email(p,new_win){
	if (new_win=='new'){
		window.open('send_email?'+p);
	}else{
		window.location.href='send_email?'+p;
	}
}

function clickOnce(){
	clickOnceForm(document.update.submitbut);
}

function clickOnceForm(f){
    f.value='Please wait...';
    f.disabled=true;
}

function checkPopup(){
    if (!(win && win.open && !win.closed)) {
        var text = "Please enable popups on our site!";
        var html = "<P align=justify class=main_text_l><b>" + text + "</b></p>";
        //if (document.all && document.all.warning)
           // document.all.warning.innerHTML = html;
        //else if (document.getElementById('warning'))
          //  document.getElementById('warning').innerHTML = html;
    }
}

function PopUpEx(sendLink, name, width, height, scrollbars) {
    mm= "width=" + width + ",height=" + height + ",scrollbars=" + scrollbars;
    win = window.open(sendLink, name, mm);
    if (win && win.open && !win.closed)
        win.focus();
    return win;
}

function PopUp(sendLink, name, width, height, scrollbars) {
    PopUpEx(sendLink, name, width, height, scrollbars);
}

function newwindow(a,windowname, width, height, scrollbars, process_link){
    var mm= "width=" + width + ",height=" + height + ",scrollbars=" + scrollbars;
    var url = a.href;
    var win = window.open(a.href, windowname, mm);
    if (win && win.open && !win.closed){
        win.focus();
    }
    if(process_link == null){
    	process_link = false;
    }
   return process_link;
}

function confirmwindow(c_text,c_url,win_name,width,heigh,scrollbars) {
    if (confirm(c_text)){
		PopUpEx(c_url,win_name,width,heigh,scrollbars);
	}
}

function modelesswin(url,mwidth,mheight,winname){
    if (document.all&&window.print){ 
        eval('window.showModelessDialog(url,winname,"help:0;resizable:1;dialogWidth:'+mwidth+'px;dialogHeight:'+mheight+'px")');
    }else{
        eval('window.open(url,winname,"width='+mwidth+'px,height='+mheight+'px,resizable=1,scrollbars=1")');
    }   
}

function fixForm(c)
{
  var i;
  var n = c.name;
  var l = c.form.elements.length;
  if (!c.checked) return;
  if (c.value == '0') {
    for (i = 0 ; i < l ; i++){
      var e = c.form.elements[i];
      if(e.name == n && e.value != c.value) e.checked=false;
    }
  } else {
    for (i = 0 ; i < l ; i++){
      var e = c.form.elements[i];
      if(e.name == n && e.value == '0') e.checked=false;
    }

  }
  return;
}

function CheckPassLenght(c)
{
	var s = c.value.indexOf(" ");
	document.getElementById('view').innerText='(At least 4 characters long for security reasons. No spaces or special characters.)'; 
	document.getElementById('view').style.color='#000000';
	document.getElementById('view').style.fontWeight = '';
	var format = /\D\W/;
	var result;
	result = c.value.match(format);
if (result) { 
    document.getElementById('view').innerText='[Enter password again. You cannot include special characters in your passwords.]'; 
	document.getElementById('view').style.color='#FF0000';
	document.getElementById('view').style.fontWeight = 'bold';
	document.getElementById('password').value= '';
    document.getElementById('password').focus();
}else{
	if (s>=0){
		document.getElementById('view').innerText='[Enter password again. You cannot include any space in your password!]';
		document.getElementById('view').style.color='#FF0000';
		document.getElementById('view').style.fontWeight = 'bold';
		document.getElementById('password').value='';
		document.getElementById('password').focus();
	}
	if(c.value.length != 0) {
		if( (c.value.length < 4) || (c.value.length > 12) ) {
			document.getElementById('view').innerText='[Your password must contain between 4 and 12 characters.No spaces or special characters.]';
			document.getElementById('view').style.color='#FF0000';
			document.getElementById('view').style.fontWeight = 'bold';
			document.getElementById('password').value='';
			document.getElementById('password').focus();
		}
	}
}
}
 
function popUpPayment(){
    PopUp('pay','pay',800,700, 'yes');
}

function PaymentWindowWithUserid(prof_id){
    window.open('pay?prof_id='+prof_id);
}

function goldMemberOnly(message1,message2,message3)
{
   var mes;
   if ((message1==null) && (message2==null) && (message3==null)){
      mes="This service is for gold members only (\$19.95 monthly). By becoming a gold member, you can access all services without restriction.";
   } else {
      if (message3!=""){
        mes=message3;
      }else{
        mes=message1;
        mes+= message2;
      }
   }
   modelesswin('goldMemberOnlyMessage_?message='+mes,350,550,'paymessage');
}

function goldMemberOnlyChat(party_id, party_name)
{
  goldMemberOnly(null,null,null);
}


function checkFrame(site) {
	try {
    var isFrame= self.parent.frames.length;
    if (isFrame==0){
        url=document.location;
        var re1 = /search_results/;
        if (re1.test(url)==true) {
            new_location = 'http://www.' + site + '/index.html?url=';
            try {
                        new_location += encodeURIComponent(url);
            } catch (e) {
                        new_location += escape(url);
            }
            document.location = new_location;
       }
    }
	} catch (e) {}
}

function RevealProfile(nextPage) {
    var newHref = "set_hidden?hide=0";
    if(nextPage!=null)
      newHref+="&next="+nextPage;
    if (confirm('Are you sure you want to reveal your profile?'))
        window.location.href = newHref;
}

function HideProfile() {
    if (confirm('You can still use all the features.  But others will not be able to see your profile.\nAre you sure you want to hide the profile?'))
        window.location.href = "set_hidden?hide=1";
}

function profileIncomplete(){
     alert("Please complete your registration to use our services!");
     //window.location.href = "my_profile";
}

function countLineBreaks (string) {
    var re = /\r\n|\r|\n/g;
    var n = 0;
    while (re.exec(string))
        n++;
    return n;
}

/* if needed, tries to increase the number of rows of a textarea */
function growTAVert (textarea) {
    var lineBreaks = countLineBreaks(textarea.value);
    if (textarea.rows * textarea.cols < textarea.value.length) {
        var newRows = lineBreaks +
                      parseInt(textarea.value.length / textarea.cols) + 2;
        newRows = newRows <= 40 ? newRows : 40;
        textarea.rows = newRows;
    } else if (textarea.rows < lineBreaks) {
        textarea.rows = lineBreaks + 2;
    }
}

function mc (id) {
    var obj = eval("document.forms.accounts.changed_" + id);
    obj.value = 1;
}

try{
     if (window.parent.document.title){
    window.parent.document.title=window.self.document.title;
     }
}catch(e){}


function checklogin()
{
     return get_XML_data("_check_authen");
}

function get_XML_data(data_url)
{
     var strResult=0;
     if (document.getElementById){
         try{
           strResult = NetScapeShow(data_url);
         }catch(e){
           strResult = IEShow(data_url);
         }
     }else{
          strResult = IEShow(data_url);
     }
     return strResult;
}
 
function NetScapeShow(data_url){
 xmlHttp = new XMLHttpRequest();
 xmlHttp.open("GET", data_url, false);
 xmlHttp.send(null);
 xmlDoc = xmlHttp.responseText;
 var strResult =xmlDoc;
 return strResult;
}
 
function IEShow(data_url){
 var oBao = new ActiveXObject("Microsoft.XMLHTTP");
 oBao.open("GET",data_url,false);
 oBao.send();
 var strResult = unescape(oBao.responseText);
 return strResult;
}

function syncForm(){
    var strResult=0;
    strResult = checklogin();
    if (!strResult){
        alert("Sorry, your session has expired. \nPlease log on again after copy your composing to your notepad!");
        return false;
    }else{
	return true;
    }
}

function setSelectValue(sel,val){
  var i;
  for (i=0;i<sel.length;i++) {
    if (sel.options[i].value == val){
      sel.selectedIndex = i;
    }
  }	     
}

function FullSize(url,ix,iy) {
    if(ix>0) {
        PopUp(url,"fsphoto",ix+6,iy+6,"no");
    }
}

function setPhotoAbout(id){
  PopUp('_set_picabout?id='+id,"about",435,388,"no");

}



function getFormFieldValue(field) {
    switch (field.type) {

        case "button" :
        case "file" :
        case "hidden" :
        case "password" :
        case "reset" :
        case "submit" :
        case "text" :
        case "textarea" :
            return field.value;

        case "select-one" :
            var i = field.selectedIndex;
            if (i == -1)
                return "";
            else
                return (field.options[i].value == "") ? field.options[i].text : field.options[i].value;

        case "select-multiple" :
            var result = new Array();
            for (var i = 0; i < field.options.length; i++)
                if (field.options[i].selected)
                    result[result.length] = (field.options[i].value == "") ? field.options[i].text : field.options[i].value;
            return result;

        case "radio" :
        case "checkbox" :
            if (field.checked)
                return field.value;
            else
                return "";

        default :
            if (field[0].type == "radio") {
                for (i = 0; i < field.length; i++)
                    if (field[i].checked)
                        return field[i].value;

                return "";
            } else if (field[0].type == "checkbox") {
                var result = new Array();
                for (i = 0; i < field.length; i++)
                    if (field[i].checked)
                        result[result.length] = field[i].value;

                return result;
            } else {
                // unknown field type
            }
            break;
    }
   
    return "";
}

function fixPiclist(obj, usr_id, picno) {
    var form = obj.form;
    var npics = form.elements['npics__' + usr_id].value;
    var makemain = form.elements['makemain__' + usr_id];
    var picno_main = npics > 1 ? getFormFieldValue(makemain) : 0;
    if (picno_main == "") picno_main = -1;

    // clear the other rank
    if (obj.name.substr(0, 6) == 'rank__' && obj.checked == 1)
        form.elements['rank4__' + usr_id].checked = 0;
    if (obj.name.substr(0, 7) == 'rank4__' && obj.checked == 1)
        form.elements['rank__' + usr_id].checked = 0;

    // undelete the main photo if setting a rank
    if ((obj.name.substr(0, 6) == 'rank__' ||
         obj.name.substr(0, 7) == 'rank4__') && obj.checked == 1)
    {
        // if there is no main photo, then use first pic for main photo
        if (picno_main == -1) {
            picno_main = 0;
            if (npics > 1) {
                makemain.value = picno_main = 0;
                makemain[0].checked = 1;
            }
        }

        form.elements['delp__' + usr_id + '_' + picno_main].checked = 0;
    }

    // "undelete" the main photo
    if (obj.name.substr(0, 10) == 'makemain__' && picno == picno_main) {
        form.elements['delp__' + usr_id + '_' + picno].checked = 0;
    }

    if (obj.name.substr(0, 6) == 'delp__' && obj.checked == 1) {
        if (picno == 0 && npics == 1) {
            // set rank to 0
            form.elements['rank__' + usr_id].checked = 0;
            form.elements['rank4__' + usr_id].checked = 0;
        } else {
            // if pic to be deleted is the main photo,
            // then use the first not deleted pic for main photo
            if (picno == picno_main) {
                for (var i = 0; i < npics; i++) {
                     if (form.elements['delp__' + usr_id + '_' + i].checked == 0) {
                         makemain.value = picno_main = i;
                         makemain[i].checked = 1;
                         break;
                     }
                }
            }

            // if all pics will be deleted, set rank to 0
            if (i == npics) {
                form.elements['rank__' + usr_id].checked = 0;
                form.elements['rank4__' + usr_id].checked = 0;
                makemain[picno_main].checked = 0;
                makemain.value = picno_main = -1;
            }
        }
    }
}

function RotateImg(obj, usr_id, picno){
  var angle = 0;
  var uid = usr_id + '_' + picno;
  angle = parseInt(document.getElementById("rangle__"+uid).value) + parseInt(obj.name);
  var rotation = 0;
  if(Math.abs(angle) >= 360)
     if(angle > 0) angle -= 360;  
	 else angle += 360;  
  document.getElementById("rangle__"+uid).value = angle;
//only for IE v.5.5 and above 
  if(navigator.appName=="Microsoft Internet Explorer"){
     if(angle < 0) angle += 360;
     switch (angle){
        case  90 : rotation = 3; break;
        case 180 : rotation = 2; break;
        case 270 : rotation = 1; break;
     }
     document.getElementById("photo__"+uid).style.filter = "progid:DXImageTransform.Microsoft.BasicImage(rotation="+rotation+")";
  } else {
     document.getElementById("photo__" + uid).src = "censor_show_rotated_img_?usr_id=" + usr_id + "&picno=" + picno + "&angle=" + angle;
  }
}

function OnLoadPage(site) {
}

function clickSearchOnce(){
	if(disp_age_error!="undefined") {
		if(disp_age_error.style.display=="") {
			return false;
		}
	}
	return true;
}
function set_start_height(oForm, startValue) {
	var fOption = oForm.options;
        if(!fOption[0].selected == true) {
        	return;
        }   
 	for (var i = 0; i < fOption.length; i++)
        if (fOption[i].value == startValue) fOption[i].selected = true;
}

function setRadioValue(f, name, value){
  var i;
  var l = f.elements.length;
  for (i = 0 ; i < l ; i++){
      var e = f.elements[i];
      if(e.name == name){
            e.checked = (e.value == value? true: false);
      } 
  }
}
function show_hide_dist(r) {
	try{
		var r_value = r.value;
		if (r.name != 'is_distance'){
			if (r.name.indexOf('_cou')!= -1 || r.name.indexOf('state')!= -1){ // is country
				r_value = 0;
			}else{
				r_value = 1;
			}
			setRadioValue(r.form, 'is_distance', r_value);   
		}
	} catch (e) {}
}
function checkMessages(theBox,theArray) {
		if ( theBox.checked ) {
			for (i = 0; i < theArray.elements.length; i++) {
				try{
					theArray.elements[i].checked = true ;
				}catch(e){}
			}
			theBox.form.checkall.checked = true;
		} else {
			for (i = 0; i < theArray.elements.length; i++) {
				try{
					theArray.elements[i].checked = false ;
				}catch(e){}
			}
			theBox.form.checkall.checked = false;
		}
}
function checkForm(frm){
	var sel = false;
	if(frm.del.length){
		for(var i=0;i<frm.del.length;i++){ 
			if(frm.del[i].checked){
				sel = true;
				break;
			}
		}
	}
	else{
		sel = frm.del.checked;
	}
	if(!sel){
		document.getElementById("error_div").style.display = 'block';
		document.location ='#top';
		return false;
	}
	return true;
}
function registerAlert() {
    alert('Please register to use the feature');
}


function check_spell_open(form_text_tag,form_name){
    if (!form_name) form_name ='update';
    var text = document.getElementById(form_text_tag).value;
	PopUpEx('/spell_checker_?form_name='+form_name+'&form_text_tag='+form_text_tag+'&text='+escape(text),'check_spell',500,400,'yes');
	//alert(text);
}

function check_spell(form_text_tag,form_name){
      if (!form_name) form_name ='update';
      var text = document.getElementById(form_text_tag).value;
      var http_request;
      http_request=getXMLHttpRequest();
	  http_request.open('GET', '/_check_spell?form_name='+form_name+'&form_text_tag='+form_text_tag+'&text='+escape(text)+'&ajaxRequestUncache='+parseInt(Math.random() * 1000000), true);
      http_request.onreadystatechange =  function(){
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
				var info = http_request.responseText;
				if(info=='1'){
					alert("No misspelling found!");
				}else{
					check_spell_open(form_text_tag,form_name);
				}
            } else {
                alert('There was a problem with the request.');
            }
        }
	  }
	  http_request.send(null);
}


// utility function to retrieve an expiration date in proper

// format; pass three integer parameters for the number of days, hours,

// and minutes from now you want the cookie to expire (or negative

// values for a past date); all three parameters are required,

// so use zeros where appropriate

function getExpDate(days, hours, minutes) {

    var expDate = new Date( );

    if (typeof days == "number" && typeof hours == "number" && 

        typeof hours == "number") {

        expDate.setDate(expDate.getDate( ) + parseInt(days));

        expDate.setHours(expDate.getHours( ) + parseInt(hours));

        expDate.setMinutes(expDate.getMinutes( ) + parseInt(minutes));

        return expDate.toGMTString( );

    }

}

// utility function called by getCookie( )

function getCookieVal(offset) {

    var endstr = document.cookie.indexOf (";", offset);

    if (endstr == -1) {

        endstr = document.cookie.length;

    }

    return unescape(document.cookie.substring(offset, endstr));

}

// primary function to retrieve cookie by name

function getCookie(name) {

    var arg = name + "=";

    var alen = arg.length;

    var clen = document.cookie.length;

    var i = 0;

    while (i < clen) {

        var j = i + alen;

        if (document.cookie.substring(i, j) == arg) {

            return getCookieVal(j);

        }

        i = document.cookie.indexOf(" ", i) + 1;

        if (i == 0) break; 

    }

    return "";

}

// store cookie value with optional details as needed

function setCookie(name, value, expires, path, domain, secure) {

    document.cookie = name + "=" + escape (value) +

        ((expires) ? "; expires=" + expires : "") +

        ((path) ? "; path=" + path : "") +

        ((domain) ? "; domain=" + domain : "") +

        ((secure) ? "; secure" : "");

}

// remove the cookie by setting ancient expiration date

function deleteCookie(name,path,domain) {

    if (getCookie(name)) {

        document.cookie = name + "=" +

            ((path) ? "; path=" + path : "") +

            ((domain) ? "; domain=" + domain : "") +

            "; expires=Thu, 01-Jan-70 00:00:01 GMT";

    }

}



//Instant Messenger functions

var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
var chats = new Array();
var CommandBlocked = false;

function startIM (usr_id) {
   PopUp("http://www.LargeFriends.com/s/im_users_list.htm","im_" + usr_id,330,500,"no, resizable=1");
}

function startPrivateChat(partyname) {
	var im_usersObj = isInternetExplorer ? document.all.im_users : document.im_users;

	if((chats[partyname]==null) || (typeof(chats[partyname])=="undefined") || (chats[partyname].closed)) {
		try {
			chats[partyname] = PopUpEx('http://www.LargeFriends.com/s/im_private.htm?partyname=' + partyname, 'MIM_to_' + partyname, 500, 330, 'no, resizable=1');
		} catch(e) { alert("error:" + e)};
		if(chats[partyname]==null || typeof(chats[partyname])=="undefined") {
//TODO: Possible, popups is blocked. Display notification.
			if(im_usersObj) {
				im_usersObj.TGotoLabel("/", "PopupBlocked");
			}
		}
	} else {
//TODO: Add blinking effect to window chats[partyname]. Don't know how to do it...
	}
}

// add to bookmark
function addBookmark() 
{
	if (window.sidebar) 
	{
		window.sidebar.addPanel(document.title, document.location.href,"");
	} 
	else if(document.all) 
	{
		window.external.AddFavorite( document.location.href, document.title);
	} 
	else if( window.opera && window.print )
	{
	return true;
	}
} 

function selectAllWithTextarea(textarea) {
    try {
        textarea.focus();
        textarea.select();
    } catch (e) {
//        alert(e);
    }
}

function getXMLHttpRequest()
{
	var http_request;
        if (window.XMLHttpRequest) { // Mozilla, Safari,...
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
            }
        } else if (window.ActiveXObject) { // IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }
		return http_request;

}

function popupMsg(id){
       document.getElementById(id).style.display='';
}
function hiddenMsg(id){
       document.getElementById(id).style.display='none';
}

function HideandUNhideObj(i){
        nav=document.getElementById('div'+i).style;
        con=document.getElementById('ul'+i);
        if(nav.display=="none"){
                // set mouseout function here
                nav.display = 'block';
                con.onmouseout = function(evt) {
                    if (checkMouseLeave(this, evt)) {
                        i = parseInt(this.id.substr(2));
                        nav=document.getElementById('div'+i).style;
                        nav.display = 'none';
                    }
                }
        } else {
                nav.display='none';
                con.onmouseout = function (evt) {
                    if (checkMouseLeave(this, evt)) {
                        i = parseInt(this.id.substr(2));
                        nav=document.getElementById('div'+i).style;
                        nav.display= 'none';
                    }
                }
        }
}

function checkMouseLeave (element, evt) {

  evt = (evt) ? evt : ((window.event) ? window.event : "");
  window.status = evt;
  if (evt.relatedTarget) {
    return !containsDOM(element, evt.relatedTarget);
  } else {
        if (element.contains(evt.toElement)) {
                return(false);
        } else {
                return(true);
        }
  }
}

function containsDOM (container, containee) {
  var isParent = false;
  do {
    if ((isParent = container == containee))
      break;
    containee = containee.parentNode;
  }
  while (containee != null);
  return isParent;
}

// for image show/hide

function getElementPosX(element) {
    var left = 0;
    if (element.offsetParent) {
        while (element.offsetParent) {
            left += element.offsetLeft;
            element = element.offsetParent;
        }
    } else if (element.x) {
        left += element.x;
    }
    return left;
}
function getElementPosY(element) {
    var top = 0;
    if (element.offsetParent) {
        while (element.offsetParent) {
            top += element.offsetTop;
            element = element.offsetParent;
        }
    } else if (element.y) {
        top += element.y;
    }
    return top;
}
function layoutImageBox(owner, box) {
    try {
        box.style.left = getElementPosX(owner) + 'px';
        box.style.top = getElementPosY(owner) + 'px';
        box.style.visibility = 'visible';
    } catch (e) {
//        alert(e);
    }
}
function showFullImage(owner, url, linkto) {
    try{
        imageBox = document.getElementById('image_box');
        imageBoxUrl = document.getElementById('image_box_url');
        var img = new Image();
        img.onload = function() {
            imageBox.src = img.src;
            w = img.width;
            h = img.height;
            max = 300.0;
            if (img.width > max) {
                scale = max / img.width;
                w *= scale;
                h *= scale;
            } else if (img.height > max) {
                scale = max / img.height;
                w *= scale;
                h *= scale;
            }
            imageBox.width = w;
            imageBox.height = h;
            img = null;
            layoutImageBox(owner, imageBox);
        }
        img.src = url;
        imageBoxUrl.href = linkto;
    } catch (e) {
//        alert(e);
    }
}


// -->

