var addingajaxcalled=0; // var is in util.js 
var dom=document.getElementById
// DO NOT FOLLOW THE ABOVE WITH A ; semicolon SINCE IT MAKES IT BAD IN NON IE BROWSERS
var hasFlashOnPage=0; 
var app_URL='http://gain6.com';
var app_secureURL='https://gain6.com';
var httpOrhttps = location.href.substring(0,5); 
var currURL;
if(httpOrhttps == 'https') currURL=app_secureURL;
else currURL=app_URL; 
var sharestorytext="Write Something"; 
var sharestorytitle="Title (optional)";
var commenttext="Add a Comment";
var sharewalltext="Share an idea"; 
// preload images
var myimages=new Array()
function preload(){
	for (i=0;i<preload.arguments.length;i++){
		myimages[i]=new Image();
		myimages[i].src=currURL + "/" + preload.arguments[i];
		//alert("preloading: " + myimages[i].src);
	}
}    
//alert("location.href is: " + location.href); 
// preload on the home page and the landing pages and on referral pages
var isReferPage = ( location.href.indexOf('.cfm')==-1 ||  location.href==app_URL + "/refer.cfm" ) ;
if ( location.href==app_URL+"/" ||  location.href==app_URL+"/home.cfm" || isReferPage ) { 
	//alert("preloading"); 
	preload("pgm/images/LogoThoughtBoxHP72.png","pgm/images/ReferralProgramIcon185.gif","pgm/images/PostStoriesIcon92x80.png","pgm/images/ReferralProgramIcon80.gif","pgm/images/ajax-loader.gif","pgm/images/ajax-loader-bar.gif"); 
} 
/* find browser */
var g6browser=navigator.userAgent.toLowerCase();
var g6isFirefox=(g6browser.indexOf("firefox")!=-1);
var g6isOpera=(!g6isFirefox && g6browser.indexOf("opera")!=-1);
var g6isIE=(!g6isOpera && g6browser.indexOf("msie")!=-1);
var g6isKonq=(!g6isIE && g6browser.indexOf('konqueror')!=-1);
var g6isSafari=(!g6isKonq && g6browser.indexOf('safari')!=-1)&&(g6browser.indexOf('mac')!=-1);
var g6isKhtml=(g6isSafari || g6isKonq); 
var g6isWinIE=g6isIE; 
/* alert("browser is: " + g6browser);  */
 
var screenWidth = screen.width;
var screenHeight = screen.height; 
  
function g6openWin(url, winName, w, h, wTop, wLeft) {  
	if (!w) var w=600;
	if (!h) var h=450;  
	// valign center if not given or 0
	if (!wTop) var wTop=  (screenHeight - (h+0)) / 2; // wTop = document.body.scrollTop+50;  
	// align center if not given or 0
	if (!wLeft) var wLeft =  (screenWidth - (w+0)) / 2;  
	if (!winName) var winName="mywin"; 
	window.open(url,winName,'resizable=1,scrollbars=1,width='+w+',height='+h+',top='+wTop+',left='+wLeft+',directories=0,location=0,menubar=0,status=0,toolbar=0')
} 

function leftTrim(sString)  {
	while (sString.substring(0,1) == ' ') {
	sString = sString.substring(1, sString.length);
	}
	return sString;
}
//keeps count of number characters in given field2
function chrCount(field,field2) {
	 field2.value=field.value.length;
}
//keeps field characters from overflowing
function chkCharsLen(field,nbr,countfield) { 
	if (field.value.length>nbr) field.value=field.value.substring(0,nbr);
	if (countfield) chrCount(field,countfield);
} 
// By default, forms are submitted by pressing the Enter/Return key from within an input type text field, when it is the ONLY text field in the form 
//Note that you should not add this event handler inside <TEXTAREA>s, as it by default will jump to the next line within itself when "Enter" is pressed.  
function checkEnter(evt) {
    evt = (evt) ? evt : event;
    var target = (evt.target) ? evt.target : evt.srcElement;
    var form = target.form;
    var charCode = (evt.charCode) ? evt.charCode :
        ((evt.which) ? evt.which : evt.keyCode);
    if (charCode == 13) { 
		  //alert("submitting form"); // does not send the "name" of the submit button, tho
           form.submit();
           return false; 
    }
    return true;
}

 
function ckOnLoad() {
 	hasFlashOnPage =  (dom && document.getElementById('toolTipHide'))? 1:0;
}
  
  // for ajax & other calls
