/*

	durgle.js
	version 4.3.1
	first created: 10/27/2002
	last revised: 03/22/2008
	http://www.durgle.com
	Edward H. Hotchkiss
	edward@durgle.com

*/


// -------- BEGIN DEBUG -----------


// Set debug to show special debugging alerts
Debug = {
	debugStarted: 0,
	init: function() {
		if (this.debugStarted) {
			alert("Debug Activated!");
		}
	}
}


// Initialize the debugging class
addOnLoadEvent(Debug.init);


// -------- END DEBUG -----------


// -------- BEGIN OBJECT REFERENCING -----------


// Get a reference to an object
function $(TheID) { 
	return document.getElementById(TheID);
}


// Get a reference to an object with the style attribute
// why doesn't prototype offer this? :P
function $s(x) {
	return $(x).style;
}


// stop a form from being submitted, form onsubmit=ff(); ff = formFalse();
function formFalse() {
	return false;
}


// -------- BEGIN JS/HTML -----------


// Insert HTML
function insertHTML(type) {
	switch(type) {
		case "a":
			currentText = $("Entry").value;
			if ($("jsA").innerHTML == "/A") {
				$("jsA").innerHTML = "A";
				$("Entry").value = currentText + "</a>";
			} else {
				var URL = prompt("Please Enter a URL", "http://");
				newText = currentText + '<a target="_new" href="' + URL + '">';
				$("Entry").value = newText;
				$("jsA").innerHTML = "/A";
			}
			break;
		case "img":
			modal('mediaAdder', 'container');
			break;
		case "b":
			currentText = $("Entry").value;
			if ($("jsB").innerHTML == "/B") {
				$("jsB").innerHTML = "B";
				$("Entry").value = currentText + "</strong>";
			} else {
				newText = currentText + "<strong>";
				$("Entry").value = newText;
				$("jsB").innerHTML = "/B";
			}
			break;
		case "u":
			currentText = $("Entry").value;
			if ($("jsU").innerHTML == "/U") {
				$("jsU").innerHTML = "U";
				$("Entry").value = currentText + "</u>";
			} else {
				newText = currentText + "<u>";
				$("Entry").value = newText;
				$("jsU").innerHTML = "/U";
			}
			break;
		case "br":
			$("Entry").value = $("Entry").value + "<br />";
			break;
		case "s":
			$("Entry").value = $("Entry").value + "&nbsp;";
			break;
		case "p":
			currentText = $("Entry").value;
			if ($("jsP").innerHTML == "/P") {
				$("jsP").innerHTML = "P";
				$("Entry").value = currentText + "</p>";
			} else {
				newText = currentText + "<p>";
				$("Entry").value = newText;
				$("jsP").innerHTML = "/P";
			}
			break;
		default:
			alert("Invalid JavaScript Insert Type!");
			break;
	}
}


// Insert HTML 
function insertHTML2(ID) {
	var URL = prompt("Please Enter an image size! (30, 80, 150, 300, 500, 600", "");
	img = '<img src="http://www.30milestyle.com/admin/media/' + ID + '_';
	currentEntry = $("Entry").value;
	switch(URL) {
		case "30":
			img += '30x30.jpg" />';
			$("Entry").value = currentEntry + img
			break;
		case "80":
			img += '80x80.jpg" />';
			$("Entry").value = currentEntry + img
			break;
		case "150":
			img += '150x150.jpg" />';
			$("Entry").value = currentEntry + img
			break;
		case "300":
			img += '300x300.jpg" />';
			$("Entry").value = currentEntry + img
			break;
		case "500":
			img += '500x500.jpg" />';
			$("Entry").value = currentEntry + img
			break;
		case "600":
			img += '600x600.jpg" />';
			$("Entry").value = currentEntry + img
			break;
	}
}


// -------- END JS/HTML  -----------


// -------- BEGIN STRING, INT AND ARRAY FUNCTIONS -----------


// Split JavaScript by a semicolon
function splitSemi(x) {
	y = x.split(";");
	return y;	
}


// Print an array
function printr(arr) {
	for (var i = 0; i < arr.length; i++) {
		document.write(arr[i] + "<br />");
	}
}


// string to array split by commas
function str2arr(str) {
	var arr = str.split(",");
	return arr;
}


// Remove an array element by index
Array.prototype.removeByValue = function(value) {
	for (var i = this.length; i >= 0; i--) {
		if (this[i] == value) {
			this.splice(i, 1); 
			return value; 
		}
	}
}


