/*=============================================================================
|| ##################################################################
||	phpFoX Portal
|| ##################################################################
||	
||	Copyright		: (C) 2005 The phpFoX Group a Reality Fox Creation
||	Contact		: support@phpfox.com
||	Support Forum	: http://www.phpfox.com/forum/
||
||	- phpFoX and all of its source code and files are protected by Copyright Laws. 
||
||	- The license for phpFoX permits you to install this software on a single domain (.com, .org, .net, etc.). 
||
||	- You may also not remove the "Powered By phpFoX" or any copyright screen which shows the copyright information and credits for phpFoX (RealityFOX Creations). 
||
||	- phpFoX is NOT a FREE software - http://www.phpfox.com/license
||
|| ##################################################################
=============================================================================*/

function showIt()
{	
	var item = document.getElementById('location');

	if (item.value == "United_States")
	{
		

		document.getElementById('state').disabled=false;
		document.getElementById('zip').disabled=false;	
	}
	else
	{
		document.getElementById('state').disabled=true;
		document.getElementById('zip').disabled=true;	
	}
}

function bookmark(url, description)
	{
	netscape="Gecko User's hit CTRL+D to add a bookmark to this site."
	if (navigator.appName=='Microsoft Internet Explorer')
		{
		window.external.AddFavorite(url, description);
		}
	else if (navigator.appName=='Netscape')
		{
		alert(netscape);
		}
	}


function popUp2(URL,WIDTH,HEIGHT,SCROLL,LEFT,TOP) {
	day = new Date();
	id = "window_"+day.getTime();
	window.open(URL, id ,'scrollbars='+SCROLL+',width='+WIDTH+',height='+HEIGHT+',left='+LEFT+',top='+TOP);
//	alert('status=no,scrollbars=no,width='+WIDTH+',height='+HEIGHT+',left='+LEFT+',top='+TOP);
}

/*###############################
	PROGRESS BAR
###############################*/

var progressEnd;		
var progressInterval;	
var progressAt;
var progressTimer;

function do_prog(item1,item2) 
{
	progressEnd = item1;		
	progressInterval = item2;	
	progressAt = progressEnd;
	progress_update();
}

function progress_clear() 
{
	for (var i = 1; i <= progressEnd; i++) document.getElementById('progress'+i).className = 'pbar1';
	progressAt = 0;
}

function progress_update() 
{
	progressAt++;
	if (progressAt > progressEnd) progress_clear();
	else document.getElementById('progress'+progressAt).className = 'pbar2';
	progressTimer = setTimeout('progress_update()',progressInterval);
}

function progress_stop() 
{
	clearTimeout(progressTimer);
	progress_clear();
}

/*###############################
	MENU MOUSEOVER
###############################*/

function linkon1(id1)
{
	document.getElementById(id1).className='menu5b';

}

function linkon2(id1)
{
	document.getElementById(id1).className='menu5a';

}


/*###############################
	COOKIES
###############################*/


function SetCookie(cookieName,cookieValue,nDays) 
{
	var today = new Date();
	var expire = new Date();
 	if (nDays==null || nDays==0) nDays=1;
 	expire.setTime(today.getTime() + 3600000*24*nDays);
 	document.cookie = cookieName+"="+escape(cookieValue) + ";expires=" + expire.toGMTString() + '; path=/';
}

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";
    }
}


function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}



/*###############################
	HIDE MENUS
###############################*/

if (document.getElementById) { 
	document.write('<style type="text/css">\n')
	document.write('.submenu{display:block;}\n')
	document.write('</style>\n')
}


function SwitchMenu(obj,id2)
{
	if(document.getElementById) {
	var el = document.getElementById(obj);
	
		if(el.style.display == "none") { 
			document.getElementById(id2).innerHTML='[&minus;]';
			el.style.display = "block";
			SetCookie(obj,"","-1"); 
		} else { 
			document.getElementById(id2).innerHTML='[+]';
			el.style.display = "none";
			SetCookie(obj,1,1); 
		}
	}
}


function SwitchMenu2(obj,id2,id3,id4,id5,id6,id7,id8)
{
	if(document.getElementById) {
	var el = document.getElementById(obj);
	
		if(el.style.display == "none") { 
			document.getElementById(id6).innerHTML=id7;
			document.getElementById(id2).src=id5;
			el.style.display = "block";
			SetCookie(obj,"","-1"); 
			document.getElementById(id3).style.width='70%';
		} else { 
			document.getElementById(id6).innerHTML=id8;
			document.getElementById(id2).src=id4;
			el.style.display = "none";
			SetCookie(obj,1,0); 
			document.getElementById(id3).style.width='100%';
		}
	}
}




/*###############################
	GO TO LOCATION / FRAMES
###############################*/
function go_home(link)
{
	if (top.frames.length == 0) {
    		document.cookie = "newURL=" + escape(document.URL) + "; path=/;"
    		ver = parseInt(navigator.appVersion, 10);
    		if ( ((navigator.appName == "Netscape") && (ver >= 3)) ||
         		((navigator.appName == "Microsoft Internet Explorer") && (ver >= 4)) )
      			location.replace(link);
    		else
	      location = link;
    		};
}



