// JavaScript Document
//////////////////////////////////// xml2array() ////////////////////////////////////////
//See http://www.openjs.com/scripts/xml_parser/
var not_whitespace = new RegExp(/[^\s]/);//This can be given inside the funciton - I made it a global variable to make the scipt a little bit faster.
var parent_count;
//Process the xml data
function xmlStr2array(text)
{
	if (window.DOMParser)
  {
  parser=new DOMParser();
  xmlDoc=parser.parseFromString(text,"text/xml");
  }
	else // Internet Explorer
	{
			xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.async="false";
		xmlDoc.loadXML(text); 
	}
	return xml2array(xmlDoc);
}
function xml2array(xmlDoc,parent_count) {
	var arr;
	var parent = "";
	parent_count = parent_count || new Object;

	var attribute_inside = 0; /*:CONFIG: Value - 1 or 0
	*	If 1, Value and Attribute will be shown inside the tag - like this...
	*	For the XML string...
	*	<guid isPermaLink="true">http://www.bin-co.com/</guid>
	*	The resulting array will be...
	*	array['guid']['value'] = "http://www.bin-co.com/";
	*	array['guid']['attribute_isPermaLink'] = "true";
	*	
	*	If 0, the value will be inside the tag but the attribute will be outside - like this...	
	*	For the same XML String the resulting array will be...
	*	array['guid'] = "http://www.bin-co.com/";
	*	array['attribute_guid_isPermaLink'] = "true";
	*/

	if(xmlDoc.nodeName && xmlDoc.nodeName.charAt(0) != "#") {
		if(xmlDoc.childNodes.length > 1) { //If its a parent
			arr = new Object;
			parent = xmlDoc.nodeName;
			
		}
	}
	var value = xmlDoc.nodeValue;
	if(xmlDoc.parentNode && xmlDoc.parentNode.nodeName && value) {
		if(not_whitespace.test(value)) {//If its a child
			arr = new Object;
			arr[xmlDoc.parentNode.nodeName] = value;
		}
	}
	if(xmlDoc.childNodes != undefined && xmlDoc.childNodes.length) {
		if(xmlDoc.childNodes.length == 1) { //Just one item in this tag.
			arr = xml2array(xmlDoc.childNodes[0],parent_count); //:RECURSION:
		} else { //If there is more than one childNodes, go thru them one by one and get their results.
			var index = 0;
			var arr = new Array();
			for(var i=0; i<xmlDoc.childNodes.length; i++) {//Go thru all the child nodes.
				var temp = xml2array(xmlDoc.childNodes[i],parent_count); //:RECURSION:
				if(temp) {
					var assoc = false;
					var arr_count = 0;
					for(key in temp) {
						if(isNaN(key)) assoc = true;
						arr_count++;
						if(arr_count>2) break;//We just need to know wether it is a single value array or not
					}
					if(assoc && arr_count == 1) {
						//alert("a");
					//	alert(dump(arr));
						//alert("b");
						if(arr[key]) { 	//If another element exists with the same tag name before,
										//		put it in a numeric array.
							//Find out how many time this parent made its appearance
							if(!parent_count || !parent_count[key]) {
								parent_count[key] = 0;

								var temp_arr = arr[key];
								arr[key] = new Object;
								arr[key][0] = temp_arr;
							}
							parent_count[key]++;
							arr[key][parent_count[key]] = temp[key]; //Members of of a numeric array
						} else {
							parent_count[key] = 0;
							arr[key] = temp[key];
							if(xmlDoc.childNodes[i].attributes && xmlDoc.childNodes[i].attributes.length) {
								for(var j=0; j<xmlDoc.childNodes[i].attributes.length; j++) {
									var nname = xmlDoc.childNodes[i].attributes[j].nodeName;
									if(nname) {
										/* Value and Attribute inside the tag */
										if(attribute_inside) {
											var temp_arr = arr[key];
											arr[key] = new Object;
											arr[key]['value'] = temp_arr;
											arr[key]['attribute_'+nname] = xmlDoc.childNodes[i].attributes[j].nodeValue;
										} else {
										/* Value in the tag and Attribute otside the tag(in parent) */
											arr['attribute_' + key + '_' + nname] = xmlDoc.childNodes[i].attributes[j].nodeValue;
										}
									}
								} //End of 'for(var j=0; j<xmlDoc. ...'
							} //End of 'if(xmlDoc.childNodes[i] ...'
						}
					} else {
						arr[index] = temp;
						index++;
					}
				} //End of 'if(temp) {'
			} //End of 'for(var i=0; i<xmlDoc. ...'
		}
	}

	if(parent && arr) {
		var temp = arr;
		arr = new Object;
		
		arr[parent] = temp;
	}
	return arr;
}


