function launchChangePass (id_prof)
{
    var win = "width=300,height=220,left=200,top=100,copyhistory=no,directories=no,menubar=no,location=no,resizable=no,scrollbars=no";
    window.open("changepass.php?ID="+id_prof,'ChangePass',win);
    return false;
}

function setCheckboxes(the_form, do_check)
{

	var elts  = document.forms[the_form].getElementsByTagName('input');
    var elts_cnt  = elts.length;
    var i = 0;

    for ( i; i < elts_cnt; i++)
    {
        elts[i].checked = do_check;
		if (the_form + "_submit" == elts[i].name)
		{
			elts[i].disabled = !do_check;
		}
    } // end for
	return true;
} // end of the 'setCheckboxes()' function

function setCheckbox(the_form)
{
    var elts      = document.forms[the_form].getElementsByTagName('input');
    var elts_cnt  = elts.length;

    var allUnchecked = true;

    for (var i = 0; i < elts_cnt; i++)
    {
        if(elts[i].checked) allUnchecked = false;
    }

    for (var i = 0; i < elts_cnt; i++)
    {
        if(elts[i].name == (the_form + "_submit")) elts[i].disabled = allUnchecked;
    }

    return true;
}


var win = "width=500,height=600,left=100,top=100,copyhistory=no,directories=no,menubar=no,location=no,resizable=no,scrollbars=yes";
function get_gallery(id_prof)
{
   window.open("photos_gallery.php?ID="+id_prof,'gallery',win);
}

function launchTellFriend ()
{
    var win = "width=300,height=300,left=200,top=100,copyhistory=no,directories=no,menubar=no,location=no,resizable=no,scrollbars=no";
    window.open("tellfriend.php",'tellfriend',win);
    return false;
}

function launchTellFriendProfile ( sID )
{
    var win = "width=300,height=300,left=200,top=100,copyhistory=no,directories=no,menubar=no,location=no,resizable=no,scrollbars=no";
    window.open("tellfriend.php?ID="+sID,'tellfriendprofile',win);
    return false;
}

function BxShowBlock( id )
{

	var el;
	el = document.getElementById( id );

	if( el.style.display == 'none' )
	{
		el.style.display = 'block'
	}
	else
	{
		el.style.display = 'none'
	}

	return false;
}

function ShowShowHide ( show_name, show_name2, hide_name )
{
    if (hide_name) hide_name.style.display = 'none';
    if (show_name) show_name.style.display = 'inline';
    if (show_name2) show_name2.style.display = 'inline';
}

function ShowHideHide ( show_name, hide_name, hide_name2 )
{
    if (hide_name) hide_name.style.display = 'none';
    if (hide_name2) hide_name2.style.display = 'none';
    if (show_name) show_name.style.display = 'inline';
}

function charCounter(field,maxLength,countTarget)
{

	field = document.getElementById(field);
	countTarget = document.getElementById(countTarget);
	var inputLength=field.value.length;

	if(inputLength >= maxLength)
	{
		field.value=field.value.substring(0,maxLength);

	}
	countTarget.innerHTML=maxLength-field.value.length;


}



/**
 * change images onHover mouse action
 */
function show(FileName,jpg1Name)
{
	document.images[FileName].src = jpg1Name;
}

/**
 * set status of the browser window to 's'
 */
function ss(s)
{
	window.status = s;
	return true;
}

/**
 * set status of the browser window to empty
 */
function ce()
{
	window.status='';
}


/**
 * insert emotion item
 */
function emoticon( txtarea, text ) {

	text = ' ' + text + ' ';
	if (txtarea.createTextRange && txtarea.caretPos) {
		var caretPos = txtarea.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
		txtarea.focus();
	} else {
		txtarea.value  += text;
		txtarea.focus();
	}
}

function launchAddToIM (id)
{
    var win = "width=600,height=160,left=100,top=100,copyhistory=no,directories=no,menubar=no,location=no,resizable=no,scrollbars=yes";
    window.open("explanation.php?explain=imadd&ID="+id,'add_to_im',win);
    return false;
}

function docOpen(text)
{
var shit = "666";
	newWindow=window.open('','','menubar=yes,toolbar=no,resizable=yes,scrollbars=yes,width=400,height=300');
	newWindow.document.open("text/html");
	newWindow.document.write(decodeURI(text));
	newWindow.document.close();
}

