var IE = document.all?true:false
if (!IE) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getMouseXY;
var tempX = 0
var tempY = 0
///////////////preload certain images
if (document.images) {
	preload_image = new Image(16,16); 
	preload_image.src="/community/images/general/indicator.gif"; 
}
function getMouseXY(e) {
  if (IE) {
    tempX = event.clientX + document.body.scrollLeft
    tempY = event.clientY + document.body.scrollTop
  } else {
    tempX = e.pageX
    tempY = e.pageY
  }  
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}  
  return true
}
var f_afterprocd2="";
var f_elid="";
function tag_box() {
	//document.getElementById("div_tag_box").left=tempX;
	//document.getElementById('div_tag_box').style.overflow="visible";
	document.getElementById('div_tag_box').style.display = 'block';	
	document.getElementById('div_tag_box').style.top=tempY-66;
	document.getElementById('div_tag_box').style.left=tempX-66;
	document.tag_media_form.tx.value=tempX-getAbsoluteLeft('tag_img');
	document.tag_media_form.ty.value=tempY-getAbsoluteTop('tag_img');
}
function tag_box_click(pid) {
	document.tag_media_form['player'+pid+'x'].value=document.tag_media_form.tx.value;
	document.tag_media_form['player'+pid+'y'].value=document.tag_media_form.ty.value;
}
function xml_get_list(url,fcn,frm,fld,fldu,fldvt,fldvid,lvalue,fld_filler) {
	xml_pass=true;
	if (document[frm][fldu].options.length > 1) {
		xml_pass=false;
	}
	if((fld_filler!=null && fld_filler)) {
			xml_pass=true;
		}
	if (xml_pass) {
	document[frm][fldu].options.length=1;
	document[frm][fldu].options[0].text=".... Please Wait ";
	if (fld.indexOf(",",fld) >-1) {
	 	url=url+'?frm='+frm+'&cfts='+new Date();
		var index=0;
		var hit_start=0;
		pid=fld;
		while (index != -1) {
			index = pid.indexOf(",", index + 1);
			index2=index;
			if (index==1) {index2=0;}
			if (hit_start==0) {hit_start=-1;}
			if (index == -1 ) {index2=pid.length;}
			listpartid=pid.substring(hit_start+1,index2);
			url=url+'&'+listpartid+'='+document[frm][listpartid][document[frm][listpartid].selectedIndex].value
			hit_start= index;
		}
	}
	else {
		if (url.indexOf("?",1) ==-1) {
			url=url+'?frm='+frm+'&fld='+fld+'&fldv='+document[frm][fld][document[frm][fld].selectedIndex].value+'&cfts='+new Date();
		}
		else {
			url=url+'&frm='+frm+'&fld='+fld+'&fldv='+document[frm][fld][document[frm][fld].selectedIndex].value+'&cfts='+new Date();
		}
	}
	m_form=frm;
	m_fldu=fldu;
	m_fldvt=fldvt;
	m_fldvid=fldvid;
	if (lvalue!= null) {
		m_lvalue=lvalue;
	}
	try {
		document[frm].test.value=url;
	}
	catch(e) {}
	xmlhttp=null
	if (window.XMLHttpRequest) {xmlhttp=new XMLHttpRequest()}
	else if (window.ActiveXObject) {xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")}
	if (xmlhttp!=null){xmlhttp.onreadystatechange=eval(fcn);xmlhttp.open("GET",url,true);xmlhttp.send(null);}
	else{alert("Your browser does not support XMLHTTP.")}
	}
}
function xml_get_page (url,elid,afterprocd,procupdate) {
	if(afterprocd!=null ) {
		f_afterprocd2=afterprocd;
	}
	xmlhttp=null
	if((procupdate!=null && procupdate) || (procupdate==null)) {
		document.getElementById(elid).innerHTML='<table align="center"><tr><td><img src="http://community.2ksports.com/community/images/general/indicator.gif"></td></tr></table>';
	}
	f_elid=elid;
	if (url.indexOf("?") > 0) {
		url2=url+'&cfts='+new Date();
	}
	else {
		url2=url+'?cfts='+new Date();
	}
	try {
	document.lineupfrm.test.value=url;
	}
	catch(e) {};
	if (window.XMLHttpRequest) {xmlhttp=new XMLHttpRequest()}
	else if (window.ActiveXObject) {xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")}
	if (xmlhttp!=null){xmlhttp.onreadystatechange=xml_get_page_exe;xmlhttp.open("GET",url2,true);xmlhttp.send(null);}
	else{alert("Your browser does not support XMLHTTP.")}
	
}
function xml_get_page_exe () {
	if(checkReadyState(xmlhttp)) {
		try { //Internet Explorer 
			xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
			xmlDoc.async="false";
			xmlDoc.loadXML(xmlhttp.responseText);
		}
		catch(e) {
  			try {//Firefox, Mozilla, Opera, etc.
				parser=new DOMParser();
				xmlDoc=parser.parseFromString(xmlhttp.responseText,"text/xml");
			}
			catch(e) {alert(e.message)}
		}
		if (window.ActiveXObject) {
			document.getElementById(f_elid).innerHTML=xmlDoc.getElementsByTagName("pagedata")[0].firstChild.data
		}
		else {
			document.getElementById(f_elid).innerHTML=xmlDoc.getElementsByTagName("pagedata")[0].textContent;
		}
		try {
		if (xmlDoc.getElementsByTagName("recv_stexe")[0].firstChild.data !=null && xmlDoc.getElementsByTagName("recv_stexe")[0].firstChild.data.length > 0) {
			eval(xmlDoc.getElementsByTagName("recv_stexe")[0].firstChild.data);
		
		}
		}	catch (e) {}
		if (f_afterprocd2!=null && f_afterprocd2.length > 0) {
			eval(f_afterprocd2);
			f_afterprocd2="";
		}
	}
}

function checkReadyState(obj){
  if(obj.readyState == 4){
    if(obj.status == 200){
      return true;
    }
    else{
      alert("Problem retrieving XML data");
    }
  }
}
function onResponse_xml_list() 
{
  if(checkReadyState(xmlhttp))
  {
 
	 // code for IE
	if (window.ActiveXObject)
	  {
	  var response=new ActiveXObject("Microsoft.XMLDOM");
	  response.async="false";
	  response.loadXML(xmlhttp.responseText);
	  }
	// code for Mozilla, Firefox, Opera, etc.
	else
	  {
	var parser = new DOMParser();
	var response = parser.parseFromString(xmlhttp.responseText, "text/xml");
	  }
	x=response.getElementsByTagName("datarecord")
	document[m_form][m_fldu].options.length=(x.length);
	document[m_form][m_fldu].options[0].text="";
	document[m_form][m_fldu].options[0].value=0;
	for (i=0;i<x.length;i++) {
	  {
	  	
      try
        {
		document[m_form][m_fldu].options[i].text=x[i].getElementsByTagName(m_fldvt)[0].firstChild.data.replace(/&amp;/,'&'); 
		document[m_form][m_fldu].options[i].value=x[i].getElementsByTagName(m_fldvid)[0].firstChild.data; 
		 }
      catch (er)
        {
        }
      }
	}
	if (x.length ==1) {
		//document[m_form][m_fldu].selectedIndex=0;
		document[m_form][m_fldu].selectedIndex=0;
		if (document[m_form][m_fldu].onchange) {document[m_form][m_fldu].onchange();}
	}
	
	if (m_lvalue.length > 0) {
		document[m_form][m_fldu].options[0].text=m_lvalue;
		document[m_form][m_fldu].selectedIndex=0;
		//document[m_form][m_fldu].style.display = 'inline';
	}
  } 
  else {
  	document[m_form][m_fldu].options[0].text=document[m_form][m_fldu].options[0].text+".";
  }
}
function getAbsoluteLeft(objectId) {
	// Get an object left position from the upper left viewport corner
	// Tested with relative and nested objects
	o = document.getElementById(objectId)
	oLeft = o.offsetLeft            // Get left position from the parent object
	while(o.offsetParent!=null) {   // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent    // Get parent object reference
		oLeft += oParent.offsetLeft // Add parent left position
		o = oParent
	}
	// Return left postion
	return oLeft
}

function getAbsoluteTop(objectId) {
	// Get an object top position from the upper left viewport corner
	// Tested with relative and nested objects
	o = document.getElementById(objectId)
	oTop = o.offsetTop            // Get top position from the parent object
	while(o.offsetParent!=null) { // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent  // Get parent object reference
		oTop += oParent.offsetTop // Add parent top position
		o = oParent
	}
	// Return top position
	return oTop
}
var lpwid="";
var lpwpopup=0;
function dis_popup(pwid,opwid) {
	lpwpopup=1;
	if (lpwid !="") {
		document.getElementById(lpwid).style.display = 'none';
		lpwid="";
	}
	t_start=27;
	if (pwid=='menu_f_myprofile') {
		t_start=44;
	}
	if (lpwid!=opwid) {
		document.getElementById(opwid).style.top=parseInt(getAbsoluteTop(pwid)+t_start)+'px';
		document.getElementById(opwid).style.left=parseInt(getAbsoluteLeft(pwid))+'px';
		document.getElementById(opwid).style.display = 'block';
		lpwid=opwid;
	}
}

function dis_popup_close() {
	if (lpwpopup==0 && lpwid !="") {
		document.getElementById(lpwid).style.display = 'none';
		lpwid="";
	}
}

function dis_gen_popupinfo(txt) {
	if (document.getElementById('gen_popupinfo')==null) {
		newdiv = document.createElement("div");
		newdiv.className = "popupwindow";
		newdiv.id = "gen_popupinfo";
		document.body.appendChild(newdiv);
	}
	document.getElementById('gen_popupinfo').style.left=tempX+10;
	document.getElementById('gen_popupinfo').style.top=tempY-30;
	document.getElementById('gen_popupinfo').style.display = 'block';
	document.getElementById('gen_popupinfo').innerHTML = txt;
}
function dis_gen_popupinfo_hide() {
	document.getElementById('gen_popupinfo').style.display = 'none';
}
//----------------------XML POST URL--------------------//
function xml_post(obj,url,afterprocd) {
	var parameters="";
	var parametersc=0;
	if(afterprocd!=null && afterprocd.length > 0) {
		f_afterprocd=afterprocd;
	}
	for (var i = 0; i < obj.length; i++) {
		if (obj[i].type != "button") {
			pass_param=true;
			if (obj[i].type == "checkbox")
			{
				if (obj[i].checked) {
					pass_param=true;
				}
				else {
				pass_param=false;
				}
			}
			if (pass_param) {
				parametersc=parametersc+1;
				if (parametersc==1) {
					parameters=obj[i].name+"="+encodeURI(obj[i].value);
				}
				else {
					parameters=parameters+"&"+obj[i].name+"="+encodeURI(obj[i].value);
				}
			}
			
		}
	}
	xmlhttp = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         xmlhttp = new XMLHttpRequest();
         if (xmlhttp.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //xmlhttp.overrideMimeType('text/xml');
            xmlhttp.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!xmlhttp) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      xmlhttp.onreadystatechange = xml_post_proc;
      xmlhttp.open('POST', url, true);
      xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      xmlhttp.setRequestHeader("Content-length", parameters.length);
      xmlhttp.setRequestHeader("Connection", "close");
      xmlhttp.send(parameters);
}
function xml_post_proc() {
   	if(checkReadyState(xmlhttp)) {
		 	 // code for IE
			if (window.ActiveXObject)
			  {
			  var response=new ActiveXObject("Microsoft.XMLDOM");
			  response.async="false";
			  response.loadXML(xmlhttp.responseText);
			  }
			// code for Mozilla, Firefox, Opera, etc.
			else
			  {
			var parser = new DOMParser();
			var response = parser.parseFromString(xmlhttp.responseText, "text/xml");
			  }
            result = xmlhttp.responseText;
			 if (response.getElementsByTagName("recvresult")[0].firstChild.data=="true") {
				if (f_afterprocd.length > 0) {
					eval(f_afterprocd);
				}
			 } else {
			 alert('There was the following error: '+response.getElementsByTagName("recv_error")[0].firstChild.data);
	}
	}
}
//----------------------XML POST URL--------------------//
function hndmsovr(tobj,tclass) {
	tobj.className=tclass;
}
function fran_article_delete(lid,aid) {
	var answer = confirm("Are you sure you want to remove this article?");
		if (answer){
			document.location='news.cfm?l='+lid+'&delete='+aid
		}
}
function delete_media(mid) {
	var answer = confirm("Are you sure you want to delete this media?");
		if (answer){
			document.location='/community/user/home.cfm?deletemediaid='+mid;
		}
}
function delete_general(question,url) {
	var answer = confirm(question);
		if (answer){
			document.location=url;
		}	
}
var x_tobj="";
var tforums_my2klast=new Array();
function forums_my2klink(tpostid,tobj,turl) {
	if (tforums_my2klast[tpostid]==null) {
		tforums_my2klast[tpostid]="media";
	}
	
	
	//alert(document.getElementById('my2kp'+tpostid+'_'+tobj).className);
	document.getElementById('my2kp'+tpostid+'_'+tforums_my2klast[tpostid]).className = 'my2kheadoff';
	document.getElementById('my2kp'+tpostid+'_'+tobj).className = 'my2kheadon';
	if (tobj != "usersig") {
		xml_get_page(turl,'forums_2kspace_post_'+tpostid);
	}
	else {
		document.getElementById('forums_2kspace_post_'+tpostid).innerHTML=document.getElementById('my2kp'+tpostid+'_sigcache').innerHTML
	}
	tforums_my2klast[tpostid]=tobj;
}
function comment_quote (cid,commenttxt,username) {
	document.commentform.comment.value='[quote]'+username+' posted:'+commenttxt+'[/quote]';
}