function dump(arr,level) {
	var dumped_text = "";
	if(!level) level = 0;
	
	
	
	//The padding given at the beginning of the line.
	var level_padding = "";
	for(var j=0;j<level+1;j++) level_padding += "    ";
	
	if(typeof(arr) == 'object') { //Array/Hashes/Objects
	 for(var item in arr) {
		var value = arr[item];
	 
		if(typeof(value) == 'object') { //If it is an array,
		 dumped_text += level_padding + "'" + item + "' ...\n";
		 dumped_text += dump(value,level+1);
		} else {
		 dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
		}
	 }
	} else { //Stings/Chars/Numbers etc.
	 dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
	}
	return dumped_text;
} 


//depricated
function parseXML(url)
{
	try //Internet Explorer
  {
  xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
  }
	catch(e)
  {
  	try //Firefox, Mozilla, Opera, etc.
    {
    	xmlDoc=document.implementation.createDocument("","",null);
    }
		catch(e)
    {
			alert(e.message);
  		return;
    }
  }
	xmlDoc.async=false;
	xmlDoc.load(url);
	alert(xmlDoc.responseText);
	//return xml2array(xmlDoc);
	
	//document.getElementById("to").innerHTML=xmlDoc.getElementsByTagName("to")[0].childNodes[0].nodeValue;
	//document.getElementById("from").innerHTML=xmlDoc.getElementsByTagName("from")[0].childNodes[0].nodeValue;
	//document.getElementById("message").innerHTML=xmlDoc.getElementsByTagName("body")[0].childNodes[0].nodeValue;
}
function createObject() {
	var request_type;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer"){
	request_type = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		request_type = new XMLHttpRequest();
	}
		return request_type;
}

var http = createObject();
var loadPageIntoDivId;
function loadPageIntoDiv(page,divId,formFields) {
	loadPageIntoDivId = divId;
	http.open('POST', page,true);
	http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http.onreadystatechange = loadPageIntoDivReply;
	if(null!=formFields && isArray(formFields))
	{
		var query = "";
		var i=0;
		for(var obj in formFields)
		{
			formElem = document.getElementById(formFields[obj]);
			if(formElem!=null)
			{
				if(i!=0)
				query = query + "&";
				query = query + formFields[obj]+"="+formElem.value;
				i++;
			}
			
		}
		http.send(query);
	}else{
		http.send(null);
	}
	
}
function loadPageIntoDivReply() {
	if(http.readyState == 4){
		var response = http.responseText;
		
		if(response!=""){

			div = document.getElementById(loadPageIntoDivId);
			if(div!=null)
				div.innerHTML = response;

		} else {

		}
	}
}
//depricated?
function loadPage(url)
{

	try //Internet Explorer
  {
  xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
  }
	catch(e)
  {
  	try //Firefox, Mozilla, Opera, etc.
    {
    	xmlDoc=document.implementation.createDocument("","",null);
    }
		catch(e)
    {
			alert(e.message);
  		return;
    }
  }
	xmlDoc.async=true;
	xmlDoc.load(url);
	return xmlDoc.nodeValue;
	
	//document.getElementById("to").innerHTML=xmlDoc.getElementsByTagName("to")[0].childNodes[0].nodeValue;
	//document.getElementById("from").innerHTML=xmlDoc.getElementsByTagName("from")[0].childNodes[0].nodeValue;
	//document.getElementById("message").innerHTML=xmlDoc.getElementsByTagName("body")[0].childNodes[0].nodeValue;
}
	function insertObjAtCursor(insert,field)
	{
		masterInsert(field,"["+insert+"]",false,"[/"+insert+"]");
	}
	function insertObjAtCursorPop(insert,field,query,text)
	{
		ret = prompt(text);
		masterInsert(field,"["+insert+" "+query+"='"+ret+"']",false,"[/"+insert+"]");
	}
	function insertObjAtCursorPop2(insert,field,query,text)
	{
		ret = prompt(text);
		masterInsert(field,"["+insert+"]",ret,"[/"+insert+"]");
	}
	function insertAtCursor(insert,field)
	{
		masterInsert(field,"",insert,"");
		
	}
	function masterInsert(field,start,mid,end)
	{
		myField = document.getElementById(field);
		if(myField.type=="hidden")
		{
			myField.value=mid;
		}else{
			//IE support
			if (document.selection) {
				myField.focus();
				sel = document.selection.createRange();
				if(mid===false)
					sel.text = start+sel.text+end;
				else
					sel.text = start+mid+end;
			}
			
			//Mozilla/Firefox/Netscape 7+ support
			else if (myField.selectionStart || myField.selectionStart == '0') {
			
				var startPos = myField.selectionStart;
				var endPos = myField.selectionEnd;
				if(mid===false)
					myField.value = myField.value.substring(0, startPos)+ start+ myField.value.substring(startPos, endPos) +end+ myField.value.substring(endPos, myField.value.length);
				else
					myField.value = myField.value.substring(0, startPos)+ start+ mid +end+ myField.value.substring(endPos, myField.value.length);
			} else {
				if(mid===false)
					myField.value += start+end;
				else
					myField.value += start+mid+end;
			} 
		}
	}
	function popupWindow(url,name,height,width)
{
	var newwindow;
	newwindow=window.open(url,name,'status=0,toolbar=0,directories=0,scrollbars=0,height='+height+',width='+width);
	if (window.focus) {newwindow.focus()}
}