function getContainer(dv) { 
	var container;
	if(dom){
		if(document.getElementById(dv)) container = document.getElementById(dv);  
	}
	else {
		var c=eval(dv);
		 if(c) container = c;
	}
	return container;
}
function getNextPostContainer(endofstring) {
	var useContainer=0;
	for (var i=1; i<=200; i++) { 
		if ( endofstring.indexOf('<span id="et">' + i + '</span>') >=0 ) {
			useContainer=i;
			break; 
		}
	}
    return useContainer; 
} 

function initalizetooltip() {
// placeholder in case it's called and we're not using the tool tips on the page
}
 
var didmoveplus=false;
var didmoveminus=false; 

function movable(id,vpx) { // move given vertical px up (-) or down(+)
	if(dom && document.getElementById(id).style.top) {   
			var ok=0;
			if(vpx>=0 && !didmoveplus) {
				ok=1;
				didmoveplus=true;
			}
			else if (!didmoveminus) { 
				didmoveminus=true;
				ok=1;
			} 
			if(ok) {
				var zTop=document.getElementById(id).style.top;
				zTop=(zTop.substring(0,(zTop.length-2)) * 1) + vpx;// strip off px, *1 to make it a number, and add the vertical px number  
				//alert("moving " + id + " to: " +  zTop+'px');
				document.getElementById(id).style.top = zTop+'px';
			}
	}
}
// for stories and mini-Net (wall)
function expandPostArea(formelem,rOrw) {  
		if(rOrw=='r' && formelem.value==sharestorytext)  formelem.value='';
		else if(rOrw=='w' && formelem.value==sharewalltext)  formelem.value='';
		else if(rOrw=='c' && formelem.value==commenttext)  formelem.value='';
		formelem.style.overflow = 'auto';
		formelem.style.height=62+'px';
		//formelem.style.fontWeight='normal';
		//formelem.style.fontSize=13+"px";
		formelem.style.color='#000000';  
}  
function resetPostArea(formelem,rOrw) { 
		if(rOrw=='w') formelem.value=sharewalltext;
		else if(rOrw=='r') formelem.value=sharestorytext; 
		else if(rOrw=='c') formelem.value=commenttext;
		formelem.style.lineHeight="normal";
		formelem.style.color='#606060'; 
		formelem.style.overflow='hidden';
		formelem.style.height=32+'px'; 
		formelem.style.fontWeight='normal';   
}
function resetPostTitle(formelem) { 
	formelem.value=sharestorytitle;
	formelem.style.color='#606060'; 
	formelem.style.lineHeight="normal";
} 
 function resetPostTopic(formelem) { 
	formelem.selectedIndex=0;  
} 

//  globals
var zpid=0; 
var zpdid=0;
//these are just the names of the div id on the containers, not the container objects themselves
var errSpace;
var commForm;
var postForm;
var commAnswSpace;
var loadSpace;
var loadSpace2;
var blockSpace; 
  
var blankoutSpace2=null;
var blankoutSpace3=null;
var showSpace2=null;
var showSpace3=null;

var zrated;
var zloggedin;
var ztopfusername;
var zisOnMyGain6Page; 
var zisOnAGain6Page; 
var commentFormOpen;
var ztextportion;
 