// hexadecimal to decimal
function hex2dec(hex) {
	return(parseInt(hex,16));
}


// decimal to hexadecimal
function dec2hex(dec) {
	return (dec < 16 ? "0" : "") + dec.toString(16);
}


// Extract Number (int)
function ExtractNumber(value) {
	var n = parseInt(value);
	return n == null || isNaN(n) ? 0 : n;
}


// -------- BEGIN STRING, INT AND ARRAY FUNCTIONS -----------


// -------- BEGIN OPACITY, FADING AND VIEWING -----------


// Toggle Between Disaply:Block & Display:none
function toggle(obj) {
	var el = document.getElementById(obj);
	if ( el.style.display != 'none' ) {
		el.style.display = 'none';
	}
	else {
		el.style.display = '';
	}
}

// Fade an element in or out via opacity
function opacity(id, opacStart, opacEnd, millisec) {
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;
	// determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpacity('" + id + "'," + i + ")",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++) {
			setTimeout("changeOpacity('" + id + "'," + i + ")",(timer * speed));
			timer++;
		}
	}
}


// Change the opacity for different browsers
function changeOpacity(id, opacity) {
	var object = $(id).style;
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
};


// -------- BEGIN getElementsByClassName non-native (as of yet) ----------


document.getElementsByClassName = function(myClass) {
	var retnode = [];
	var myClass = new RegExp('\\b'+myClass+'\\b');
	var elem = this.getElementsByTagName('*');
	for (var i = 0; i < elem.length; i++) {
		var theClass = elem[i].className;
		if (myClass.test(theClass)) {
			retnode.push(elem[i]);
		}
	}
	return retnode;
};


// -------- END getElementsByClassName non-native (as of yet) ----------


// -------- EVENT MANAGEMENT ----------


// Bind Events
function addEvent(elem, evtType, func, capture) {
	capture = (capture) ? capture : false;
	if (elem.addEventListener) {
		elem.addEventListener(evtType, func, capture);
	} else if (elem.attachEvent) {
		elem.attachEvent("on" + evtType, func);
	} else {
		elem["on" + evtType] = func;
	}
}


// Unbind Events
function removeEvent(elem, evtType, func, capture) {
	capture = (capture) ? capture : false;
	if (elem.removeEventListener) {
		elem.removeEventListener(evtType, func, capture);
	} else if (elem.attachEvent) {
		elem.detatchEvent("on", evtType, func);
	} else {
		elem["on" + evtType] = null;
	}
}
	

// Autoloader
function addOnLoadEvent(func) {
	if (window.addEventListener || window.attachEvent) {
		addEvent(window, "load", func, false);
	} else {
		var oldQueue = (window.onload) ? window.onload : function() {}
		window.onload = function() {
			oldQueue();
			func();
		}
	}
}


// Block Events
function blockEvents(evt) {
	evt = (evt) ? evt : event;
	var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
	if (elem && elem.tagName && elem.tagName.toLowerCase() == "img") {
		if (evt.cancelBubble) {
			evt.cancelBubble = true;
		}
		alert("Event Bubble Cancel Unavailable!");
		return false;
	}
}


// Disable Context Menu
//document.oncontextmenu = blockEvents;


// -------- END BROADCAST, EVENT AND LISTENER FUNCTIONS ----------


// -------- BEGIN CSS FUNCTIONS ----------


// Insert line of CSS into the DOM
function insertCSS(css) {
	var ss = document.createElement("style");
	ss.type = "text/css";
	var sst = document.createTextNode(css);
	ss.appendChild(sst);
	document.getElementsByTagName("head")[0].appendChild(ss);
}


// -------- END CSS FUNCTIONS ----------


// -------- BEGIN SimpleToolTips CLASS ----------