function getFile(pURL) {
   if (window.XMLHttpRequest) { // code for Mozilla, Safari, etc 
      xmlhttp=new XMLHttpRequest();
      xmlhttp.onreadystatechange=reloadPage;
      xmlhttp.open("GET", pURL, true);
      xmlhttp.send(null);
   } else if (window.ActiveXObject) { //IE 
      xmlhttp=new ActiveXObject('Microsoft.XMLHTTP'); 
      if (xmlhttp) {
         xmlhttp.onreadystatechange=reloadPage;
         xmlhttp.open('GET', pURL, true);
         xmlhttp.send();
      }
   }
}
function reloadPage() {
   if (xmlhttp.readyState==4) { 
      if (xmlhttp.status==200) { 
				//alert(xmlhttp.responseText);
				 window.location.reload()
      }
   }
}

var addEvent;
if (document.addEventListener) {
    addEvent = function(element, type, handler) {
        element.addEventListener(type, handler, null);
    }
}
else if (document.attachEvent) {
    addEvent = function(element, type, handler) {
    element.attachEvent("on" + type, handler);
    }
}
else {
    addEvent = new Function; // not supported
}

var floatBoxWindows = new Array;
function lightBox(interiorPage){
	lightBoxC(interiorPage,500,500,20,2);
}