/*###############################
	NO RIGHT CLICK
###############################*/
function clickIE() 
	{
	if (document.all) 
		{
		return false;
		}
	}

function clickNS(e) 
	{
	if (document.layers||(document.getElementById&&!document.all)) 
		{
		if (e.which==2||e.which==3) 
			{
			return false;
			}
		}
	}


function noCLICK()
{
	
	if (document.layers) {
		document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;
	} else {
	document.onmouseup=clickNS;document.oncontextmenu=clickIE;
	}
	document.oncontextmenu=new Function("return false")
}



function jumpTo(list)
{
	var IDS = document.getElementById(list);
	
	if (IDS.value != "") {
		window.location.href=IDS.value;
	} 
	
	return false;
}






function image1(img,height,width)
{
	if (getCookie('FOX_EN')) { showInfo3(img,width,height); }
	return false;
}


function image2()
{
	if (getCookie('FOX_EN')) {  }
	return false;
}


function image3(type)
{
	if (getCookie('FOX_EN')) {
		SetCookie("FOX_EN","","-1");
	} else {
		SetCookie("FOX_EN",1,0);
	}	
}




/*###############################
	IMAGE FADER
###############################*/
function initImage(ids) {
  imageId = ids;
  image = document.getElementById(imageId);
  setOpacity(image, 0);
  image.style.visibility = 'visible';
  fadeIn(imageId,0);
}


function setOpacity(obj, opacity) {
  opacity = (opacity == 100)?99.999:opacity;
  
  // IE/Win
  obj.style.filter = "alpha(opacity:"+opacity+")";
  
  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opacity/100;
  
  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;
  
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
}


function fadeIn(objId,opacity) {
  if (document.getElementById) {
    obj = document.getElementById(objId);
    if (opacity <= 100) {
      setOpacity(obj, opacity);
      opacity += 10;
      window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);
    }
  }
}



/*###############################
	INSERT TEXT AT CURSOR
###############################*/
function insertAtCursor(myField, myValue, type) 
{
	if ( displayIt == "True" )
	{
		var newValue = myValue.replace(":","");
		var mainValue = newValue.replace(":","");
		var html = '<img src="'+ SciptHome +'/images/smile/emo/'+ mainValue +'.gif">';
		tinyMCE.execCommand('mceInsertContent', false, html);
		return;
	}
	else
	{
		if (document.selection) 
		{
			myField.focus();
			if (type == 1) {
			sel = opener.document.selection.createRange();
		} else {
			sel = document.selection.createRange();
		}
		sel.text = myValue;
	}
	else if (myField.selectionStart || myField.selectionStart == '0') 
	{
		var startPos = myField.selectionStart;
		var endPos = myField.selectionEnd;
		myField.value = myField.value.substring(0, startPos)
		+ myValue
		+ myField.value.substring(endPos, myField.value.length);
		myField.focus();
	} 
	else 
	{
		myField.value += myValue;
		}
	}
}







function sel(idname) {
	with(document.myform) {
		for(i=0;i<elements.length;i++) {
			thiselm = elements[i];
			if(thiselm.name.substring(0,2) == 'id')
				thiselm.checked = !thiselm.checked
		}
	}
}



	


/**
 * in order not to write each time window.location.href = bla bla bla
 * just call this function
 * author Maxim Starikov
 */
 
 function getUrl(url){
   window.location.href = url;
 }
 
/**
 *
 */ 
 function addBookmark(a){
  try {
	window.external.addFavorite(window.document.location, window.document.title); 
	return false;
  }
  catch(e){}
  try {
  	ShowTooltip(a,'Title','Instructions','text','<div style="padding:10px;"><p>Hold CTRL and hit D to add a bookmark to this site.</p><p align="right"><a class="headlines" href="#" onclick="setAsHome.tooltip.hideDelayed()">Close</a></p></div>','show_close_button',true);    
    addBookmark.tooltip = a.tooltip;
	return false;
  }
  catch(e){alert(e)}
 
 }
 
/**
 *
 */
 function setAsHome(a){
  try {
    a.style.behavior='url(#default#homepage)';
    a.setHomePage('http://www.realestateinvestor.com');
    return false;
  }
  catch(e){}
  try { 
  	ShowTooltip(a,'Title','Instructions','text','<div style="padding:10px;"><p>Drag <a class="headlines" href="http://www.realestateinvestor.com/"><img src="/images/icons/home_16.jpg" alt="" width="16" height="16" border="0"> this house</a> to the picture of the house at the top of your browser.</p><p align="right"><a class="headlines" href="#" onclick="setAsHome.tooltip.hideDelayed()">Close</a></p></div>','show_close_button',true);
  	setAsHome.tooltip = a.tooltip;
	return false;
  }
  catch(e){alert(e)}
  return true;
}
/**
 * shows something like
 * <div style="visibility: hidden;" id="add_bookmark">
 *     <div class="popup_header">
 *        {title}
 *      </div>
 *      <div class="popup_body">
 *        {message}
 *      </div>
 *      <div class="popup_footer">
 *      <a class="headlines" href="#" onclick="$('add_bookmark').style.visibility = 'hidden'">Close</a>
 *      </div>
 *</div>
 */