SimpleToolTips = {
	startX: 0,
	startY: 0,
	offsetX: 0,
	offsetY: 0,
	hoverOverElement: "",
	oldZIndex: 0,
	tip: "",
	tipText: "No Text Defined!",
	// Initialize the Class
	init: function() {
		toolTipAnchors = document.getElementsByClassName("tooltip"); 
			for (x = 0; x < toolTipAnchors.length; x++) {
				tipText = toolTipAnchors[x].title;
				addEvent(toolTipAnchors[x], "mouseover", SimpleToolTips.OnMouseOver, false);
				// Kill Tips
				addEvent(toolTipAnchors[x], "mouseout", SimpleToolTips.OnMouseOut, false);
			}
	},
	// Create a Tip
	createTip: function(str) {
		tip = document.createElement("DIV"); 
		document.body.appendChild(tip); 
		tip.setAttribute('id','myToolTip');
		with(tip.style) {
			position = 'absolute';
			background = "#f3f3f3";
			top = this.startX;
			left = this.startY;
			display = "none";
			padding = "10px";
			font = "13px Myriad, Tahoma, Lucida, Helvetica, Arial, sans-serif";
			color = "#5a5a5a";
			border = "1px solid #b3b3b3";
		}
		tip.innerHTML = "<p>" + str + "</p>";
		changeOpacity("myToolTip", 0);
		toggle("myToolTip");
		opacity("myToolTip", 0, 100, 400);
	},
	// Initialize the Tip
	OnMouseOver: function(e) {
		if (e == null) e = window.event; 
		// IE: srcElement | Other Browsers: target
		var target = e.target != null ? e.target : e.srcElement;
		tipText = target.title;
		SimpleToolTips.createTip(tipText);
		// IE, left click == 1
		// Firefox, left click == 0
		if ((e.button == 1 && window.event != null || e.button == 0) && target.className == 'tooltip') {
			// Current Mouse Position
			startX = e.clientX - 100;
			startY = e.clientY - 50;
			// Grab the Clicked Element's Position
			offsetX = ExtractNumber(target.style.left);
			offsetY = ExtractNumber(target.style.top);
			// Bring Draggable to Front while being Dragged
			oldZIndex = target.style.zIndex;
			target.style.zIndex = 100;
			// Item to Drag
			hoverOverElement = target;
			// Mouse Moves, Object Moves
			addEvent(document, "mousemove", SimpleToolTips.OnMouseMove, false);
			// No Text Selection
			document.body.focus();
			document.onselectstart = function () {
				return false;
			};
			return false;
		}
	},
	// Move the Tip
	OnMouseMove: function(e) {
		if (e == null) var e = window.event; 
		tip.style.left = (offsetX + e.clientX - startX) + 'px';
		tip.style.top = (offsetY + e.clientY - startY) + 'px';
	},
	// Kill the Tip
	OnMouseOut: function(e) {
		if (tip != null) {
			// Return old z-Index
			tip.style.zIndex = oldZIndex;
			// Cancel Dragging
			document.onmousemove = null;
			document.onselectstart = null;	
			opacity("myToolTip", 100, 0, 400);
			toggle("myToolTip");
			tip = null;
		}
	}

}


// Initialize SimpleToolTips onload
addOnLoadEvent(SimpleToolTips.init);


// -------- END SimpleToolTips CLASS ----------




// -------- BEGIN STYLESHEET FUNCTIONS -----------


// Set the active style sheet from an alternate style sheet
function disableFirstStyleSheet() {
	document.getElementsByTagName('link')[0].disabled = true;
}


// -------- BEGIN MISCELLANEOUS FUNCTIONS -----------


// Pause, take a break, lie down and chillout
function pause(numberMillis) {
	var now = new Date();
	var exitTime = now.getTime() + numberMillis;
	while (true) {
		now = new Date();
		if (now.getTime() > exitTime)
		return;
	}
}


// Change the status bar
function changeStatusBar(str) {
	window.status = str;
}


// Generate a random number
function generateRandomNumber(startInt, finishInt) {
	var randomNumber = Math.floor(Math.random() * (finishInt - startInt + 1)) + startInt;
	return randomNumber;
}


// -------- BEGIN DOM/XML MANIPULATION -----------


function insertAfter(parent, node, referenceNode) {
	parent.insertBefore(node, referenceNode.nextSibling);
}


// -------- END DOM/XML MANIPULATION -----------


// -------- BEGIN IMAGE PRELOADING AND ROLLOVER FUNCTIONS -----------