function lightBoxC(interiorPage,width,height,barHeight,border){
	//fade
	if(!top.document.getElementById("floatBox_background"))
	{

		var newdiv = document.createElement('div');
		var divIdName = 'floatBox_background';
		newdiv.setAttribute('id',divIdName);
		newdiv.setAttribute('class','floatBox_background');
		newdiv.style.backgroundColor = "#000000";
		newdiv.style.width=getWinWidth()+"px";
		newdiv.style.height=getWinHeight()+"px";
		newdiv.style.position="fixed";
		newdiv.style.left="0px";
		newdiv.style.top="0px";
		newdiv.style.filter = 'alpha(opacity=0)';
		newdiv.style.opacity = '.0';
		newdiv.innerHTML = '';
		addEvent(newdiv, "click", closeFloatBox) ;
	addEvent(window, "scroll", closeFloatBox) ;
	addEvent(window, "resize", closeFloatBox) ;
		top.document.body.appendChild(newdiv);
		fadeIn(divIdName,0,75,microtime(),2);
	}
	
	
	uid = uniqid();
	var newdiv = top.document.createElement('div');
	top.floatBoxWindows.push(newdiv);
  var divIdName = 'floatBox_foreground'+top.floatBoxWindows.length;
  newdiv.setAttribute('id',divIdName);
	newdiv.setAttribute('class','floatBox_foreground');
	//newdiv.style.backgroundColor = "#FFFFFF";
	newdiv.style.width="0px";
	newdiv.style.height=(height+barHeight)+"px";
	newdiv.style.position="fixed";
	newdiv.style.overflow="hidden";
	newdiv.style.border="solid "+border+"px #000";
	newdiv.style.left=((getWinWidth())/2)+"px";
	newdiv.style.top=((getWinHeight()-(height+barHeight))/2-border)+"px";
	//newdiv.style.filter = 'alpha(opacity=0)';
	//newdiv.style.opacity = '.0';
  newdiv.innerHTML = '';
	top.document.body.appendChild(newdiv);

	
	
	var floatBox_content = top.document.createElement('div');
  var floatBox_contentName = 'floatBox_content'+top.floatBoxWindows.length;
  floatBox_content.setAttribute('id',floatBox_contentName);
	floatBox_content.setAttribute('class','floatBox_content');
	//floatBox_content.style.backgroundColor = "#FFFFFF";
	//floatBox_content.style.width=width+"px";
	//floatBox_content.style.height=(height+barHeight)+"px";
	floatBox_content.style.position="relative";
	floatBox_content.style.overflow="hidden";
//	floatBox_content.style.left="100px";
	//floatBox_content.style.top="0px";
//	loadPageIntoDiv("plugins/postData/popImage.php",floatBox_contentName);
	floatBox_content.innerHTML = "";
	if(barHeight>0)
	{
  		floatBox_content.innerHTML += '<div style="background-color:#dddddd;height:'+(barHeight-border)+'px;border-bottom:'+border+'px solid black;"><div style="float:right;margin-right:'+border+'px;height:'+(barHeight-border)+'px;"><a onClick="closeTopFloatBox()"><img src="plugins/images/close.gif" border=0></a></div></div>';
	}
  floatBox_content.innerHTML += '<iframe id="floatBox_contentFrm'+top.floatBoxWindows.length+'" src="'+interiorPage+'" style="border:none; visibility:hidden; overflow:hidden" width="'+(width)+'px" height="'+(height)+'px"></iframe>';

  newdiv.appendChild(floatBox_content);
	
	var ifrm = top.document.getElementById("floatBox_contentFrm"+top.floatBoxWindows.length);
	if(ifrm!=null)
	{
		addEvent(ifrm, "load", showiframe) ;
	}
	fadeIn(divIdName,0,100,microtime(),.5);
	scrollOpen(divIdName,0,width,microtime(),.5,floatBox_contentName);
}
function showiframe()
{
	var ifrm = top.document.getElementById("floatBox_contentFrm"+top.floatBoxWindows.length);
	ifrm.style.visibility="visible";
}
function closeFloatBox()
{
	div = top.document.getElementById("floatBox_background");
	if(div!=null)
		top.document.body.removeChild(div);
	for(i=0;i<top.floatBoxWindows.length;i++)
	{
		div = top.floatBoxWindows[i];
		//div = document.getElementById("floatBox_foreground");
		if(div!=null)
			document.body.removeChild(div);
	//	unset(top.floatBoxWindows[i]);
	}
	top.floatBoxWindows = new Array();
}
function closeTopFloatBox()
{
	if(top.floatBoxWindows.length==1)
	{
		closeFloatBox();
	}
	div = top.floatBoxWindows[top.floatBoxWindows.length-1];
	if(div!=null)
	{
		//parent.document.body.removeChild(div);
		fadeIn('floatBox_foreground'+(top.floatBoxWindows.length),100,0,microtime(),.5);
		scrollOpen('floatBox_foreground'+(top.floatBoxWindows.length),false,0,microtime(),.5,'floatBox_content'+(top.floatBoxWindows.length));
	}
	top.floatBoxWindows.splice(top.floatBoxWindows.length-1,top.floatBoxWindows.length-1);
}

var currentFades = new Array();
//depricated.  use fade instead

