function FieldLength(cFrom, cTo, cPivot) {
  if(cFrom.value.length < cPivot) {
    cTo.value = cPivot - cFrom.value.length;
  } else {
    cTo.value = 0;
  }
}
function ConfirmDelete(pURL, pType) {
  if(confirm("Are you sure you want to delete this " + pType + "?")) {
    location.replace(pURL);
  }
}
function LoadDownload(pUrlNew, pUrlCur) {
  window.open(pUrlNew);
  window.location = pUrlCur;
}
function IEPNGTrans(i) {
  if (navigator.appName == "Microsoft Internet Explorer") {
	  if (i.src.toLowerCase().indexOf(".png") != -1) {
			i.parentElement.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+i.src+"')";
			i.parentElement.style.width=i.width;
			i.parentElement.style.width=i.height;
			i.style.visibility="hidden";
		}
	}
}
function imgSize(obj) {
	if (obj.getAttribute("truew") && obj.getAttribute("trueh")) {
		obj.width = obj.getAttribute("truew");
		obj.height = obj.getAttribute("trueh");
		obj.style.cursor = "";
		obj.alt="Image";
	}
}
function scalePic(pic,max) {
	if (pic.width > max || pic.height > max) {
	  if (pic.width >= pic.height) {
	  	diff = pic.width - max;
	  	scale = ((pic.height * 100) / pic.width)/100;
	  	pic.width = max;
	  	pic.height = max * scale;
	  }	
	  if (pic.width < pic.height) {
	  	diff = pic.height - max;
	  	scale = ((pic.width * 100) / pic.height)/100;
	  	pic.height = max;
	  	pic.width = max * scale;
	  }	
	}	
}
function imgLoad(obj) {
	if(parseInt(obj.width) > 500 || parseInt(obj.height) > 500) {
 		obj.setAttribute("truew",obj.width);
 		obj.setAttribute("trueh",obj.height);
 		obj.style.cursor = "pointer";
 		obj.alt = "Picture has been scaled to fit.\nClick to Enlarge";
 		obj.title = "Picture has been scaled to fit.\nClick to Enlarge";
 		scalePic(obj,500);
	}
	obj.style.visibility = "visible";
	obj.style.position = "";
}
function imgErr(obj) {
	obj.style.visibility = "visible";
	obj.style.position = "";;
	obj.alt = "Could not load: " + obj.src;
}
var clicklock = false;
function starBar() {
	document.write("<input type=\"hidden\" value=\"5\" name=\"rating\" id=\"ratingelement\">")
	document.write("<img style=\"cursor:pointer\" align=\"absmiddle\" width=18 height=17 src=\"sitegfx/widget.gif\" alt=\"0/5\" title=\"0/5 [Click to lock]\" border=0 onMouseOver=\"if(!clicklock){setStars(0)}\" onClick=\"clicklock=true;setStars(0)\">")
	for (i=0;i<5;i++) {
		document.write("<img style=\"cursor:pointer\" align=\"absmiddle\" id=\"rstar"+i+"\" width=18 height=17 src=\"sitegfx/ratingon.png\" alt=\"" + (i+1) + "/5\" title=\"" + (i+1) + "/5 [Click to lock]\" border=0 onMouseOver=\"if(!clicklock){setStars("+(i+1)+")}\" onClick=\"clicklock=true;setStars("+(i+1)+")\">")
	}
}
function setStars(n) {
	for (i=0;i<5;i++) {
		document.getElementById("rstar"+i).src="sitegfx/ratingoff.png";
	}
	for (i=0;i<n;i++) {
		document.getElementById("rstar"+i).src="sitegfx/ratingon.png";
	}
	document.getElementById("ratingelement").value=n;
}
function showTags(i,t) {
	//
}

var MyInt = 0;
function commentRating() {
	MyInt++;
	document.getElementById("rating0").firstChild.nodeValue = MyInt + " ";
	//document.getElementById("rating0").value = MyInt + " ";
	document.getElementById("link1").href = "mylink.html";
	document.getElementById("img1").style.display = "none";
}
vitcount = 0

function vitalizeHolder(tag) {

	vitcount++;
	
	urlstart = tag.indexOf(" ");
	resstart = tag.indexOf(" ", urlstart+1);
	if (urlstart == -1 || resstart == -1) {
		document.write("[Invalid Vitalize Tag]");
		return;
	}
  	vitres = tag.substr(resstart,tag.length - resstart - 1);
  	resx = vitres.indexOf("x");
  
  	resw = parseInt(vitres.substr(0,resx));
 	resh = parseInt(vitres.substr(resx+1,4));
  
  	viturl = tag.substr(urlstart+1,resstart - urlstart - 1).replace("vit://", "http://");
  
	document.write("<div id=\"vithold" + vitcount + "\" class=\"textbutton\" style=\"width: " + resw + "px; height: " + resh + "px; padding: 0px; margin: 0px;\">");
	document.write("<div style=\"width: 200px; position: relative; top: 50%; left: 50%; margin-left: -100px; margin-top: -60px; text-align: center;\">");
	document.write("<img src=\"sitegfx/vittrans.png\" alt=\"\"><br /><br /><a href=\"#\" onClick=\"vitalizeStart(" + vitcount + "," + resw + "," + resh + ",'" + escape(viturl) + "');return false\" class=\"textbutton\">Start Vitalize Content</a>");
	document.write("</div></div>");
}
function vitalizeStart(id, resw, resh, viturl) {
	
	viturl = unescape(viturl);
	viturl = viturl.replace("\"", "&quot;");
	
	vitcode = "<object id=\"dcvit" + id + "\" width=" + resw + " height=" + resh + " type=\"application/x-cnc\" classid=\"clsid:eb6d7e70-aaa9-40d9-ba05-f214089f2275\" codebase=\"http://www.clickteam.com/vitalize4/vitalize.cab#version=4,0,247,6\">"
	vitcode += "<param name=\"url\" value=\"" + viturl + "\">"
	vitcode += "<param name=\"progressbar\" value=\"5,5,200,10\">"
	vitcode += "<param name=\"progressbarcolor\" value=\"255,128,0\">"
	vitcode += "<param name=\"progressbarbordercolor\" value=\"0,0,0\">"
	vitcode += "<param name=\"backcolor\" value=\"255,255,255\">"
	vitcode += "<embed type=\"application/x-cnc\" progressbar=\"5,5,200,10\" progressbarcolor=\"255,128,0\" progressbarbordercolor=\"0,0,0\" backcolor=\"255,255,255\" src=\"" + viturl + "\" checkversion=\"4,0,247,6\" pluginspage=\"http://www.clickteam.com/vitalize4/download.html\" width=" + resw + " height=" + resh + "></embed>"
	vitcode += "</object>"
	
	document.getElementById("vithold" + id).innerHTML = vitcode;
	
}