/*
(C) AEwebworks Software Development Ltd., 2002-2003
IMPORTANT: This is a commercial software product and any kind of using it must agree
to the AEwebworks Software Development Ltd. license agreement. It can be found at
http://www.aewebworks.com/license.htm
This notice may not be removed from the source code.
*/

/**
 * Checks/unchecks all tables
 *
 * @param   string   the form name
 * @param   boolean  whether to check or to uncheck the element
 *
 * @return  boolean  always true
 */

function setCheckboxes(the_form, do_check)
{
	var elts      = document.forms[the_form].elements;
	var elts_cnt  = elts.length;
	
    for (var i = 0; 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


var win = "width=400,height=500,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 get_kamaface(id_prof, contest_id)
{
   window.open("kama_face.php?ID="+id_prof + "&contest_id=" + contest_id ,'gallery',win);
}

function launchTellFriend ()
{
    var win = "width=300,height=300,left=100,top=100,copyhistory=no,directories=no,menubar=no,location=no,resizable=no,scrollbars=yes";
    window.open("tellfriend.php",'tellfriend',win);
    return false;
}

function launchTellFriendProfile ( sID )
{
    var win = "width=300,height=300,left=100,top=100,copyhistory=no,directories=no,menubar=no,location=no,resizable=no,scrollbars=yes";
    window.open("tellfriend.php?ID="+sID,'tellfriendprofile',win);
    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';
}


/**
 * 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 ) {
//	var txtarea = document.post.message;
	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 disableZIP()
{
	document.FCompose.distance.value = '';
	document.FCompose.zip.value = '';
	document.FCompose.metric.selectedIndex= 0;
	
	document.FCompose.distance.disabled = true;
	document.FCompose.zip.disabled = true;
	document.FCompose.metric.disabled = true;
	
	var Countries=document.FCompose.elements['Country[]'];
	var States = document.FCompose.elements['State[]'];
	Countries.disabled = false;
	States.disabled = false;

}
function disableCont()
{
	var Countries=document.FCompose.elements['Country[]'];
	var States = document.FCompose.elements['State[]'];
	Countries.selectedIndex = 0;
	States.selectedIndex = 0;
	
	Countries.disabled=true;
	States.disabled=true;

	document.FCompose.distance.disabled = false;
	document.FCompose.zip.disabled = false;
	document.FCompose.metric.disabled = false;
}
function checkContZip()
{
	for (counter = 0; counter < document.FCompose.contzip.length; counter++)
	{

	if(document.FCompose.contzip[counter].checked)
	{
		if(document.FCompose.contzip[counter].value=='zip')
		{
			var Countries=document.FCompose.elements['Country[]'];
			var States = document.FCompose.elements['State[]'];
			Countries.selectedIndex = 0;
			States.selectedIndex = 0;
			
			Countries.disabled=true;
			States.disabled=true;

			document.FCompose.distance.disabled = false;
			document.FCompose.zip.disabled = false;
			document.FCompose.metric.disabled = false;
		}
		else if(document.FCompose.contzip[counter].value=='cont')
		{
			document.FCompose.distance.value = '';
			document.FCompose.zip.value = '';
			document.FCompose.metric.selectedIndex= 0;
			
			document.FCompose.distance.disabled = true;
			document.FCompose.zip.disabled = true;
			document.FCompose.metric.disabled = true;
			
			var Countries=document.FCompose.elements['Country[]'];
			var States = document.FCompose.elements['State[]'];
			Countries.disabled = false;
			States.disabled = false;
		}
	}

	}

}

function openIMWindow(destinationUserID,where)
{
	/*alert(destinationUserID);*/
	/*window.open( "userplane/samples/PHP/userplane/wm.php?WITH="+destinationUserID,'Chat::'+destinationUserID,"width=360,height=420,toolbar=0,directories=0,menubar=0,status=0,location=0,scrollbars=0,resizable=0" );*/
	/*window.open( "cc.php?WITH=" + destinationUserID + "" ,'Chat::' + destinationUserID,"width=360,heigh=420,toolbar=0,directories=0,menubar=0,status=0,location=0,scrollbars=0,resizable=0" );*/
	var blockTest = null;
	blockTest = window.open( "http://kamaconnection.com/popuptest.html",'',"width=360,height=420,toolbar=0,directories=0,menubar=0,status=0,location=0,scrollbars=0,resizable=0");
	if(blockTest != null)
	{
		if(where=='here')
			blockTest = window.open( "wm.php?here=here&yes=yes&WITH=" + destinationUserID,'',"width=360,height=420,toolbar=0,directories=0,menubar=0,status=0,location=0,scrollbars=0,resizable=0");
		else
			blockTest = window.open( "userplane/samples/PHP/userplane/wm.php?WITH=" + destinationUserID,'',"width=360,height=420,toolbar=0,directories=0,menubar=0,status=0,location=0,scrollbars=0,resizable=0");
		if(blockTest != null) return true;
	}
	else if(where == 'here') {
		alert(destinationUserID + " is trying to chat with you. DISABLE YOUR POP-UP BLOCKER to chat");
		return false;
	}	
	else {
		alert("DISABLE YOUR POP-UP BLOCKER to chat with " + destinationUserID);
		return false;
	}
	
}
