/* Some fancy redirection for E-creations static pages */
strID = window.document.location.toString();
//document.write(strID);
/*if (strID.search("members2/PublisherIndex/")) {
	window.location = "http://www.moneypit.com/ecreations-redirect-test.php"
}*/

/* Image Mouseover */

var tempimg = '';
var tempdir = '';
var tempext = '';

function Img(img,dir) {
	if (img) {
		if (dir) dir = '/'+ dir +'/';
		else dir = '/';
		var ext = document[img].src.substring(eval(document[img].src.length-4),document[img].src.length);
		document[img].src = 'http://www.moneypit.com/images'+ dir +'nav_'+ img +'_on'+ ext;
		tempimg = img;
		tempdir = dir;
		tempext = ext;
	}
	else {
		document[tempimg].src = 'http://www.moneypit.com/images'+ tempdir +'nav_'+ tempimg + tempext;
	}
}

/* PopUp */

function Popup(page,width,height,scroll) {
	if (!scroll) { scroll = 0 }
	//var name = page.substring(0,(page.length - 4));
	random_num = (Math.round((Math.random()*9)+1))
	var name = random_num;
	window.open(page,name,'toolbar=0,scrollbars='+ scroll +',location=0,statusbar=0,menubar=0,resizable=0,width='+ width +',height='+ height);
}

/* Expand/Collapase */

var vTempPostid = "";

function ExpandCollapseNav(vPostid) { 
	var vWhichpost = document.getElementById(vPostid);
	if (vTempPostid) {
		var vWhichTemppost = document.getElementById(vTempPostid);
		if (vWhichTemppost.className=="nav_side postshown") { 
			vWhichTemppost.className="nav_side posthidden";
		}
	}
	//else { 
		vWhichpost.className="nav_side postshown"; 
		vTempPostid = vPostid;
	//} 
}

/* Show/Hide divs onClick */

function ExpandCollapse(vPostid) { 
   var vWhichpost = document.getElementById(vPostid);  
   if (vWhichpost.className=="postshown") { 
      vWhichpost.className="posthidden"; 
   } 
   else { 
      vWhichpost.className="postshown"; 
   } 
}

/* Collapse blank tags */

function CollapseTag(vContent) {
	if (vContent == "&nbsp;") document.write("");
	else document.write(vContent);
}

/* Change Form */

function changeForm(url,field) {
  if (field == 1) {
    document.mpbasicsearch.belowcategoryid.checked = false;
  }
  else {
    document.mpbasicsearch.allcontent.checked = false;
  }

  document.mpbasicsearch.action = url;
  document.mpbasicsearch.searchkeywords.value = document.mpbasicsearch.searchword.value;
}

function getChild(ids){
	if(document.getElementById) return document.getElementById(ids).firstChild;
	return null;
}

function dataCD(ids){
	var child=getChild(ids);
	if(child) alert(child.data);
	else notSupported();
}

function getChild2(ids){
	if(document.getElementById) return document.getElementById(ids).firstChild;
	return null;
}

function CapitalizeText(vText) {
	var vTextText = '';
	var vText = vText.split(' ');
	for(var j=0; j<vText.length; j++) {
		vTextText += vText[j].substring(0,1).toUpperCase() + vText[j].substring(1,vText[j].length) + ' ';
	}
	return vTextText.substring(0,vTextText.length-1);
}

function TitlizeTag(vTag) {
	var vText = document.getElementsByTagName(vTag);
	for (var i=0; i<vText.length; i++) {
		var vTextLength = vText[i].firstChild.length;
		var vTextData = vText[i].firstChild.data.toLowerCase();
		var vTextTemp = CapitalizeText(vTextData);
		vText[i].firstChild.replaceData(0,vTextLength,vTextTemp);
	}
}

/* Mediaplayer Ajax */

var xmlHttp;

function UpdatePlayer() {
	
	selectdate = document.mediaform.selecteddate.options[document.mediaform.selecteddate.selectedIndex].value;
	if (selectdate == '') selectdate = '11-24-07';
	if (document.mediaform.hour[1].checked) selecthour = 2;
	else selecthour = 1;

	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) {
		alert ("Your browser does not support AJAX!"); // Alert the user...
		return;
	}
	var url="inc_mediaplayer.php"; // This is the page you will be calling to output HTML within the element "mediaplayer"...
	url=url+"?date="+selectdate; // Append variable name & string to be recieved by said page...
	url=url+"&hour="+selecthour; // Append variable name & string to be recieved by said page...
	url=url+"&sid="+Math.random(); // Append Random ID (required for some reason?)...
	xmlHttp.onreadystatechange=stateChanged; 
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
} 

function stateChanged() {
	if (xmlHttp.readyState==0) { 
		document.getElementById("mediaplayer").innerHTML="Sending..."
	} 
	if (xmlHttp.readyState==1 || xmlHttp.readyState==2 || xmlHttp.readyState==3) { 
		document.getElementById("mediaplayer").innerHTML="Loading...";
	}
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
		document.getElementById("mediaplayer").innerHTML=xmlHttp.responseText;
	}
}

function GetXmlHttpObject() {
	var xmlHttp=null;
	try { // Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e) { // Internet Explorer
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}

function Debug() {
}