//comment functions
function openComment(pdid,rated,loggedin,topfusername,isOnAGain6Page) {    
	// globals
	zpdid=pdid;
	zrated=rated;// can be 0
	zloggedin=loggedin;
	ztopfusername=topfusername;
	zisOnAGain6Page=isOnAGain6Page;
	if(!loggedin) { 
		var lnk=app_URL+'/';
		if (isOnAGain6Page) { 
				//alert("Please log in or join gain6 to make your comments.");
				lnk=lnk + "join.cfm"; 
		}
		else { // not on gain6 page 
				if(topfusername.length >=2) lnk=lnk + topfusername;
				document.location.href=lnk;
		}
		document.location.href=lnk;
	}
	//logged in:
	else if(getContainer('divCommentForm'+pdid)) { 
			getContainer('divCommentForm'+pdid).style.display='block'; // open the div space where the form is 
			commentFormOpen=1;//global
			var theForm=eval('document.form' + pdid);// set the form itself
			commForm=theForm;// global 
			if(getContainer('rate1Icon'+pdid)) { // if 1st one is there, then they all are there
					unsetRating(pdid,theForm);
					if(getContainer("rate"+rated+"Icon"+pdid)) getContainer("rate"+rated+"Icon"+pdid).style.backgroundColor="yellow"; 
			} 
			if(theForm && theForm.CommentRating) { // keep this after the unset above
				theForm.CommentRating.value=rated;  // could be 0 if just commenting again 
				//alert ("the form.CommentRating.value is: " + theForm.CommentRating.value);
			}
			if(getContainer('ratewords'+pdid)) {
					var unsetOption='<a href="javascript:void(0);" onClick="unsetRating('+ pdid + ')" class="tinyGray">UnRate</a>';// it will figure out the form from pdid
					getContainer('ratewords'+pdid).style.display='block';
					if(rated==5) getContainer('ratewords'+pdid).innerHTML='I love it!' + ' ' + unsetOption;
					else if (rated==4) getContainer('ratewords'+pdid).innerHTML='I like it.' + ' ' + unsetOption;
					else if (rated==3) getContainer('ratewords'+pdid).innerHTML='It\'s Okay' + ' ' + unsetOption;
					else if (rated==2) getContainer('ratewords'+pdid).innerHTML='I don\'t like it' + ' ' + unsetOption;
					else if (rated==1) getContainer('ratewords'+pdid).innerHTML='Oh No!' + ' ' + unsetOption;
					
					if(getContainer('ratewordsCommentSpace'+pdid) ) {  
						rateCommSpace='ratewordsCommentSpace'+pdid;// global 
						 if(getContainer(rateCommSpace).innerHTML.indexOf('openComment(') > 0) {  
							 getContainer(rateCommSpace).innerHTML = '<a href="javascript:void(0);" onClick="closeComment('+ pdid + ',0)" class="tinyGray">Close Comment Box<img src="'+app_URL+'/pgm/images/arrowUp8.png" width="8" height="8" border="0" style="margin-left:2px"></a>'; 
						}
					}  
			}
			else {
					// no ratewords section means they are logged in and it says "add a comment" , so change it now to say close comment
					if(document.getElementById('divCommentAnswSpace'+pdid) ) {  
						commAnswSpace='divCommentAnswSpace'+pdid;// global 
						 if(getContainer(commAnswSpace).innerHTML.indexOf('openComment(') > 0) {  
							 getContainer(commAnswSpace).innerHTML = '<a href="javascript:void(0);" onClick="closeComment('+ pdid + ',0)" class="tinyGray">Close Comment Box<img src="'+app_URL+'/pgm/images/arrowUp8.png" width="8" height="8" border="0" style="margin-left:2px"></a>'; 
						}
					} 
			} 
	}
}
function setRating(isloggedIn,pdid,rated,isOnAGain6Page,tfID,topfusername,lid,fu) { //1,512,1,1,76,'kristi'
	if(getContainer('ratewords'+pdid) && (rated>=1 && rated<=5) ) { 
			zloggedin=isloggedIn; 
			zisOnAGain6Page=isOnAGain6Page;
			if(!isloggedIn) { 
					var lnk=app_URL+'/';
					if (isOnAGain6Page) {  
							if(!tfID)  alert("Please log in or join gain6 now to rate this blog post.");
							else  lnk=lnk + "join.cfm?tf="+tfID;  
					}
					else { // not on gain6 page 
							if(topfusername.length >=5) lnk=lnk + topfusername; 
					}
					document.location.href=lnk;
			}
			else {//logged in 
					var unsetOption='<a href="javascript:void(0);" onClick="unsetRating('+ pdid + ')" class="tinyGray">UnRate</a>';
					unsetOption=''; // override until I get unsetRating ajax going
					
					if(rated==5) getContainer('ratewords'+pdid).innerHTML='I love this!' + ' ' + unsetOption;
					else if (rated==4) getContainer('ratewords'+pdid).innerHTML='I like this.' + ' ' + unsetOption;
					else if (rated==3) getContainer('ratewords'+pdid).innerHTML='This is Okay' + ' ' + unsetOption;
					else if (rated==2) getContainer('ratewords'+pdid).innerHTML='I don\'t really like this' + ' ' + unsetOption;
					else if (rated==1) getContainer('ratewords'+pdid).innerHTML='Oh No!' + ' ' + unsetOption;  
					
					getContainer('rateIcons'+pdid).style.display='none'; 
					getContainer('ratewords'+pdid).style.display='block'; 
					 
					if (!xmlhttp) xmlhttp = aaGetXmlHttpRequest();
					if (!xmlhttp) return;  
					loadSpace='rateStats'+pdid;
					errSpace='ratewords'+pdid
					var qry = 'lid='+lid+'&fu='+fu+'&rating='+rated+'&postdid='+pdid;
					var url = 'Ajax_ratePost.cfm?' + qry; 
					ajaxPreloader(loadSpace, 'left', 0,'bar');
					//if(isK) alert ("sending url: " + url);
					xmlhttp.open('GET', url, true);
					xmlhttp.onreadystatechange = fillGivenSpace;
					xmlhttp.send(null);  
					return false;   
			}//li
	} //containers
} 
function unsetRating(pdid) {
	// reset the rating to 0 and reset icons and rating words, too 
	 if(getContainer("rate1Icon"+pdid)) {
		 	for(i=1;i<=5;i++) if(getContainer("rate"+i+"Icon"+pdid)) getContainer("rate"+i+"Icon"+pdid).style.border="0px"; 
			if(getContainer('rateIcons'+pdid)) getContainer('rateIcons'+pdid).display='block';   
			if(getContainer('ratewords'+pdid)) {
				getContainer('ratewords'+pdid).innerHTML='';
				getContainer('ratewords'+pdid).style.display='none';
			}
			// ajax to find my rating for this post based on cookie.fid and pdid and delete it, there should only be 1
			if(!theForm) var theForm=eval('document.form' + pdid); 
			if(theForm && theForm.CommentRating)  theForm.CommentRating.value=0;
	}
}
function closeComment(pdid,doFullReset) {  
	if(!pdid) return;
	var theForm=eval('document.form' + pdid); 
	// reset the form
	if(theForm) {  
		if(doFullReset) { // reset the answers, too
				theForm.Comment.style.color='#606060';
				theForm.Comment.value=commenttext;   
				if(theForm.CommentRating) {
						 unsetRating(pdid,theForm); 
				}
				if(theForm.CommentAnswer) theForm.CommentAnswer.value=''; 
		}
		else if(theForm.Comment.value.length==0) {
				theForm.Comment.value=commenttext; 
				theForm.Comment.style.color='#606060'; 
		} // full reset
	
		// hide the space the form is in
		if(dom && document.getElementById('divCommentForm'+pdid)) {
			 getContainer('divCommentForm'+pdid).style.display='none';  
		}
	}// form exists
	commentFormOpen=0;// global
	
	// if the answer space is available, and has Close in it, then change it so they can click it to open it again, if not Cose it might have rating icons, leave them
	if(dom && document.getElementById('divCommentAnswSpace'+pdid) ) {  
			if(getContainer('divCommentAnswSpace'+pdid).innerHTML.indexOf('closeComment(') > 0) {  
					var whichcontainer = getContainer('divCommentAnswSpace'+pdid); 
					
					// but wait, we could actually be into the 'ratewordsCommentSpace'+pdid which is inside of the 'divCommentAnswSpace'+pdid
					if(document.getElementById('ratewordsCommentSpace'+pdid) ) {   
							 containerRateCommSpace = getContainer('ratewordsCommentSpace'+pdid); 
							 if(containerRateCommSpace.innerHTML.indexOf('closeComment(') > 0) {  
							 	 var whichcontainer = containerRateCommSpace; // yes, so switch the container to this one instead
							}  
					}   
					if(zloggedin) var youra='a';
					else var youra='Your'; 
					whichcontainer.innerHTML = '<a href="javascript:void(0);" onClick="openComment('+pdid+','+zrated+','+zloggedin+',\''+ztopfusername+'\','+zisOnAGain6Page+')" class="tinyGray">Add '+youra+' Comment<img src="'+app_URL+'/pgm/images/arrowDown8.png" width="8" height="8" border="0" style="margin-left:2px"></a>'; 
			} 
	}
	//alert ("closed it");
} 
function showCommLinks(commid) {
	if(dom) {
		if (document.getElementById('divCommLinkSpace'+commid))  document.getElementById('divCommLinkSpace'+commid).style.visibility='visible';
	}
	else {
		var dv=eval('divCommLinkSpace'+commid);
		if(dv) dv.style.visibility='visible';
	}
}
function hideCommLinks(commid) {
	if(dom) {
		if (document.getElementById('divCommLinkSpace'+commid))  document.getElementById('divCommLinkSpace'+commid).style.visibility='hidden';
	}
	else {
		var dv=eval('divCommLinkSpace'+commid);
		if(dv) dv.style.visibility='hidden';
	}
}