function showMessageBlock(x,y,title,body){
  closeOpenedMessage();
  var m = document.createElement('DIV');
  m.className = 'popup_box';
  m.style.position = 'absolute';
  m.style.left = x+'px';  
  m.style.top = y+'px';    
  window.opened_message = m;
  document.body.appendChild(m);
  var mheader = document.createElement('DIV');
  mheader.className = "popup_header";
  m.appendChild(mheader);
  var mheader_text = document.createTextNode(title); 
  mheader.appendChild(mheader_text); 
  var mbody = document.createElement('DIV'); 
  mbody.className = "popup_body";  
  m.appendChild(mbody);
  mbody.innerHTML = body;
//  var mbody_text = document.createTextNode(body);  
//  mbody.appendChild(mbody_text);
  var mfooter = document.createElement('DIV');  
  mfooter.className = "popup_footer";    
  m.appendChild(mfooter);    
  var mfooter_a = document.createElement('A');    
  mfooter_a.onclick = closeOpenedMessage;
  mfooter_a.href = '#';
  mfooter.appendChild(mfooter_a);
  var mfooter_a_text = document.createTextNode('Close');      
  mfooter_a.appendChild(mfooter_a_text);  
  //alert(m.innerHTML)
}

/**
 * close opened message if there is any
 */
function closeOpenedMessage(){
  if (window.opened_message) {
    document.body.removeChild(window.opened_message);
	window.opened_message = null;
  }
}


/**
 * retruns top coordinate of element
 */ 
function getPageOffsetTop(obj) {
  
  var y;
  y = obj.offsetTop;
  if (obj.offsetParent != null)
  y += getPageOffsetTop(obj.offsetParent);
  return y;
}
/**
 * retruns left coordinate of element
 */ 
function getPageOffsetLeft(obj) {
  var x;
  x = obj.offsetLeft;
  if (obj.offsetParent != null)
  x += getPageOffsetLeft(obj.offsetParent);
  return x;
}
  
  function $(id)
  {
  	if(id && document.getElementById(id)){
		var ele= document.getElementById(id);
		return ele;
  	}else
  		return null;
  }

/**
 * 
 *
 */ 
function InitMessagesCountRefresh() {
  setTimeout(SetCountOfMessages,60000); //60 seconds
}

function SetCountOfMessages() {
  xajaxSetCountOfMessages();
  setTimeout(SetCountOfMessages,60000); //60 seconds
}

function fckEditor(id, template){
	var url= "http://"+window.location.host;
	var oFCKeditor = new FCKeditor( id ); 
	oFCKeditor.BasePath    = url+"/FCKeditor/" ; 
	oFCKeditor.ToolbarSet = template; 
	oFCKeditor.ReplaceTextarea();
}

function submitForm(formName){
	var form= $(formName);
	form.submit();
}

function setAction(action){
	$('action').value= action;
}

function setField(name, value){
	$(name).value= value;
}

function test(){
	alert('ok');
}


function prepDel(formName, action){
	var form= $(formName);
	
	if(confirm("Are you sure?")){
		setAction(action);
		form.submit();
	}
}
/**
 * use ShowTooltip instead
 */
function ShowHint(owner,value,title,hovered_class){

	if (typeof(hovered_class)!='undefined'){
		var old_class = owner.className;

		ShowTooltip(owner,
			'text',value,'Title',title,'width','auto','position','mouse',
			'onmouseover',function(){owner.className=hovered_class},
			'onmouseout',function(){owner.className=old_class});
	}
  	else {
		ShowTooltip(owner,'text',value,'Title',title,'width','auto','position','mouse');
  	}
  	owner.alt = "";	
  	owner.title = "";
}
	

function showAjaxLoader(id){
  $(id).style.visibility = 'visible';
}

function hideAjaxLoader(id){
  $(id).style.visibility = 'hidden';
}

function getFormValues(frm){
	var objForm;
	var submitDisabledElements=false;
	if(arguments.length > 1 && arguments[1]==true)
		submitDisabledElements=true;var prefix="";
	if(arguments.length > 2)
		prefix=arguments[2];
	if(typeof(frm)=="string") objForm=$(frm);
	else objForm=frm;
	var values = {};
	if(objForm && objForm.tagName.toUpperCase()=='FORM'){
		var formElements=objForm.elements;
		for(var i=0;i < formElements.length;i++){
			if(!formElements[i].name) continue;
			if(formElements[i].name.substring(0,prefix.length)!=prefix) continue;
			if(formElements[i].type && (formElements[i].type=='radio' 
			|| formElements[i].type=='checkbox') && formElements[i].checked==false) continue;
			if(formElements[i].disabled && formElements[i].disabled==true && submitDisabledElements==false) continue;
			var name=formElements[i].name;
			if(name){
				values[name] = formElements[i].value;
			}
		}
	}
	return values;
}

function print_f(v){
  var s = ''
  for(key in v){
    s = s + key + ' => ' + v[key] + "\n";
  }
  alert(s);
}