function fadeIn(id,startZ,endZ,startTime,totalTime)
{
	div = top.document.getElementById(id);
	if(startTime!=0)
	{
		if(div.style.opacity!="" && div.style.opacity != startZ && div.style.opacity !=undefined)
		{
			if(startZ < endZ)
			{
				startTime -= totalTime * (div.style.opacity / ((endZ - startZ) / 100));
			}else{
				startTime -= totalTime * (1-(div.style.opacity / ((startZ - endZ) / 100)));
			}

		}
		currentFades[id] = new Array(id,startZ,endZ,startTime,totalTime);
	}
	if(div!=undefined)
	{

		startZ = currentFades[id][1];
		endZ = currentFades[id][2];
		startTime = currentFades[id][3];
		totalTime = currentFades[id][4];
		
		startTime + totalTime - microtime();
		perc = (microtime() - startTime)/totalTime;
		if(perc > 1) perc = 1;
		trans = (endZ -startZ) * perc + startZ;

		if((trans > endZ && startZ < endZ) || (trans < endZ && startZ > endZ)) trans = endZ;
		div.style.filter = 'alpha(opacity='+trans+')';
		div.style.opacity = trans/100;

		/*if(trans>0)
		{
			div.style.visibility = "visible";
		}else{
			div.style.visibility = "hidden";
		}*/
		if(trans!=endZ)
		{
			setTimeout("fadeIn('"+id+"',0,0,0,0)",10);
		}
	}
}

var fadeList = Array();
function fade(id,speed,end)
{
//	if(!in_array(Array(id,speed,end),fadeList))
//	{
		fadeList[id] = Array(id,speed,end,1);
//	}
	registerDaemon("fadeDaemon()");
}
function fadeDaemon()
{
	for ( var fade in fadeList )
	{
		if(fadeList[fade][3])
		{
			if(currentFades[fadeList[fade][0]]==null)
				currentFades[fadeList[fade][0]] = 0;
			var direction = 0;
			if(fadeList[fade][2]>currentFades[fadeList[fade][0]])
			{
				currentFades[fadeList[fade][0]] += (fadeList[fade][1])*cycleTime;
				direction=1;
			}
			else
			{
				currentFades[fadeList[fade][0]] -= (fadeList[fade][1])*cycleTime;
			}
			if((currentFades[fadeList[fade][0]] > fadeList[fade][2] && direction==1) || (currentFades[fadeList[fade][0]] < fadeList[fade][2] && direction==0))
				currentFades[fadeList[fade][0]] = fadeList[fade][2];
			var obj = document.getElementById(fadeList[fade][0]);
			if(obj!=undefined)
			{
				currentFades[fadeList[fade][0]] = Number(currentFades[fadeList[fade][0]]);
				if(currentFades[fadeList[fade][0]]>0)
					obj.style.visibility = "visible";
				else
					obj.style.visibility = "hidden";
					
				if(fadeList[fade][0]!=undefined && currentFades[fadeList[fade][0]]!=undefined)
				{
					obj.style.filter = 'alpha(opacity='+currentFades[fadeList[fade][0]]+')';
					obj.style.opacity = currentFades[fadeList[fade][0]]/100;
				}
			}
			if(currentFades[fadeList[fade][0]] == fadeList[fade][2])
			{
				fadeList[fade][3] = 0;
				delete(fadeList[fade]);
			}
		}
	}

	if(arrayCount(fadeList)==0)
		unregisterDaemon("fadeDaemon()");
}
function unregisterDaemon(functionName)
{
	delete(daemon_functionNames[functionName]);
}
function registerDaemon(functionName)
{
	daemon_functionNames[functionName] = functionName;
	if(daemon_nowTime ==false || microtime() > daemon_nowTime +10)
	{
		//daemon_lastTime = microtime();
		loopDaemons();
	}
}
var daemon_functionNames= Array();
var cycleTime = false;
var daemon_lastTime = false;
var daemon_nowTime = false;
function loopDaemons()
{
	daemon_nowTime = microtime();
	if(daemon_lastTime !=false)
	{
		cycleTime = daemon_nowTime - daemon_lastTime;
	}
	daemon_lastTime = daemon_nowTime;
	if(cycleTime!=false)
	{
		for(var name in daemon_functionNames)
		{
			setTimeout(name,0);
		}
	}
	if(arrayCount(daemon_functionNames)>0)
	{

		setTimeout("loopDaemons()",20);
	}else{
		daemon_lastTime = false;
		daemon_nowTime = false;
		cycleTime = false;
	}
}