function reportAbuse(wh,id) {
	var zurl=app_URL + '/pop_reportAbuse.cfm?wh='+wh+'&id='+id;
	g6openWin(zurl, 'abusewin') 
} 
// for mini-Net 
var zisOnMyWall;
//comment functions for mini-Net 
function openWallComment(pid,loggedin,isOnMyWall) {    
	// globals
	zpid=pid; 
	zloggedin=loggedin; 
	zisOnMyWall=isOnMyWall;
	if(!loggedin) {  
		var lnk=app_URL+'/login.cfm?do=logout';
		document.location.href=lnk; // better be logged in if you're on the mini-Net 
	}
	//logged in:
	else if(dom && document.getElementById('divCommentForm'+pid)) { 
			document.getElementById('divCommentForm'+pid).style.display='block'; // open the div space where the form is
			commentFormOpen=1;//global
			var theForm=eval('document.form' + pid);// set the form itself
			commForm=theForm;// global 
			if(document.getElementById("rate1Icon"+pid)) { // if 1st one is there, then they all are there
					unsetRating(pid,theForm);
					if(document.getElementById("rate"+rated+"Icon"+pid)) document.getElementById("rate"+rated+"Icon"+pid).style.border="2px solid #ff6501"; 
			} 
			 
			if(document.getElementById('ratewords'+pid)) { 
					document.getElementById('ratewords'+pid).style.display='block'; 
					if(document.getElementById('ratewordsCommentSpace'+pid) ) {  
						rateCommSpace='ratewordsCommentSpace'+pid;// global 
						 if(getContainer(rateCommSpace).innerHTML.indexOf('openComment(') > 0) {  
							 getContainer(rateCommSpace).innerHTML = '<a href="javascript:void(0);" onClick="closeWallComment('+ pid + ',0)" class="tinyGray">Close Comment Box<img src="'+app_URL+'/pgm/images/arrowUp8.png" width="8" height="8" border="0" style="margin-left:2px"></a>'; 
						}
					}  
			}
			else {
					// no ratewords section means they are logged in and it says "add a comment" , so change it now to say close comment
					if(document.getElementById('divCommentAnswSpace'+pid) ) {  
						commAnswSpace='divCommentAnswSpace'+pid;// global 
						 if(getContainer(commAnswSpace).innerHTML.indexOf('openWallComment(') > 0) {  
							 getContainer(commAnswSpace).innerHTML = '<a href="javascript:void(0);" onClick="closeWallComment('+ pid + ',0)" class="tinyGray">Close Comment Box<img src="'+app_URL+'/pgm/images/arrowUp8.png" width="8" height="8" border="0" style="margin-left:2px"></a>'; 
						}
					} 
			} 
	}
} 
function closeWallComment(pid,doFullReset) {  
	if(!pid) return;
	var theForm=eval('document.form' + pid); 
	// reset the form
	if(theForm) {   
		if(doFullReset || theForm.Comment.value.length==0) { 
				theForm.Comment.style.color='#606060';
				theForm.Comment.value=commenttext;    
				//alert("reset the form");
		} 
		// hide the space the form is in
		if(dom && document.getElementById('divCommentForm'+pid)) {
			 document.getElementById('divCommentForm'+pid).style.display='none';  
		}
	}// form exists
	commentFormOpen=0;// global 
	// if the answer space is available, and has Close in it, then change it so they can click it to open it again, if not Cose it might have rating icons, leave them
	if(dom && document.getElementById('divCommentAnswSpace'+pid) ) {  
			var whichcontainer = getContainer('divCommentAnswSpace'+pid);  
			if(whichcontainer.innerHTML.indexOf('closeWallComment(') > 0) {   
				whichcontainer.innerHTML = '<a href="javascript:void(0);" onClick="openWallComment('+pid+','+zloggedin+','+zisOnMyWall+')" class="tinyGray">Add a Comment<img src="'+app_URL+'/pgm/images/arrowDown8.png" width="8" height="8" border="0" style="margin-left:2px"></a>'; 
			} 
	} 
}  
function getPostTextExerpt(txt,porc,id,isForWall,isOnAGain6Page,isInIFrame) { 
	if (!xmlhttp) xmlhttp = aaGetXmlHttpRequest();
	if (!xmlhttp) return;     
	if(porc=='p') {
		loadSpace='divTextSpace'+id; 
	}
	else if(porc=='c') {
		loadSpace='divCommTextSpace'+id;
	}
	else {
		return false;
	}  
	if(isForWall!=0 && isForWall!=1) isForWall=0;
	if(isInIFrame!=0 && isInIFrame !=1) isInIFrame=0;
	zisOnAGain6Page = isOnAGain6Page; 
	errSpace=loadSpace;
	var zVale=encodeURIComponent(txt);  
	var qry = 'ztxt='+zVale+'&commOrPost='+porc+'&zID='+id+'&EorF=e&isForWall='+isForWall+ '&isOnAGain6Page='+isOnAGain6Page+'&isInIFrame='+isInIFrame;
	var url = 'Ajax_getPostTextExerptOrFull.cfm?' + qry; 
	//ajaxPreloader(loadSpace, 'center', 0,'wheel');
	xmlhttp.open('GET', url, true);
	xmlhttp.onreadystatechange = fillGivenSpace;  
	xmlhttp.send(null);  
	return false;  
}
function getPostTextFull(txt,porc,id,isForWall,isOnAGain6Page,isInIFrame) { 
	if (!xmlhttp) xmlhttp = aaGetXmlHttpRequest();
	if (!xmlhttp) return;    
	if(porc=='p') {
		loadSpace='divTextSpace'+id;
	}
	else if(porc=='c') {
		loadSpace='divCommTextSpace'+id;
	}
	else {
		return false;
	}   
	if(isForWall!=0 && isForWall!=1) isForWall=0;
	if(isInIFrame!=0 && isInIFrame !=1) isInIFrame=0;
	zisOnAGain6Page = isOnAGain6Page;
	errSpace=loadSpace;
	var zVale=encodeURIComponent(txt);  
	var qry = 'ztxt='+zVale+'&commOrPost='+porc+'&zID='+id+'&EorF=F&isForWall='+isForWall+ '&isOnAGain6Page='+isOnAGain6Page+'&isInIFrame='+isInIFrame;
	var url = 'Ajax_getPostTextExerptOrFull.cfm?' + qry; 
	 //ajaxPreloader(loadSpace, 'center', 0,'wheel');
	xmlhttp.open('GET', url, true);
	xmlhttp.onreadystatechange = fillGivenSpace;  
	xmlhttp.send(null);  
	return false;  
}  
function setCFCookie(cookiename,cookievalue,cookieexpires) { 	  
	if (!xmlhttp) xmlhttp = aaGetXmlHttpRequest();
	if (!xmlhttp) return false;  
	var cookievaluee=encodeURIComponent(cookievalue);  
	var cookieexpirese=encodeURIComponent(cookieexpires); 
	var qry = 'cookiename=' + cookiename+'&cookievalue='+cookievaluee+'&cookieexpires='+cookieexpirese;
	var url = 'Ajax_setCookie.cfm?'+ qry;   
	xmlhttp.open('GET', url, true);
	xmlhttp.onreadystatechange = fillNothing;
	xmlhttp.send(null);  
	return false;
}   
function fillNothing() { 
   if(xmlhttp.readyState == 4 && xmlhttp.status == 200) { 
		var str=xmlhttp.responseText; 
		//if(isK&&0) alert("returned ok: "+ str);
		var posE=str.indexOf('<span id="et">0</span>');  
		if(posE>=0&&str.length > 0) {
			str=str.substring(0,posE);
			if(isK&&1) alert("K: Error returned: " + str);
		}
   }
}
function sendToFriend(file,title,wh) { 
	 //wh p=page a=article
	 loadSpace='sendSpace';
	 var container = getContainer(loadSpace);  
	 var h=400;
	 var w=358;
	 if(container) { 
		 var wTop =  ((screenHeight - (h+0)) / 2) - 80;
	     var wLeft =  ((screenWidth - (w+0)) / 2) - 0;
		 var zFilee=encodeURIComponent(file);  
		  var zTitlee=encodeURIComponent(title);  
		 var qry="wh="+wh+"&zfile="+zFilee+"&ztitle="+zTitlee;
		 var sorc=app_URL+'/Ajax_sendToFriend.cfm?'+qry; 
		 var newHTML = '<div style="position:absolute;z-index:900;top:'+wTop+'px;left:'+wLeft+'px;"><iframe frameborder="0" src="' +  sorc + '" scrolling="No" height="' + h + '" marginheight="0" marginwidth="0" width="' + w + '"></iframe></div>';
		  container.innerHTML=newHTML;
		  container.style.display='block';
	  }
}
function closeSendSpace() {
	loadSpace='sendSpace';
	var container = getContainer(loadSpace);  
	 if(container) { 
 	   container.innerHTML = '';
	   container.style.display='none'; 
	 } 
}
function printContents(wcontentspace,title) {  
	if(dom&&getContainer(wcontentspace)) { 
		 var w=768;
		 var h=550; 
		var wTop =  ((screenHeight - (h+0)) / 2) - 20;
	    var wLeft =  ((screenWidth - (w+0)) / 2) - 0;
		 var zTitlee=encodeURIComponent(title);  
		var u=app_URL+'/popPrintContents.cfm?sp='+wcontentspace+'&ztitle='+zTitlee;
		g6openWin(u, 'printWin',w,h,wTop,wLeft); 
	}
}

 