// Preload Images
var rolloverImageBank = {
	height: 20,
	width: 50,
	sharedImgURIs : ["img/home", "img/prod", "img/support", "img/contact"],
	normalSuffix: "Normal.png",
	hiliteSuffix: "Hilite.png",
	preloadImages: function() {
		var imgObj = new Image(this.height, this.width);
		for (i = 0; i < this.sharedImgURIs; i++) {
			imgObj.src = this.sharedImgURIs[i] + this.normalSuffix;
			imgObj.src = this.sharedImgURIs[i] + this.hiliteSuffix;
		}
	},
	toggleImage : function(evt) {
		evt = (evt) ? evt : event;
		var elem = (evt.target) ? evt.target : evt.srcElement;
		if (elem && elem.src) {
			var reOff = new RegExp("(.*)(" + this.normalSuffix + ")");
			var reOn = new RegExp("(.*)(" + this.hiliteSuffix + ")");
			if (reOff.test(elem.src)) {
				elem.src = reOff.exec(elem.src)[1] + this.hiliteSuffix;
			} else {
				elem.src = reOn.exec(elem.src)[1] + this.normalSuffix;		
			}
		}
	}
}


// Preload Images
//rolloverImageBank.preloadImages();


// Set Image Rollovers
function setRollovers() {
	addEvent(document.getElementById("home"), "mouseover", function(evt) { rolloverImageBank.toggleImage(evt) }, false);
	addEvent(document.getElementById("home"), "mouseout", function(evt) { rolloverImageBank.toggleImage(evt) }, false);
}


// Set Rollover Events
//addOnLoadEvents(setRollovers);


// -------- BEGIN FORM CHECKING FUNCTIONS -----------


// Put the focus on a form element and change the background color
function focusFormElement(elementID) {
	$(elementID).focus();
}


// Check captcha
function checkAddition() {
	val = document.forms[0].addition.value;
	if (val == 4) {
		return true;
	} else {
		alert("To keep out spammers, answer the following question: What is 2+2?");
		return false;
	}
}