function scrollOpen(id,startZ,endZ,startTime,totalTime,id2)
{
	
	div = top.document.getElementById(id);

	if(div!=null)
	{
		if(startZ===false)
		{
		 startZ = parseInt(div.style.width);
		}
		//startTime + totalTime - microtime();
		perc = (microtime() - startTime)/totalTime;
		if(perc > 1) perc = 1;
		newWidth = (endZ -startZ) * perc + startZ;
		if((newWidth > endZ && startZ < endZ) || (newWidth < endZ && startZ > endZ)) newWidth = endZ;
		div.style.width = newWidth+"px";
		div.style.left=((getWinWidth()-newWidth)/2)+"px";
		if(newWidth!=endZ)
			setTimeout("scrollOpen('"+id+"',"+startZ+","+endZ+","+startTime+","+totalTime+",'"+id2+"')",10);
		if(newWidth==endZ && endZ==0)
		{
			top.document.body.removeChild(div);
		}
		interior = top.document.getElementById(id2);
		if(interior!=null)
		{
			if(endZ>startZ)
				interior.style.left = ((newWidth/2) - (endZ/2)) +"px";
			else
				interior.style.left = ((newWidth/2) - (startZ/2)) +"px";
		}
	}
}

function getWinWidth()
{
	if (top.window.innerWidth) {
	theWidth=top.window.innerWidth;
	}
	else if (top.document.documentElement && top.document.documentElement.clientWidth) {
	theWidth=top.document.documentElement.clientWidth;
	}
	else if (top.document.body) {
	theWidth=top.document.body.clientWidth;
	}
	return theWidth;
}
function getWinHeight()
{
	if (top.window.innerHeight) {
	theHeight=top.window.innerHeight;
	}
	else if (top.document.documentElement && top.document.documentElement.clientHeight) {
	theHeight=top.document.documentElement.clientHeight;
	}
	else if (top.document.body) {
	theHeight=top.document.body.clientHeight;
	}
	return theHeight;
}
function microtime()
{
	var now = new Date().getTime()/1000;
	return now;
}

function isArray(obj) {
   if (obj.constructor.toString().indexOf("Array") == -1)
      return false;
   else
      return true;
}

function popQuery(question,url)
{
	var answer = confirm(question);
	if (answer)
	{
		window.location=url;
	}else{
	}
}


function uniqid()
{
var newDate = new Date;
return newDate.getTime();
}

function in_array (needle, haystack, argStrict) {
    // Checks if the given value exists in the array  
    // 
    // version: 911.718
    // discuss at: http://phpjs.org/functions/in_array    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: vlado houba
    // +   input by: Billy
    // +   bugfixed by: Brett Zamir (http://brett-zamir.me)
    // *     example 1: in_array('van', ['Kevin', 'van', 'Zonneveld']);    // *     returns 1: true
    // *     example 2: in_array('vlado', {0: 'Kevin', vlado: 'van', 1: 'Zonneveld'});
    // *     returns 2: false
    // *     example 3: in_array(1, ['1', '2', '3']);
    // *     returns 3: true    // *     example 3: in_array(1, ['1', '2', '3'], false);
    // *     returns 3: true
    // *     example 4: in_array(1, ['1', '2', '3'], true);
    // *     returns 4: false
    var key = '', strict = !!argStrict; 
    if (strict) {
        for (key in haystack) {
            if (haystack[key] === needle) {
                return true;            }
        }
    } else {
        for (key in haystack) {
            if (haystack[key] == needle) {                return true;
            }
        }
    }
     return false;
}