function fillGivenSpace() { 
	   if(isK && xmlhttp.readyState == 4 && xmlhttp.status != 200) {
			var container;
		   	if(loadSpace)  container = getContainer(loadSpace);  
			else if (errSpace)  container = getContainer(errSpace);  
			if(container) container.innerHTML = xmlhttp.responseText + "<br>xmlhttp.status: " +xmlhttp.status;
			else alert("error: " +  xmlhttp.responseText + "xmlhttp.status: " +xmlhttp.status );  
			loadSpace2=null;//done with it (keep this inside readystatechange or it resets it before it uses it
	   } 
	   if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {    
	   		if(isK&&0)  alert("returned ok: " + xmlhttp.responseText);
			var posE = -1;
		    var str=xmlhttp.responseText; 
			var pos=str.indexOf('<span id="et"></span>');   
			var container;
			 if(pos >= 0) {   
			 		str=str.substring(0,pos);
					if(str.length > 0 && str.length < 100)  str= '<span style="color:green;">' + str + '</span>';  
					if(loadSpace2)  container = getContainer(loadSpace2);//if load space is not null, us it.
					else container = getContainer(loadSpace);  
			}
			else {
					var posE=str.indexOf('<span id="et">0</span>');  
					if(posE>=0) str=str.substring(0,posE);
					if(str.length > 0)  str= '<span style="color:red;">' + str + '</span>'; 
					container = getContainer(errSpace); 
			} 
			if(container) {
					if( str.length > 0) {
						container.style.display='block';
						container.innerHTML = str;  
					}
					else {
						container.style.display='none';
						if(isK && 0) alert("K: Nothing returned, container closed, OK");
					} 
					if(posE<0) {
							if(errSpace) {
								 var Errcontainer = getContainer(errSpace);  
								 if(Errcontainer && Errcontainer.innerHTML &&
								   (Errcontainer.innerHTML.indexOf("ajax-loader.gif")>0 || Errcontainer.innerHTML.indexOf("ajax-loader-bar.gif")>0) ) {
								 		Errcontainer.style.display='none';//remove any preloader
								 }
							 }
					
							if(blankoutSpace2) {
								var container2 = getContainer(blankoutSpace2);  
								if(container2) container2.style.display='none'; 
								blankoutSpace2=null;//done with it
							}
							if(blankoutSpace3) {
								var container3 = getContainer(blankoutSpace3);  
								if(container3) container3.style.display='none'; 
								blankoutSpace3=null;//done with it
							}
							if(showSpace2) {
								var container2 = getContainer(showSpace2);  
								if(container2) container2.style.display='block'; 
								showSpace2=null;//done with it
							}
							if(showSpace3) {
								var container3 = getContainer(showSpace3);  
								if(container3) container3.style.display='block'; 
								showSpace3=null;//done with it
							} 
					} 
					initalizetooltip();
			}
			else if(str.length > 0) { 
					if(isK) alert("K: no container and has a string" + str);
					else alert(str); 
			}
			else {
				if(isK&&0) alert("K: Nothing returned and no container");
			}   
			loadSpace2=null;//done with it (keep this inside readystatechange or it resets it before it uses it
		}    
}