// Verify that a string is in fact an email address
function isEmail(formElement) {
	var str = formElement.value;
	var RegExp = /^[\W-]+(\.[w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
	if (str.match(RegExp)) {
		return true;
	} else {
		return false;
	}
}


// Check and see if an input box is filled in or not
function validateRequiWhiteSmoke(field,alerttxt) {
	with (field) {
		if (value == null || value == "") {
			alert(alerttxt);
			return false;
		} else {
 			return true;
		}
	}
}


// Make sure that all of the form is filled out
function checkForm(aForm) {
	formLength = aForm.elements.length;
	formErrors = 0;
	formErrorNames = "Missing Fields: ";
	payment = "";
	paymentChecked = 0;
	for (i = 0; i < formLength; i++) {
		formElementType = aForm.elements[i].type;
		formElementValue = aForm.elements[i].value;
		formElementName = aForm.elements[i].name;
		formElementID = aForm.elements[i].id;
		if (formElementType == "text" || formElementType == "password") {
			if (formElementValue == "" || formElementValue == null) {
				if (formElementName != "company") {
					if (formElementName != "email") {
						if (formElementName != "fax") {
							if (formElementName != "website") {
								aForm.elements[i].style.backgroundColor = "WhiteSmoke";
								if (formElementName != "") {
									formErrors += 1;
									formErrorNames += formElementID + ", ";
								}
							}
						}
					}
				}
			}
		}
		if (formElementType == "select-one") {
			if (formElementValue == "") {
				aForm.elements[i].style.backgroundColor = "WhiteSmoke";
				formErrors += 1;
				formErrorNames += formElementID + ", ";
			}
		}
		if (formElementType == "select-multiple") {
			if (formElementValue == "") {
				aForm.elements[i].style.backgroundColor = "WhiteSmoke";
				formErrors += 1;
				formErrorNames += formElementID + ", ";
			}
		}
		if (formElementType == "textarea") {
			if (formElementValue == "") {
				aForm.elements[i].style.backgroundColor = "WhiteSmoke";
				formErrors += 1;
				formErrorNames += formElementID + ", ";
			}
		}
		if (formElementType == "checkbox") {
			if (formElementName = "enclosedCheck") {
				if (aForm.elements[i].checked == true) {
					paymentChecked += 1;
				}
			} else if (formElementName = "creditCard") {
				if (aForm.elements[i].checked == true) {
					paymentChecked += 1;
				}
			}
			if (paymentChecked == 2) {
				formErrors += 1;
			}
			if (aForm.elements[i].checked == false) {
				aForm.elements[i].checked = false;
			}
		}
	}
	var strLen = formErrorNames.length;
	formErrorNames2 = formErrorNames.slice(0,strLen-2);
  	if (formErrors > 0) {
  		errorStr = "You have left (" + formErrors + ") fields empty or checked two payment methods!";
  	    alert(errorStr);
  	   	alert(formErrorNames2);
    	return false;
  	} else {
  		if (confirm('Please review your information and click Cancel to go back to edit or click OK to submit')) {
  			return true;
  		} else {
  			return false;
  		}
	}
}


// -------- BEGIN AJAX -----------


// Encode GET
// @@frm = Form Name
function GetParams(frm) {
	aForm = document.forms[frm];
	formLength = aForm.elements.length;
	Params = "";
	if (formLength > 0) {
		for (i = 0; i < formLength; i++) {
			formElementType = aForm.elements[i].type;
			formElementValue = aForm.elements[i].value;
			formElementName = aForm.elements[i].name;
			formElementID = aForm.elements[i].id;
			if (formElementType == "text" || formElementType == "password" || formElementType == "textarea" || formElementType == "select-one" || formElementType == "hidden") {
				if (i == 0) {
					Sym = "?";
				} else {
					Sym = "&";
				}
				Params += Sym + formElementName + "=" + formElementValue;
			}
		}
		return Params;
	} else {
		return "";
	}
}


// Get a browser independent XMLHTTP Object
function GetXMLHTTP() {
	var XMLHTTP = false;
	if (window.XMLHttpRequest) {
		XMLHTTP = new XMLHttpRequest()
  	} else if (window.ActiveXObject) {
		try {
			XMLHTTP = new ActiveXObject("Msxml2.XMLHTTP")
		} catch (e) { 
			try {
        			XMLHTTP = new ActiveXObject("Microsoft.XMLHTTP")
      		} catch (E) {
        			XMLHTTP = false;
      		}
    	}
  	}
	return XMLHTTP;
};


// Pass a server side response as a javascript function
// @@ URL = PHP/Perl page to execute
// @@ frm = Form Name
function AJAXToFunction(URL, frm) {
	var XMLHTTP = new GetXMLHTTP();
	// Compatibility with IE 5.0
	// Send the Request
	Params = GetParams(frm);
	if (XMLHTTP) {
		XMLHTTP.onreadystatechange = function stateChange() {
			if (XMLHTTP && XMLHTTP.readyState == 4) {
				// Got something back..
				if (XMLHTTP.status == 200) {
					// Check to see if the response was good
					var response = XMLHTTP.responseText;
			//		if (debug) {
				//		alert(response);
					//}
					eval(response);
				} else if(debug){
					document.write(XMLHTTP.responseText);
				}
			}
		}
		// open the page
		XMLHTTP.open("GET", URL+Params, true);
		// send the data
		XMLHTTP.send(null);
	}
}


// Pass a server side response as a javascript function
// @@ URL = PHP/Perl page to execute
// @@ frm = Form Name
function AJAX(URL) {
	var XMLHTTP = new GetXMLHTTP();
	// Compatibility with IE 5.0
	// Send the Request
	if (XMLHTTP) {
		XMLHTTP.onreadystatechange = function stateChange() {
			if (XMLHTTP && XMLHTTP.readyState == 4) {
				// Got something back..
				if (XMLHTTP.status == 200) {
					// Check to see if the response was good
					var response = XMLHTTP.responseText;
					if(debug) {
						alert(response);
					}
					eval(response);
				} else if(debug){
					document.write(XMLHTTP.responseText);
				}
			}
		}
		// open the page
		XMLHTTP.open("GET", URL, true);
		// send the data
		XMLHTTP.send(null);
	}
}


// Pass a server side response as a javascript function, then
// change the innderHTML of a div or Object
// @@ URL = PHP/Perl page to execute
// @@ obj_id = object to have innerHTML changed
// @@ frm = Form Name
// @@ execAfterEval = Javascript to execute upon completion
function InnerFromAJAX(URL, obj_id, frm, execAfterEval) {
	var XMLHTTP = new GetXMLHTTP();
	Params = GetParams(frm);
	// Send the Request
	if (XMLHTTP) {
		XMLHTTP.onreadystatechange = function stateChange() {
			if (XMLHTTP && XMLHTTP.readyState == 4) {
				// Got something back..
				if (XMLHTTP.status == 200) {
					// Check to see if the response was good
					var response = XMLHTTP.responseText;
					if(debug) {
						alert(response);
					}
					document.getElementById(obj_id).innerHTML = response;
					if(debug) {
						alert(execAfterEval);
					}
					eval(execAfterEval);
				} else if(debug){
					document.write(XMLHTTP.responseText);
				}
			}
		}
	// open the page
	XMLHTTP.open("GET", URL+Params, true);
	// send the data
	XMLHTTP.send(null);
	}
}

// Instant AJAX (ie: Live Searching etc)
// @@ instantFile = PHP/Perl page to execute
// @@ instantDiv = object to have innerHTML updated live/instantly
// @@ instantIndicator = Div with animated gif or text indicator to display that the script is still loading/working
// @@ instantForm = Form Name
// @@ execAfterEval = Javascript to execute upon completion
function InstantAJAX(instantFile, instantDIV, instantIndicator, instantForm, execAfterEval) {
	document.getElementById(instantIndicator).style.display = "block";
	document.getElementById(instantDIV).style.display = "block";
	var XMLHTTP = new GetXMLHTTP();
	// Compatibility with IE 5.0
	Params = GetParams(instantForm);
	// Send the Request
	if (XMLHTTP) {
		XMLHTTP.onreadystatechange = function stateChange() {
			if (XMLHTTP && XMLHTTP.readyState == 4) {
				// Got something back..
				if (XMLHTTP.status == 200) {
					// Check to see if the response was good
					var response = XMLHTTP.responseText;
					if(debug) {
						alert(response);
					}
					document.getElementById(instantDIV).innerHTML = response;
					if(debug) {
						alert(execAfterEval);
					}
					eval(execAfterEval);
					document.getElementById(instantIndicator).style.display = "none";
					//document.getElementById(instantDIV).style.display = "none";
				} else if(debug){
					document.write(XMLHTTP.responseText);
				}
			}
		}
	// open the page
	XMLHTTP.open("GET", instantFile + Params, true);
	// send the data
	XMLHTTP.send(null);
	}
}


// -------- END AJAX -----------


// Open Modal Window
function modal(modalID, holderID) {
	changeOpacity(modalID, 0);
	$s(modalID).display = 'block';
	opacity(holderID, 100, 40, 200);
	//changeOpacity('headerImage', 60);
	opacity(modalID, 0, 100, 300); 
}


// Close Modal Window
function closeModal(modalID, holderID) {
	opacity(modalID, 100, 0, 300);
	opacity(holderID, 40, 100, 300);
	$s(modalID).display = 'none';
}


// Close Modal Window
function closeIndicator(indicatorID) {
	opacity(indicatorID, 100, 0, 300);
	$s(indicatorID).display = 'none';
}


// Close Modal Window
function openIndicator(indicatorID) {
	changeOpacity(indicatorID, 0);
	$s(indicatorID).display = 'block';
	opacity(indicatorID, 0, 100, 300);
}


// Move the modal window
function moveModal(modalID) {
}


// -------- BEGIN CMS TAG ADDER -----------


// Add tags from DB into 
function addTag(tag, id) {
	if ($("Tags").value == " Tags...") {
		$("Tags").value = tag;
	} else {
		$("Tags").value += ", " + tag;
	}
	$(id).innerHTML = "";
}


// Insert Poll iFrame into 
function addPoll(id, PollID) {
	$(id).value += '<iframe src ="admin/vote.php?ID=' + PollID + '" width="400" height="300" frameborder="0" border="0"></iframe>';
}


// -------- END CMS TAG ADDER -----------


// -------- BEGIN TWEENING -----------


// Function Delegation
function Delegate() {}


Delegate.create = function (o, f) {
	var a = new Array() ;
	var l = arguments.length ;
	for(var i = 2 ; i < l ; i++) a[i - 2] = arguments[i] ;
	return function() {
		var aP = [].concat(arguments, a) ;
		f.apply(o, aP);
	}
}


// Tweening Function
Tween = function(obj, prop, func, begin, finish, duration, suffixe) {
	this.init(obj, prop, func, begin, finish, duration, suffixe)
}
var t = Tween.prototype;

t.obj = new Object();
t.prop='';
t.func = function (t, b, c, d) { return c*t/d + b; };
t.begin = 0;
t.change = 0;
t.prevTime = 0;
t.prevPos = 0;
t.looping = false;
t._duration = 0;
t._time = 0;
t._pos = 0;
t._position = 0;
t._startTime = 0;
t._finish = 0;
t.name = '';
t.suffixe = '';
t._listeners = new Array();	
t.setTime = function(t){
	this.prevTime = this._time;
	if (t > this.getDuration()) {
		if (this.looping) {
			this.rewind (t - this._duration);
			this.update();
			this.broadcastMessage('onMotionLooped',{target:this,type:'onMotionLooped'});
		} else {
			this._time = this._duration;
			this.update();
			this.stop();
			this.broadcastMessage('onMotionFinished',{target:this,type:'onMotionFinished'});
		}
	} else if (t < 0) {
		this.rewind();
		this.update();
	} else {
		this._time = t;
		this.update();
	}
}
t.getTime = function(){
	return this._time;
}
t.setDuration = function(d){
	this._duration = (d == null || d <= 0) ? 100000 : d;
}
t.getDuration = function(){
	return this._duration;
}
t.setPosition = function(p){
	this.prevPos = this._pos;
	var a = this.suffixe != '' ? this.suffixe : '';
	this.obj[this.prop] = Math.round(p) + a;
	this._pos = p;
	this.broadcastMessage('onMotionChanged',{target:this,type:'onMotionChanged'});
}
t.getPosition = function(t){
	if (t == undefined) t = this._time;
	return this.func(t, this.begin, this.change, this._duration);
};
t.setFinish = function(f){
	this.change = f - this.begin;
};
t.geFinish = function(){
	return this.begin + this.change;
};
t.init = function(obj, prop, func, begin, finish, duration, suffixe){
	if (!arguments.length) return;
	this._listeners = new Array();
	this.addListener(this);
	if(suffixe) this.suffixe = suffixe;
	this.obj = obj;
	this.prop = prop;
	this.begin = begin;
	this._pos = begin;
	this.setDuration(duration);
	if (func!=null && func!='') {
		this.func = func;
	}
	this.setFinish(finish);
}

// Start Tween
t.start = function(){
	this.rewind();
	this.startEnterFrame();
	this.broadcastMessage('onMotionStarted',{target:this,type:'onMotionStarted'});
}

// Rewind Tween
t.rewind = function(t){
	this.stop();
	this._time = (t == undefined) ? 0 : t;
	this.fixTime();
	this.update();
}

// Fast Forward Tween
t.fforward = function(){
	this._time = this._duration;
	this.fixTime();
	this.update();
}

// Update Tween Position
t.update = function(){
	this.setPosition(this.getPosition(this._time));
	}
t.startEnterFrame = function(){
	this.stopEnterFrame();
	this.isPlaying = true;
	this.onEnterFrame();
}

// On Enter Frame
t.onEnterFrame = function(){
	if(this.isPlaying) {
		this.nextFrame();
		setTimeout(Delegate.create(this, this.onEnterFrame), 0);
	}
}

// Next Frame
t.nextFrame = function(){
	this.setTime((this.getTimer() - this._startTime) / 1000);
}

// Stop Tween
t.stop = function(){
	this.stopEnterFrame();
	this.broadcastMessage('onMotionStopped',{target:this,type:'onMotionStopped'});
}

// On Enter Frame
t.stopEnterFrame = function(){
	this.isPlaying = false;
}

// Continue
t.continueTo = function(finish, duration){
	this.begin = this._pos;
	this.setFinish(finish);
	if (this._duration != undefined)
		this.setDuration(duration);
	this.start();
}

// Resume Tween
t.resume = function(){
	this.fixTime();
	this.startEnterFrame();
	this.broadcastMessage('onMotionResumed',{target:this,type:'onMotionResumed'});
}

// Go back, YOYO
t.yoyo = function (){
	this.continueTo(this.begin,this._time);
}

// Add Listener
t.addListener = function(o){
	this.removeListener (o);
	return this._listeners.push(o);
}

t.removeListener = function(o){
	var a = this._listeners;	
	var i = a.length;
	while (i--) {
		if (a[i] == o) {
			a.splice (i, 1);
			return true;
		}
	}
	return false;
}

t.broadcastMessage = function(){
	var arr = new Array();
	for(var i = 0; i < arguments.length; i++){
		arr.push(arguments[i])
	}
	var e = arr.shift();
	var a = this._listeners;
	var l = a.length;
	for (var i=0; i<l; i++){
		if(a[i][e])
		a[i][e].apply(a[i], arr);
	}
}

t.fixTime = function(){
	this._startTime = this.getTimer() - this._time * 1000;
}

t.getTimer = function(){
	return new Date().getTime() - this._time;
}

// Tweening Easing Types [Robert Penner]
Tween.backEaseIn = function(t,b,c,d,a,p){
	if (s == undefined) var s = 1.70158;
	return c*(t/=d)*t*((s+1)*t - s) + b;
}

Tween.backEaseOut = function(t,b,c,d,a,p){
	if (s == undefined) var s = 1.70158;
	return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
}

Tween.backEaseInOut = function(t,b,c,d,a,p){
	if (s == undefined) var s = 1.70158; 
	if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
	return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
}

Tween.elasticEaseIn = function(t,b,c,d,a,p){
		if (t==0) return b;  
		if ((t/=d)==1) return b+c;  
		if (!p) p=d*.3;
		if (!a || a < Math.abs(c)) {
			a=c; var s=p/4;
		}
		else 
			var s = p/(2*Math.PI) * Math.asin (c/a);
		
		return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;	
}

Tween.elasticEaseOut = function (t,b,c,d,a,p){
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (!a || a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return (a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b);
}
	
Tween.elasticEaseInOut = function (t,b,c,d,a,p){
	if (t==0) return b;  if ((t/=d/2)==2) return b+c;  if (!p) var p=d*(.3*1.5);
	if (!a || a < Math.abs(c)) {var a=c; var s=p/4; }
	else var s = p/(2*Math.PI) * Math.asin (c/a);
	if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
	return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
}

Tween.bounceEaseOut = function(t,b,c,d){
	if ((t/=d) < (1/2.75)) {
		return c*(7.5625*t*t) + b;
	} else if (t < (2/2.75)) {
		return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
	} else if (t < (2.5/2.75)) {
		return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
	} else {
		return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
	}
}

Tween.bounceEaseIn = function(t,b,c,d){
	return c - Tween.bounceEaseOut (d-t, 0, c, d) + b;
}

Tween.bounceEaseInOut = function(t,b,c,d){
	if (t < d/2) return Tween.bounceEaseIn (t*2, 0, c, d) * .5 + b;
	else return Tween.bounceEaseOut (t*2-d, 0, c, d) * .5 + c*.5 + b;
}

Tween.strongEaseInOut = function(t,b,c,d){
	return c*(t/=d)*t*t*t*t + b;
}

Tween.regularEaseIn = function(t,b,c,d){
	return c*(t/=d)*t + b;
}

Tween.regularEaseOut = function(t,b,c,d){
	return -c *(t/=d)*(t-2) + b;
}

Tween.regularEaseInOut = function(t,b,c,d){
	if ((t/=d/2) < 1) return c/2*t*t + b;
	return -c/2 * ((--t)*(t-2) - 1) + b;
}

Tween.strongEaseIn = function(t,b,c,d){
	return c*(t/=d)*t*t*t*t + b;
}

Tween.strongEaseOut = function(t,b,c,d){
	return c*((t=t/d-1)*t*t*t*t + 1) + b;
}

Tween.strongEaseInOut = function(t,b,c,d){
	if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
	return c/2*((t-=2)*t*t*t*t + 2) + b;
}

// -------- END TWEENING -----------


// -------- BEGIN COOKIES -----------


// Get Cookie Expiration Date
function getExpDate(days, hours, minutes) {
	var expDate = new Date();
	if (typeof(days) == "number" && typeof(hours) == "number" && typeof(minutes) == "number") {
		expDate.setDate(expDate.getDate() + parseInt(days));
		expDate.setHours(expDate.getHours() + parseInt(hours));
		expDate.setMinutes(expDate.getMinutes() + parseInt(minutes));
		return expDate.toUTCString();
	}
}


// Cookie Utility Function
function getCookieVal(offset) {
	var endstr = document.cookie.indexOf(";", offset);
	if (endstr == -1) {
		endstr = document.cookie.length;
	}
	return decodeURI(document.cookie.substring(offset, endstr));
}


// Retrieve cookie by name
function getCookie(name) {
	var arg = name + "=";
	var alen  = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg) {
			return getCookieVal(j);
		}
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return "";
}


// Set Cookie
function setCookie(name, expires, path, domain, secure) {
	document.cookie = name + "=" + encodeURI(value) +
		((expires) ? "; expires=" + expires : "") +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		((secure) ? "; secure=" + secure : "");
}


// Delete Cookie
function deleteCookie(name, path, domain) {
	if(getCookie(name)) {
		document.cookie = name + "=" +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		"; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}


// -------- END COOKIES -----------


// -------- BEGIN THREADS -----------


// Threads via AJAX
var Threads = { }


// -------- END THREADS -----------


// EOF