function arrayCount(array)
{
	var i=0;
	for ( var ar in array )
	{
		i++;
	}
	return i;
}
function fontSmoothResize (objID,width,height) {
	if (objID && width && height) {
		setSWFDimensions(objID+'f',width,height);
		//alert(width+" "+height);
		if(width>2 && height>2)
		{
			var html = document.getElementById(objID+"h");
			var parent = document.getElementById(objID);
			parent.removeChild(html);

		}
	}
}
function setSWFDimensions (objID,width,height) {
	if (objID && width && height) {
		var parent = document.getElementById(objID);
		var hObj = document.getElementById(objID+'h');
		if (hObj) {
			hObj.setAttribute('visibility','hidden');
			hObj.setAttribute('width',0);
			hObj.setAttribute('height',0);
			hObj.style.visibility = 'hidden';
			hObj.style.width = 0;
			hObj.style.height = 0;
			parent.removeChild(hObj);
		}
		var fObj = document.getElementById(objID+'f');
		var fEmb = document.getElementById(objID+'f'+'-embed');
		
		if (fObj && fObj.style) {
			
			fObj.setAttribute('width',width);
			fObj.setAttribute('height',height);
			fObj.style.width = width;
			fObj.style.height = height;
			
		}

		if (fEmb != null) {
			fEmb.width = width;
			fEmb.height = height;

			if (fEmb.style) {
				fEmb.style.width = width;
				fEmb.style.height = height;
			}
		}

	}
}

var slidesArray0 = new Array();
var slidesArray1 = new Array();
var slidesArray2 = new Array();
var slidesArray3 = new Array();
var slidesArray4 = new Array();
var slideStartH = new Array();
var slideStartW = new Array();
var txtFocus = false;

function registerTextFields()
{
	var inputs = document.getElementsByTagName('input');

	for(var i = 0; i < inputs.length; i++) {
		var elem = inputs[i];

		if(elem.type == 'text' || elem.type == 'password' || elem.type == 'textarea') {
			elem.onfocus = function() {
				txtFocus = true;

			}
			elem.onblur = function() {
				txtFocus = false;
			}
		}
	}
}
function slideOpen(name,align)
{
	slidesArray0[name] = name;
	slidesArray1[name] = 1;
	slidesArray2[name] = align;
	slidesArray3[name] = 6;
	slidesArray4[name] = 1;
	registerDaemon("slideDaemon()");
}
function slideCloseDelay(name,align,delay)
{
	slidesArray4[name] = 0;
	setTimeout('slideCloseDelay2("'+name+'","'+align+'")',delay);
}
function slideCloseDelay2(name,align)
{
	if(!txtFocus && slidesArray4[name] == 0){
	
		slidesArray0[name] = name;
		slidesArray1[name] = 0;
		slidesArray2[name] = align;
		slidesArray3[name] = 6;
		registerDaemon("slideDaemon()");
	}
}
function slideClose(name,align)
{
	if(!txtFocus){
	
	slidesArray0[name] = name;
	slidesArray1[name] = 0;
	slidesArray2[name] = align;
	slidesArray3[name] = 6;
	registerDaemon("slideDaemon()");
	}
}
function slideAlternate(name,align)
{
	if(slidesArray1[name])
		slideClose(name,align);
	else
		slideOpen(name,align);
}
function slideDaemon()
{
//console.log(cycleTime);

	
	for(var slide in slidesArray0)
	{
		var speed = slidesArray3[slide];
		//var minH = 0;
		var outer = document.getElementById(slide+"Outer");
		
		if(outer!=null)
		{
			var inner = document.getElementById(slide+"Inner");
			if(slideStartH[slide] == null)
				slideStartH[slide] = parseInt(outer.offsetHeight);
			var minH = slideStartH[slide];
			if(slideStartW[slide] == null)
				slideStartW[slide] = parseInt(outer.offsetWidth);
			var minW = slideStartW[slide];
			
			var currentH = parseInt(outer.offsetHeight);
			maxH = parseInt(inner.offsetHeight);

			if(slidesArray1[slide])
			{
				var change = ((maxH - currentH)) * (cycleTime*speed);
				if(change<1) change = 1;
				var newH = currentH+change;
				if(newH >maxH)
				{
					newH = maxH;
				}
			}else{
				var change = ((currentH - minH)) * (cycleTime*speed);
				if(change<1) change = 1;
				var newH = currentH-change;
				if(newH <minH)
				{
					newH = minH;
				}
			}
			outer.style.height = Math.round(newH) + "px";
			var currentW = parseInt(outer.offsetWidth);
			maxW = parseInt(inner.offsetWidth);
			if(slidesArray1[slide])
			{
				var change = ((maxW - currentW)) * (cycleTime*speed);
				if(change<1) change = 1;
				var newW = currentW+change;
				if(newW >maxW)
				{
					newW = maxW;
				}
			}else{
				var change = ((currentW - minW)) * (cycleTime*speed);
				if(change<1) change = 1;
				var newW = currentW-change;
				if(newW <minW)
				{
					newW = minW;
				}
			}
			outer.style.width = Math.round(newW) + "px";
			switch(slidesArray2[slide])
			{
				case "n":
					inner.setAttribute("margin-top",(parseInt(outer.offsetHeight) - parseInt(inner.offsetHeight)) + "px");
					inner.style.marginTop = (parseInt(outer.offsetHeight) - parseInt(inner.offsetHeight)) + "px";
					break;
				case "s":
					outer.setAttribute("margin-top",(parseInt(inner.offsetHeight) - parseInt(outer.offsetHeight)) + "px");
					outer.style.marginTop = (parseInt(inner.offsetHeight) - parseInt(outer.offsetHeight)) + "px";
					break;
				default:
					inner.setAttribute("margin-top","0px");
					inner.style.marginTop = "0px";
					inner.setAttribute("margin-left","0px");
					inner.style.marginLeft = "0px";
					break;
				case "e":
					outer.setAttribute("margin-left",(parseInt(inner.offsetWidth) - parseInt(outer.offsetWidth)) + "px");
					outer.style.marginLeft = (parseInt(inner.offsetWidth) - parseInt(outer.offsetWidth)) + "px";
					break;
			}
			if((newH ==minH || newH==maxH) && (newW ==minW || newW==maxW))
			{
				delete(slidesArray0[slide]);
				delete(slidesArray2[slide]);
			}
		}
	}
	/*if(slidesArray0.length==0)
	{
		unregisterDaemon("slideDaemon()");
	}*/
}

