//document.onclick=process_link;
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0 
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function make_primary(hash,imagenum){
		return popup('image_resize.php?hash='+hash+'&image='+imagenum,'resizewin','width=700,height=650');
	}
function popup(url,name,args){
	eval(name + '= window.open("'+url+'","'+name+'","'+args+'");');
	return false;
}
	
function getXMLObj(){
	var Z=false;
	if(window.XMLHttpRequest){
		try{
			Z=new XMLHttpRequest()
		}catch(e){
			Z=false
		}
	}else if(window.ActiveXObject){
		try{
			Z=new ActiveXObject('Msxml2.XMLHTTP')
		}catch(e){
			try{
				Z=new ActiveXObject('Microsoft.XMLHTTP')
			}catch(e){
				Z=false
			}
		}
	}
return Z
}

function h(){
	if(http.readyState == 4){
		content_text = http.responseText;
		//document.getElementById(content_location).style.height="";
		document.getElementById(content_location).innerHTML = content_text;
		//scroll(0,0);
	}
} 
function load_content(cn,cl,args){
	return true;
	http=getXMLObj();
	content_name = cn; // the page name to load.
	content_location = cl; // site_content
	http.open("POST","getcontent.php",true);
	http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	str="content_name="+content_name+"&content_location="+content_location;
	if(args)str += "&args="+escape(args); //+"&phpshiznit=<?=session_id();?>";
	http.setRequestHeader('Content-Length',str.length);
	http.send(str);
	http.onreadystatechange = h;
	return false;
}
function load_content2(cn,cl,args){
	http=getXMLObj();
	content_name = cn; // the page name to load.
	content_location = cl; // site_content
	http.open("POST","getcontent.php",true);
	http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	str="content_name="+content_name+"&content_location="+content_location;
	if(args)str += "&args="+escape(args); //+"&phpshiznit=<?=session_id();?>";
	http.setRequestHeader('Content-Length',str.length);
	http.send(str);
	http.onreadystatechange = h;
	return false;
}
var content_location="";
var http;

function submit_form(){
	
}

function process_link(e){
	if (e.target.nodeName == 'A'){
		click_url = e.target.getAttribute('href');
		//return false;
	}
}

function submitform(form){
	return true;
	str = "";
	for (i=0;i<form.length;i++){
		str += form.elements[i].name + "=" + form.elements[i].value + "&";
	}
	formaction = form.action;
	cna = formaction.split("/");
	cnt = cna[cna.length-1];
	cnr = cnt.split("?");
	cns = cnr[0];
	cn = cns.replace(/.php/g,"");
	if(cnr[1])str += cnr[1];
	load_content(cn,"site_content",str);
	return false;
}

function submitNewWindow(wName, wWidth, wHeight)
{
  features = 'scrollbars=0,status=0,resizable=false,width=' + wWidth + ',height=' + wHeight;
  popWin = window.open('', wName, features);
	if(popWin.focus) { popWin.focus(); }
	return true;
}

if(window.attachEvent)
window.attachEvent("onload",setListeners);

function setListeners(){
	inputList = document.getElementsByTagName("INPUT");
	for(i=0;i<inputList.length;i++){
	  inputList[i].attachEvent("onpropertychange",restoreStyles);
	  inputList[i].style.backgroundColor = "";
	}
	selectList = document.getElementsByTagName("SELECT");
	for(i=0;i<selectList.length;i++){
	  selectList[i].attachEvent("onpropertychange",restoreStyles);
	  selectList[i].style.backgroundColor = "";
	}
}

function restoreStyles(){
if(event.srcElement.style.backgroundColor != "")
  event.srcElement.style.backgroundColor = "";
}

function create_chat_box(id,othername){
	eval ("popup('chat/popup.php?id="+id+"','chat_window_"+id+"','width=330,height=360,toolbar=no,location=no,resizable=no,scrollbars=no');");
	eval ("chat_window_"+id+".focus();");
}

function getFlashMovieObject(movieName)
{
  if (window.document[movieName]) 
  {
	return window.document[movieName];
  }
  if (navigator.appName.indexOf("Microsoft Internet")==-1)
  {
	if (document.embeds && document.embeds[movieName])
	  return document.embeds[movieName]; 
  }
  else 
  {
	return document.getElementById(movieName);
  }
}
function playsound() {
	var soundmovie2 = getFlashMovieObject("soundfile");
	if(soundmovie2)soundmovie2.Play();
}
function set_over(img,group,id){
	document.getElementById('message'+group).innerHTML = "Vote "+id;
	for(var x=id;x>0;x--){
		var chng = document.getElementById(group+'rate'+x);
		if(chng){
			chng.className = 'vote_ruby';
		}
	}
}
function set_out(img,group,gold){
	for(var x=1;x<=5;x++){
		var chng = document.getElementById(group+'rate'+x);
		if(chng){
			if(x<=gold){
				chng.className = 'vote_gold';
			}else{
				chng.className = 'vote_white';
			}
		}
	}
	document.getElementById('message'+group).innerHTML = "Vote for this!";
}
function set_vote(img,group,id){
	for(var x=1;x<=5;x++){
		var chng = document.getElementById(group+'rate'+x);
		if(chng){
			if(id>=x){
				chng.className = 'vote_ruby';
			}else{
				chng.className = 'vote_white';
			}
			// now disable the click
			chng.setAttribute('onmouseover',"");
			chng.setAttribute('onmouseout',"");
			chng.setAttribute('onclick',"");
		}
	}
	http=getXMLObj();
	http.open("POST","includes/rating_box.php",true);
	http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	str="vote=true&id="+group+"&value="+id;
	http.setRequestHeader('Content-Length',str.length);
	http.send(str);
	http.onreadystatechange = function(){
		document.getElementById('message'+group).innerHTML = "Vote Recorded";
	};
}
function open_big_table(){
	var objOverlay = document.getElementById('overlay');
	//var arrayPageSize = getPageSize();
	//var arrayPageScroll = getPageScroll();
	// set height of Overlay to take up whole page and show
	//objOverlay.style.width = ((arrayPageSize[0]) + 'px');
	//objOverlay.style.height = (arrayPageSize[1] + 'px');
	objOverlay.style.display = 'block';
	return false;
}
function update_big_table(){
	var objOverlay = document.getElementById('overlay');
	//var arrayPageSize = getPageSize();
	//var arrayPageScroll = getPageScroll();
	// set height of Overlay to take up whole page and show
	//objOverlay.style.width = ((arrayPageSize[0]-60) + 'px');
	//objOverlay.style.height = (arrayPageSize[1] + 'px');
}
function close_big_table(){
	update_status = true;
	var objOverlay = document.getElementById('overlay');
	var objOverlayC = document.getElementById('overlay_content');
	objOverlayC.innerHTML = '';
	objOverlay.style.display = 'none';
	return false;
}

function popup_message(username){
	open_big_table();
	var objOverlayC = document.getElementById('overlay_content');
	objOverlayC.innerHTML = '<table width="100%" border="0" cellpadding="3" cellspacing="0" class="popup"><tr><td><div style="text-align:center; color:#666699; font-size:14px;">Send a Message to: '+username+'</div><div style="position:relative; width:33px;top:-30px; right:0px;"><a href="#" onClick="return close_big_table();"><img src="images/popup_close.gif" align="right" width="30" height="29" border="0"></a></div></td></tr><tr height=50><td valign=middle align=center>Loading ... please wait </td></tr></table>';
	update_big_table();
	//post_data('ajax.php','type=atmoss&tm_number='+tmnumber,show_atmoss_data);
	return false;
}