function get_data( container, url, siteUrl )
    {

        if ( container )
        {
	    var container = document.getElementById( container );
	    container.innerHTML = "loading ... ";
        }

        var XMLHttpRequestObject = false;

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


	if( XMLHttpRequestObject )
        {
    	    var data_source = siteUrl + 'xml/menu.php' + url + '&_t=' + Math.random();
    	    XMLHttpRequestObject.open( "GET", data_source );
    	    XMLHttpRequestObject.onreadystatechange = function()
    	    {
        	if ( XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200 )
        	{

        	var xmlDocument = XMLHttpRequestObject.responseXML;
            delete XMLHttpRequestObject;
            XMLHttpRequestObject = null;

		   	names = xmlDocument.getElementsByTagName("name");
		    links = xmlDocument.getElementsByTagName("link");

		    list_sublinks(names, links);

        	}
    	    }

            XMLHttpRequestObject.send( null );

	}

	//container.innerHTML = '';




	function list_sublinks(names, links)
	{
    	var loopIndex, name, link, maxIndex = names.length;

	    container.innerHTML = '';
	    for ( loopIndex = 0; loopIndex < maxIndex; loopIndex++ )
   	    {

		    //if ( values[loopIndex].firstChild.nodeName=="name")
			name = names[loopIndex].firstChild.nodeValue;

		    //if ( values[loopIndex].childNodes[1].nodeName=="link")
			link = links[loopIndex].firstChild.nodeValue;

		    container.innerHTML += '<div class="innerSubmenuDiv"><a href="' + link + '">' + name + '</a></div>';
	    }

	}
}


function createNamedElement( type, name )
{

    var element;

    try
    {
        element = document.createElement('<'+type+' name="'+name+'">');
    } catch (e) { }

    if (!element || !element.name) // Cool, this is not IE !!
    {
        element = document.createElement(type)
        element.name = name;
    }

    return element;
}

function display_node(node, siteUrl)
{

    var nn = document.getElementById( node );

	var sub_name = node.split('_')[1];
    if ( 'none' == nn.style.display )
    {
	nn.style.display='block';
	if ( '' == nn.innerHTML )
	    get_data( node, '?action=menu&ID=' + sub_name, siteUrl);
    }
    else
    {
		nn.style.display='none';
    }

}

function stripSlashes(str)
{
	return str.replace(/\\/g, '');
}

//function commentQuote(commentid,commentname,commenttext,commentarea) {
//	var quote = '<div class="quote_n"><a href="profile.php?ID='+commentid+'">'+commentname+'</a> _wrote\n'+'<div class="quote_t">____________________\n'+commenttext+'\n'+'____________________\n</div></div>';
//	var comment = document.getElementById(commentarea);
//	addQuote(comment,quote);
//	return false;
//}

function postQuote(postid,postname,commentarea,alertmsg,write) {
	var posttext = '';
	
	if (window.getSelection){
		posttext = window.getSelection();
	}
	else if (document.getSelection){
		posttext = document.getSelection();
	}
	else if (document.selection){
		posttext = document.selection.createRange().text;
	}
	else {
		return true;
	}
	if (posttext==''){
		alert(alertmsg);
		return true;
	} else {
		//tinymce.DOM.addClass('quote', 'quote_n');
		var quote='<div class="quote_n" style="position:relative;background-color:#2d2d2d;border-bottom:1px solid #404040;padding:3px 0px 3px 3px;font-weight:bold;color:#AdAdAd;" /><a href="profile.php?ID='+postid+'">'+postname+'</a> '+write+'<br>'+'<div class="quote_t" style="padding:5px;text-align:justify;border-top:1px solid #404040;background-color:#2d2d2d;font-weight:normal;font-style:italic;" />'+posttext+'<br /></div></div><br />';
	//	var comment=document.getElementById(commentarea);
		//var el = tinyMCE.activeEditor.dom.create('div', {id : 'quote', 'class' : 'quote_n'}, quote);
//tinyMCE.activeEditor.selection.setNode(el);
tinyMCE.execCommand("mceInsertContent",false,quote);
		//addQuote(comment,quote);
	}
	return false;
}

//function addQuote(comment,quote){
//	// Derived from Alex King's JS Quicktags code (http://www.alexking.org/)
//	// Released under LGPL license
//	// IE support
//	if (document.selection) {
//		comment.focus();
//		sel = document.selection.createRange();
//		sel.text = quote;
//		comment.focus();
//	}
//	// MOZILLA/NETSCAPE support
//	else if (comment.selectionStart || comment.selectionStart == '0') {
//		var startPos = comment.selectionStart;
//		var endPos = comment.selectionEnd;
//		var cursorPos = endPos;
//		var scrollTop = comment.scrollTop;
//		if (startPos != endPos) {
//			comment.value = comment.value.substring(0, startPos)
//			              + quote
//			              + comment.value.substring(endPos, comment.value.length);
//			cursorPos = startPos + quote.length
//		}
//		else {
//			comment.value = comment.value.substring(0, startPos) 
//				              + quote
//				              + comment.value.substring(endPos, comment.value.length);
//			cursorPos = startPos + quote.length;
//		}
//		comment.focus();
//		comment.selectionStart = cursorPos;
//		comment.selectionEnd = cursorPos;
//		comment.scrollTop = scrollTop;
//	}
//	else {
//		comment.value += quote;
//	}
//	}
	