function makeHttpRequest(url, callback_function, return_xml)
{
 var http_request, response, i;

 var activex_ids = [
   'MSXML2.XMLHTTP.3.0',
   'MSXML2.XMLHTTP',
   'Microsoft.XMLHTTP'
 ];

 if (window.XMLHttpRequest) { // Mozilla, Safari, IE7+...
   http_request = new XMLHttpRequest();
   if (http_request.overrideMimeType) {
     http_request.overrideMimeType('text/xml');
   }
 } else if (window.ActiveXObject) { // IE6 and older
   for (i = 0; i < activex_ids.length; i++) {
     try {
       http_request = new ActiveXObject(activex_ids[i]);
     } catch (e) {}
   }
 }

 if (!http_request) {
   alert('Unfortunately your browser does not support this feature.');
   return false;
 }
 http_request.onreadystatechange = function() {
   if (http_request.readyState !== 4) {

       // not ready yet
       return;
   }
   if (http_request.status !== 200) {
     // ready, but not OK
   //	alert('There was a problem with the request.(Code: ' + http_request.status + ')');
     return;
   }
   if (return_xml) {
     response = http_request.responseXML;
   } else {
     response = http_request.responseText;
   }
   // invoke the callback
	 if(typeof callback_function == 'function')
	 {
   	callback_function(response);
	 }
 };

 http_request.open('GET', url, true);
 http_request.send(null);
}

function userData_signin(email,password)
{
	makeHttpRequest("plugins/userData/signin.php?email="+email+"&password="+password,userData_signinResponse);
}
function userData_signinResponse(resp)
{
	if(resp==1)
	{
		window.location = window.location;
	}else{
		alert("incorrect email or password");
	}
}
function userData_signout()
{
	makeHttpRequest("plugins/userData/signout.php",userData_signoutResponse);
}
function userData_signoutResponse(resp)
{
		window.location = window.location;
}
function getRadio(radio)
{
	for (i=0;i<radio.length;i++){
		if (radio[i].checked==true){
			return(radio[i].value);
		}
	}
	return false;
}
