var searchHttp
var widthh = "";
var fontt = "";
var bgCol = "";
var ttclor = "";
var pcclor = "";
var desc = "";
var link = "";
function GetXmlHttpObject()
{
	var objXMLHttp=null
	if(window.XMLHttpRequest) {
		try {
			objXMLHttp = new XMLHttpRequest();
		} catch(e) {
			objXMLHttp = false;
		}
		// branch for IE/Windows ActiveX version
	} else if(window.ActiveXObject) {
		try {
			objXMLHttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(e) {
			try {
				objXMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch(e) {
				objXMLHttp = false;
			}
		}
	}

	return objXMLHttp
}


function sAll(area)
{
	var update = document.getElementById(area)
	update.focus()
	update.select()
}

function searchIt(arg)
{

	var infoHttp=GetXmlHttpObject()
	if (infoHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	//the regular ajax stuff
	if (infoHttp.readyState == 0 || infoHttp.readyState == 4) {

		var url="search.php"
		url=url+ "?area=" + escape(arg)
		url=url+"&sid="+Math.random()
		infoHttp.open("GET", url, true);
		infoHttp.onreadystatechange=function() {
			if (infoHttp.readyState==4) {
				document.getElementById("navBar").innerHTML=infoHttp.responseText;
			}
		}

		infoHttp.send(null);
	}

}

function selectorArea(arg){
//	alert(arg)
	document.forms["addFeede"].sort.value = arg; 
}
function gottadoit()
{
	if(document.all){	
		var bin = document.forms["addFeede"].catID.options[document.addFeede.catID.selectedIndex].value; 
    } else {
		var bin = document.forms[0].catID.options[document.addFeede.catID.selectedIndex].value; 
    }

	var infoHttp=GetXmlHttpObject()
	if (infoHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	//the regular ajax stuff
	if (infoHttp.readyState == 0 || infoHttp.readyState == 4) {

		var url="index.php"
		url=url+ "?action=getSort"
		url=url+ "&id=" + escape(bin)
		url=url+"&sid="+Math.random()
		infoHttp.open("GET", url, true);
		infoHttp.onreadystatechange=function() {
			if (infoHttp.readyState==4) {
				document.getElementById("sortArea").innerHTML=infoHttp.responseText;
			}
		}

		infoHttp.send(null);
	}

}
function showCats(arg)
{

var	infoHttp=GetXmlHttpObject()
	if (infoHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	//the regular ajax stuff
	if (infoHttp.readyState == 0 || infoHttp.readyState == 4) {
		arg.replace('/_/',' ')
		var url="search.php"
		url=url+ "?cat=" + escape(arg)
		url=url+"&sid="+Math.random()
		infoHttp.open("GET", url, true);
		infoHttp.onreadystatechange=function() {
			if (infoHttp.readyState==4) {
				document.getElementById(arg).innerHTML=infoHttp.responseText;
			}
		}

		infoHttp.send(null);
	}
}

function openMe(){
	document.getElementById("commentForm").style.display="";
}


function showForm(){
	var x = document.getElementById("email");
	if(x.style.display=="none"){
		document.getElementById("email").style.display="";
	} else if(x.style.display==""){
		document.getElementById("email").style.display="none";
	}

}
function validate_email(field,alerttxt)
{
	with (field)
	{
		apos=value.indexOf("@")
		dotpos=value.lastIndexOf(".")
		if (apos<1||dotpos-apos<2)
		{alert(alerttxt);return false}
		else {return true}
	}
}
function validate_required(field,alerttxt)
{


	with (field)
	{
		if (value==null||value=="")
		{alert(alerttxt);return false}
		else {return true}
	}
}
function validate_form(thisform)
{
	with (thisform)
	{
		if (validate_required(desc,"Description must be filled out")==false)
		{desc.focus();return false}
		else if (validate_email(email,"Not a valid e-mail address")==false)
		{email.focus();return false}
		else if (validate_required(name,"Name must be filled out")==false)
		{name.focus();return false}
	}
}
function bk(art) {
	if(art== "Tips"){
		var url = "http://www.phparrow.com/Tips_And_Tricks"
		var title = "PhpArrow Tips And Tricks";
	} else if (art == "Help"){
		var url = "http://www.phparrow.com/Php_Help"
		var title = "PhpArrow Php Help";
	}
	if (window.sidebar) {
		// Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) {
		// IE Favorite
		window.external.AddFavorite( url, title);
	}	else if(window.opera && window.print) {
		// Opera Hotlist
		return true; }
}

function checkArea(){
	var c = document.forms["addFeede"].template.options[document.addFeede.template.selectedIndex].value;
	if(c != 0){ 
	document.getElementById("closeit").style.display="none";	
	} else if(c == 0) {
	document.getElementById("closeit").style.display="";	
	}
}
// ===================================================================
// Author: Matt Kruse <matt@mattkruse.com>
// WWW: http://www.mattkruse.com/
//
// NOTICE: You may use this code for any purpose, commercial or
// private, without any further permission from the author. You may
// remove this notice from your final code if you wish, however it is
// appreciated by the author if at least my web site address is kept.
//
// You may *NOT* re-distribute this code in any way except through its
// use. That means, you can include it in your product, or your web
// site, or any other form where the code is actually being used. You
// may not put the plain javascript up on your site for download or
// include it in your javascript libraries for download.
// If you wish to share this code with others, please just point them
// to the URL instead.
// Please DO NOT link directly to my .js files from your site. Copy
// the files to your server and use them there. Thank you.
// ===================================================================


/* SOURCE FILE: AnchorPosition.js */

/*
AnchorPosition.js
Author: Matt Kruse
Last modified: 10/11/02

DESCRIPTION: These functions find the position of an <A> tag in a document,
so other elements can be positioned relative to it.

COMPATABILITY: Netscape 4.x,6.x,Mozilla, IE 5.x,6.x on Windows. Some small
positioning errors - usually with Window positioning - occur on the
Macintosh platform.

FUNCTIONS:
getAnchorPosition(anchorname)
Returns an Object() having .x and .y properties of the pixel coordinates
of the upper-left corner of the anchor. Position is relative to the PAGE.

getAnchorWindowPosition(anchorname)
Returns an Object() having .x and .y properties of the pixel coordinates
of the upper-left corner of the anchor, relative to the WHOLE SCREEN.

NOTES:

1) For popping up separate browser windows, use getAnchorWindowPosition.
Otherwise, use getAnchorPosition

2) Your anchor tag MUST contain both NAME and ID attributes which are the
same. For example:
<A NAME="test" ID="test"> </A>

3) There must be at least a space between <A> </A> for IE5.5 to see the
anchor tag correctly. Do not do <A></A> with no space.
*/

function show(area){
	if(area == "accounting"){
	var	res = "<img src=special/images/accounting.jpg>";
	}if(area == "business"){
	var	res = "<img src=special/images/business.jpg>";
	}if(area == "database"){
	var	res = "<img src=special/images/database.jpg>";
	}if(area == "education"){
	var	res = "<img src=special/images/education.jpg>";
	}if(area == "general"){
	var	res = "<img src=special/images/general.jpg>";
	}if(area == "email"){
	var	res = "<img src=special/images/mail.jpg>";
	}if(area == "multimedia"){
	var	res = "<img src=special/images/mulitmedia.jpg>";
	}if(area == "network"){
	var	res = "<img src=special/images/network.jpg>";
	}if(area == "webdesign"){
	var	res = "<img src=special/images/webdesign.jpg>";
	}
	document.getElementById("tab1").innerHTML=res;
	document.getElementById(area).className="selected";
	hideRest(area);
}

function hideRest(area){
var arg = new Array()
arg[0] = "accounting"
arg[1] = "business"
arg[2] = "database"
arg[3] = "education"
arg[4] = "general"
arg[5] = "email"
arg[6] = "multimedia"
arg[7] = "network"
arg[8] = "webdesign"

for (i=0;i<arg.length;i++)
{
	if(area != arg[i]){
document.getElementById(arg[i]).className="";
	}
}


}
// getAnchorPosition(anchorname)
//   This function returns an object having .x and .y properties which are the coordinates
//   of the named anchor, relative to the page.
function getAnchorPosition(anchorname) {
	// This function will return an Object with x and y properties
	var useWindow=false;
	var coordinates=new Object();
	var x=0,y=0;
	// Browser capability sniffing
	var use_gebi=false, use_css=false, use_layers=false;
	if (document.getElementById) { use_gebi=true; }
	else if (document.all) { use_css=true; }
	else if (document.layers) { use_layers=true; }
	// Logic to find position
	if (use_gebi && document.all) {
		x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
		y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
	}
	else if (use_gebi) {
		var o=document.getElementById(anchorname);
		x=AnchorPosition_getPageOffsetLeft(o);
		y=AnchorPosition_getPageOffsetTop(o);
	}
	else if (use_css) {
		x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
		y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
	}
	else if (use_layers) {
		var found=0;
		for (var i=0; i<document.anchors.length; i++) {
			if (document.anchors[i].name==anchorname) { found=1; break; }
		}
		if (found==0) {
			coordinates.x=0; coordinates.y=0; return coordinates;
		}
		x=document.anchors[i].x;
		y=document.anchors[i].y;
	}
	else {
		coordinates.x=0; coordinates.y=0; return coordinates;
	}
	coordinates.x=x;
	coordinates.y=y;
	return coordinates;
}

// getAnchorWindowPosition(anchorname)
//   This function returns an object having .x and .y properties which are the coordinates
//   of the named anchor, relative to the window
function getAnchorWindowPosition(anchorname) {
	var coordinates=getAnchorPosition(anchorname);
	var x=0;
	var y=0;
	if (document.getElementById) {
		if (isNaN(window.screenX)) {
			x=coordinates.x-document.body.scrollLeft+window.screenLeft;
			y=coordinates.y-document.body.scrollTop+window.screenTop;
		}
		else {
			x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
			y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
		}
	}
	else if (document.all) {
		x=coordinates.x-document.body.scrollLeft+window.screenLeft;
		y=coordinates.y-document.body.scrollTop+window.screenTop;
	}
	else if (document.layers) {
		x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
		y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
	}
	coordinates.x=x;
	coordinates.y=y;
	return coordinates;
}

// Functions for IE to get position of an object
function AnchorPosition_getPageOffsetLeft (el) {
	var ol=el.offsetLeft;
	while ((el=el.offsetParent) != null) { ol += el.offsetLeft; }
	return ol;
}
function AnchorPosition_getWindowOffsetLeft (el) {
	return AnchorPosition_getPageOffsetLeft(el)-document.body.scrollLeft;
}
function AnchorPosition_getPageOffsetTop (el) {
	var ot=el.offsetTop;
	while((el=el.offsetParent) != null) { ot += el.offsetTop; }
	return ot;
}
function AnchorPosition_getWindowOffsetTop (el) {
	return AnchorPosition_getPageOffsetTop(el)-document.body.scrollTop;
}

/* SOURCE FILE: PopupWindow.js */

/*
PopupWindow.js
Author: Matt Kruse
Last modified: 02/16/04

DESCRIPTION: This object allows you to easily and quickly popup a window
in a certain place. The window can either be a DIV or a separate browser
window.

COMPATABILITY: Works with Netscape 4.x, 6.x, IE 5.x on Windows. Some small
positioning errors - usually with Window positioning - occur on the
Macintosh platform. Due to bugs in Netscape 4.x, populating the popup
window with <STYLE> tags may cause errors.

USAGE:
// Create an object for a WINDOW popup
var win = new PopupWindow();

// Create an object for a DIV window using the DIV named 'mydiv'
var win = new PopupWindow('mydiv');

// Set the window to automatically hide itself when the user clicks
// anywhere else on the page except the popup
win.autoHide();

// Show the window relative to the anchor name passed in
win.showPopup(anchorname);

// Hide the popup
win.hidePopup();

// Set the size of the popup window (only applies to WINDOW popups
win.setSize(width,height);

// Populate the contents of the popup window that will be shown. If you
// change the contents while it is displayed, you will need to refresh()
win.populate(string);

// set the URL of the window, rather than populating its contents
// manually
win.setUrl("http://www.site.com/");

// Refresh the contents of the popup
win.refresh();

// Specify how many pixels to the right of the anchor the popup will appear
win.offsetX = 50;

// Specify how many pixels below the anchor the popup will appear
win.offsetY = 100;

NOTES:
1) Requires the functions in AnchorPosition.js

2) Your anchor tag MUST contain both NAME and ID attributes which are the
same. For example:
<A NAME="test" ID="test"> </A>

3) There must be at least a space between <A> </A> for IE5.5 to see the
anchor tag correctly. Do not do <A></A> with no space.

4) When a PopupWindow object is created, a handler for 'onmouseup' is
attached to any event handler you may have already defined. Do NOT define
an event handler for 'onmouseup' after you define a PopupWindow object or
the autoHide() will not work correctly.
*/

function useThisCat(arg,arg2){
	document.forms["addFeede"].elements["catID"].value=arg;
	document.getElementById('store').value=arg2;
	document.getElementById('myDiv').style.display="none";
}
function doitNow(are)
{

	var infoHttp=GetXmlHttpObject()
	if (infoHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	
	for(i=0; i<document.forms[0].elements.length; i++){
   if(document.forms[0].elements[i].name == "q" && document.forms[0].elements[i].value != ""){
   	var q = document.forms[0].elements[i].value; 
   }if(document.forms[0].elements[i].name == "store" && document.forms[0].elements[i].value != ""){
   	var store = document.forms[0].elements[i].value; 
   }
   if(document.forms[0].elements[i].name == "catID" && document.forms[0].elements[i].value != ""){
   	var catID = document.forms[0].elements[i].value; 
   } else {
   	var catID = "";
   }
   }

	//the regular ajax stuff
	if (infoHttp.readyState == 0 || infoHttp.readyState == 4) {

		var url="index.php?action=findCategoryNumberNowAjax"
		url=url+"&q=" + escape(q)
		url=url+"&catID=" + escape(catID)
		url=url+"&store=" + escape(store)
		url=url+"&sid="+Math.random();
					infoHttp.open("GET", url, true);
					infoHttp.onreadystatechange=function() {
						if (infoHttp.readyState==4) {
						document.getElementById(are).innerHTML=infoHttp.responseText;
						document.getElementById(are).style.width=400;
						}
					}
					infoHttp.send(null);
	}
}



function subForm(){



		if(document.all){	
		var catID = document.forms["addFeede"].catID.value; 
		var q = document.forms["addFeede"].q.value; 
		var totalResults = document.forms["addFeede"].totalResults.value; 
		var minprice = document.forms["addFeede"].minprice.value; 
		var maxprice = document.forms["addFeede"].maxprice.value; 
		var bin = document.forms["addFeede"].bin.options[document.addFeede.bin.selectedIndex].value; 
		var sort = document.forms["addFeede"].sort.options[document.addFeede.sort.selectedIndex].value; 
		var searchdesc = document.forms["addFeede"].searchdesc.options[document.addFeede.searchdesc.selectedIndex].value; 
		var track = document.forms["addFeede"].track.options[document.addFeede.track.selectedIndex].value; 
		var store = document.forms["addFeede"].store.options[document.addFeede.store.selectedIndex].value; 
		var template = document.forms["addFeede"].template.options[document.addFeede.template.selectedIndex].value; 
		var subCamp = document.forms["addFeede"].subCamp.value; 
		var campID = document.forms["addFeede"].campID.value; 
    } else {
		var catID = document.forms[1].catID.value; 
		var q = document.forms[1].q.value;
		var totalResults = document.forms[1].totalResults.value; 
		var minprice = document.forms[1].minprice.value; 
		var maxprice = document.forms[1].maxprice.value;
		var bin = document.forms[1].bin.options[document.addFeede.bin.selectedIndex].value; 
		var sort = document.forms[1].sort.options[document.addFeede.sort.selectedIndex].value; 
		var searchdesc = document.forms[1].searchdesc.options[document.addFeede.searchdesc.selectedIndex].value; 
		var track = document.forms[1].track.options[document.addFeede.track.selectedIndex].value; 
		var store = document.forms[1].store.options[document.addFeede.store.selectedIndex].value; 
		var template = document.forms[1].template.options[document.addFeede.template.selectedIndex].value; 
		var subCamp = document.forms[1].subCamp.value; 
		var campID = document.forms[1].campID.value; 
    }
    document.location= "index.php?action=addFeedNow&catID="+escape(catID)+"&q="+escape(q)+"&totalResults="+escape(totalResults)+"&minprice="+escape(minprice)+"&maxprice="+escape(maxprice)+"&bin="+escape(bin)+"&sort="+escape(sort)+"&searchdesc="+escape(searchdesc)+"&track="+escape(track)+"&store="+escape(store)+"&template="+escape(template)+"&subCamp="+escape(subCamp)+"&campID="+escape(campID);
}
function searchAgain()
{

	var infoHttp=GetXmlHttpObject()
	if (infoHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	

    var obj=document.getElementById("myDiv");
    if(document.all){ 
    while(obj.firstChild){
    	obj.removeChild(obj.firstChild);
    }
    }
	//the regular ajax stuff
	if (infoHttp.readyState == 0 || infoHttp.readyState == 4) {

		var url="index.php?action=findCategoryNumber1"
		url=url+"&sid="+Math.random();
					infoHttp.open("GET", url, true);
					infoHttp.onreadystatechange=function() {
						if (infoHttp.readyState==4) {
							if(document.all){
							var ell = document.createElement("div");
						ell.setAttribute("id", "myDiv"); 
						ell.innerHTML = infoHttp.responseText;
						obj.appendChild(ell)		
							} else {
						obj.innerHTML=infoHttp.responseText;
							}
						}
					}
					infoHttp.send(null);
	}
}

function popup1(anchorname) {

	var testpopup1 = new PopupWindow("myDiv");
	testpopup1.offsetY=-130;
	testpopup1.offsetX=-550;
	testpopup1.showPopup(anchorname);
	testpopup1.autoHide();
	//	testpopup1.setUrl("http://www.phparrow.com/");
	////	testpopup1.refresh();
	document.getElementById('myDiv').style.display = "";
	//	DivRef.style.display = "block";
	//    IfrRef.style.width = DivRef.offsetWidth;
	//    IfrRef.style.height = DivRef.offsetHeight;
	//    IfrRef.style.top = DivRef.style.top;
	//    IfrRef.style.left = DivRef.style.left;
	//    IfrRef.style.zIndex = DivRef.style.zIndex - 1;
	//    IfrRef.style.display = "block";
}

// Set the position of the popup window based on the anchor
function PopupWindow_getXYPosition(anchorname) {
	var coordinates;
	if (this.type == "WINDOW") {
		coordinates = getAnchorWindowPosition(anchorname);
	}
	else {
		coordinates = getAnchorPosition(anchorname);
	}
	this.x = coordinates.x;
	this.y = coordinates.y;
}
// Set width/height of DIV/popup window
function PopupWindow_setSize(width,height) {
	this.width = width;
	this.height = height;
}
// Fill the window with contents
function PopupWindow_populate(contents) {
	this.contents = contents;
	this.populated = false;
}
// Set the URL to go to
function PopupWindow_setUrl(url) {
	this.url = url;
}
// Set the window popup properties
function PopupWindow_setWindowProperties(props) {
	this.windowProperties = props;
}
// Refresh the displayed contents of the popup
function PopupWindow_refresh() {
	if (this.divName != null) {
		// refresh the DIV object
		if (this.use_gebi) {
			document.getElementById(this.divName).innerHTML = this.contents;
		}
		else if (this.use_css) {
			document.all[this.divName].innerHTML = this.contents;
		}
		else if (this.use_layers) {
			var d = document.layers[this.divName];
			d.document.open();
			d.document.writeln(this.contents);
			d.document.close();
		}
	}
	else {
		if (this.popupWindow != null && !this.popupWindow.closed) {
			if (this.url!="") {
				this.popupWindow.location.href=this.url;
			}
			else {
				this.popupWindow.document.open();
				this.popupWindow.document.writeln(this.contents);
				this.popupWindow.document.close();
			}
			this.popupWindow.focus();
		}
	}
}
// Position and show the popup, relative to an anchor object
function PopupWindow_showPopup(anchorname) {
	this.getXYPosition(anchorname);
	this.x += this.offsetX;
	this.y += this.offsetY;
	if (!this.populated && (this.contents != "")) {
		this.populated = true;
		this.refresh();
	}
	if (this.divName != null) {
		// Show the DIV object
		if (this.use_gebi) {
			document.getElementById(this.divName).style.left = this.x + "px";
			document.getElementById(this.divName).style.top = this.y + "px";
			document.getElementById(this.divName).style.visibility = "visible";
		}
		else if (this.use_css) {
			document.all[this.divName].style.left = this.x;
			document.all[this.divName].style.top = this.y;
			document.all[this.divName].style.visibility = "visible";
		}
		else if (this.use_layers) {
			document.layers[this.divName].left = this.x;
			document.layers[this.divName].top = this.y;
			document.layers[this.divName].visibility = "visible";
		}
	}
	else {
		if (this.popupWindow == null || this.popupWindow.closed) {
			// If the popup window will go off-screen, move it so it doesn't
			if (this.x<0) { this.x=0; }
			if (this.y<0) { this.y=0; }
			if (screen && screen.availHeight) {
				if ((this.y + this.height) > screen.availHeight) {
					this.y = screen.availHeight - this.height;
				}
			}
			if (screen && screen.availWidth) {
				if ((this.x + this.width) > screen.availWidth) {
					this.x = screen.availWidth - this.width;
				}
			}
			var avoidAboutBlank = window.opera || ( document.layers && !navigator.mimeTypes['*'] ) || navigator.vendor == 'KDE' || ( document.childNodes && !document.all && !navigator.taintEnabled );
			this.popupWindow = window.open(avoidAboutBlank?"":"about:blank","window_"+anchorname,this.windowProperties+",width="+this.width+",height="+this.height+",screenX="+this.x+",left="+this.x+",screenY="+this.y+",top="+this.y+"");
		}
		this.refresh();
	}
}

// Hide the popup
function PopupWindow_hidePopup() {
	if (this.divName != null) {
		if (this.use_gebi) {
			document.getElementById(this.divName).style.visibility = "hidden";
			if(document.getElementById('DivShim')){
				document.getElementById('DivShim').style.visibility = "hidden";
			}
		}
		else if (this.use_css) {
			document.all[this.divName].style.visibility = "hidden";
			if(document.all['DivShim']){
				document.all['DivShim'].style.visibility = "hidden";
			}
		}
		else if (this.use_layers) {
			document.layers[this.divName].visibility = "hidden";
			if(document.layers['DivShim']){
				document.layers['DivShim'].visibility = "hidden";
			}
		}
	}
	else {
		if (this.popupWindow && !this.popupWindow.closed) {
			this.popupWindow.close();
			this.popupWindow = null;
		}
	}
}
// Pass an event and return whether or not it was the popup DIV that was clicked
function PopupWindow_isClicked(e) {
	if (this.divName != null) {
		if (this.use_layers) {
			var clickX = e.pageX;
			var clickY = e.pageY;
			var t = document.layers[this.divName];
			if ((clickX > t.left) && (clickX < t.left+t.clip.width) && (clickY > t.top) && (clickY < t.top+t.clip.height)) {
				return true;
			}
			else { return false; }
		}
		else if (document.all) { // Need to hard-code this to trap IE for error-handling
			var t = window.event.srcElement;
			while (t.parentElement != null) {
				if (t.id==this.divName) {
					return true;
				}
				t = t.parentElement;
			}
			return false;
		}
		else if (this.use_gebi && e) {
			var t = e.originalTarget;
			while (t.parentNode != null) {
				if (t.id==this.divName) {
					return true;
				}
				t = t.parentNode;
			}
			return false;
		}
		return false;
	}
	return false;
}

// Check an onMouseDown event to see if we should hide
function PopupWindow_hideIfNotClicked(e) {
	if (this.autoHideEnabled && !this.isClicked(e)) {
		this.hidePopup();
	}
}
// Call this to make the DIV disable automatically when mouse is clicked outside it
function PopupWindow_autoHide() {
	this.autoHideEnabled = true;
}
// This global function checks all PopupWindow objects onmouseup to see if they should be hidden
function PopupWindow_hidePopupWindows(e) {
	for (var i=0; i<popupWindowObjects.length; i++) {
		if (popupWindowObjects[i] != null) {
			var p = popupWindowObjects[i];
			p.hideIfNotClicked(e);
		}
	}
}
// Run this immediately to attach the event listener
function PopupWindow_attachListener() {
	if (document.layers) {
		document.captureEvents(Event.MOUSEUP);
	}
	window.popupWindowOldEventListener = document.onmouseup;
	if (window.popupWindowOldEventListener != null) {
		document.onmouseup = new Function("window.popupWindowOldEventListener(); PopupWindow_hidePopupWindows();");
	}
	else {
		document.onmouseup = PopupWindow_hidePopupWindows;
	}
}
// CONSTRUCTOR for the PopupWindow object
// Pass it a DIV name to use a DHTML popup, otherwise will default to window popup
function PopupWindow() {
	if (!window.popupWindowIndex) { window.popupWindowIndex = 0; }
	if (!window.popupWindowObjects) { window.popupWindowObjects = new Array(); }
	if (!window.listenerAttached) {
		window.listenerAttached = true;
		PopupWindow_attachListener();
	}
	this.index = popupWindowIndex++;
	popupWindowObjects[this.index] = this;
	this.divName = null;
	this.popupWindow = null;
	this.width=0;
	this.height=0;
	this.populated = false;
	this.visible = false;
	this.autoHideEnabled = false;

	this.contents = "";
	this.url="";
	this.windowProperties="toolbar=no,location=no,status=no,menubar=no,scrollbars=auto,resizable,alwaysRaised,dependent,titlebar=no";
	if (arguments.length>0) {
		this.type="DIV";
		this.divName = arguments[0];
	}
	else {
		this.type="WINDOW";
	}
	this.use_gebi = false;
	this.use_css = false;
	this.use_layers = false;
	if (document.getElementById) { this.use_gebi = true; }
	else if (document.all) { this.use_css = true; }
	else if (document.layers) { this.use_layers = true; }
	else { this.type = "WINDOW"; }
	this.offsetX = 0;
	this.offsetY = 0;
	// Method mappings
	this.getXYPosition = PopupWindow_getXYPosition;
	this.populate = PopupWindow_populate;
	this.setUrl = PopupWindow_setUrl;
	this.setWindowProperties = PopupWindow_setWindowProperties;
	this.refresh = PopupWindow_refresh;
	this.showPopup = PopupWindow_showPopup;
	this.hidePopup = PopupWindow_hidePopup;
	this.setSize = PopupWindow_setSize;
	this.isClicked = PopupWindow_isClicked;
	this.autoHide = PopupWindow_autoHide;
	this.hideIfNotClicked = PopupWindow_hideIfNotClicked;
}
var targetColor = "";

//COLOR PICKER
function getWebsafeColours() {
        var colours = [];
        var hex;
        var parts = ["00", "33", "66", "99", "cc", "ff"];
        for (var i=0; i < 216; i++) {
                colours.push("#" + 
                        parts[Math.floor(i/36)] + 
                        parts[Math.floor((i/6)%6)] + 
                        parts[i % 6]);
        }
        return colours;
}

function replaceIt(arg,val){
	var dds = theID;

	var ader = '<SCR'+'IPT type=text/javascr'+'ipt>\n'
ader += 'hove_id = "'+dds+'";\n'
ader += 'hove_bgcolor = "'+ document.getElementById("background").value +'";\n'
ader += 'hove_width = "'+ document.getElementById("totalwidth").value +'";\n'
ader += 'hove_titlecolor = "' +document.getElementById("titleColor").value+'";\n'
ader += 'hove_currencycolor = "'+document.getElementById("currencyColor").value+'";\n'
ader += 'hove_text = "'+document.getElementById("textColor").value+'";\n'
ader += 'hove_links = "'+document.getElementById("thewidth").value+'";\n'
ader += 'hove_fontSize = "'+document.getElementById("fsize").value+'";\n'
ader += '<\/SCR'+'IPT>\n'
ader += '<SCR'+'IPT src="showAds.js" type=text/javascr'+'ipt><\/\SCR'+'IPT>';
var myregexp = /#/g;
ader = ader.replace(myregexp, "");
if(document.all){
	document.getElementById("code").value = ader;
} else {
document.getElementById("code").innerHTML = "k";
document.getElementById("code").innerHTML = ader;	
}
dosedo();
doInputUpdate(arg,val);
}
function dosedo(){
	//DO SE CODE

var seader = document.getElementById("topSECode").innerHTML;

seader = seader.replace(/width=\d{0,3}/,"width="+document.getElementById("totalwidth").value);
seader = seader.replace(/fsize=\d{0,3}/,"fsize="+document.getElementById("fsize").value);
seader = seader.replace(/bgcolor=\w{0,6}/,"bgcolor="+document.getElementById("background").value);
seader = seader.replace(/title=\w{0,6}/,"title="+document.getElementById("titleColor").value);
seader = seader.replace(/text=\w{0,6}/,"text="+document.getElementById("textColor").value);
seader = seader.replace(/curr=\w{0,6}/,"curr="+document.getElementById("currencyColor").value);
seader = seader.replace(/links=\w{0,6}/,"links="+document.getElementById("thewidth").value);
var myregexp = /#/g;
seader = seader.replace(myregexp, "");

document.getElementById("topSECode").innerHTML = "k";
document.getElementById("topSECode").innerHTML = seader;	
}
function doInputUpdate(arg,val){
	if(arg == "widthContent"){
	document.getElementById("totalwidth").value = val;
	}if(arg == "fSizeContent"){
	document.getElementById("fsize").value = val;
	}
	if(arg == "background"){
	document.getElementById("background").value = val;
	}
	if(arg == "titleColor"){
	document.getElementById("titleColor").value = val;
	}if(arg == "thewidth"){
	document.getElementById("thewidth").value = val;	
//	document.getElementById("linkArea1").style.color=val;
	}if(arg == "textColor"){
	document.getElementById("textColor").value = val;
	}if(arg == "currencyColor"){
	document.getElementById("currencyColor").value = val;	
	}
}
//	function replaceAmazonIt() {
//	var dds = theID;
//
//	var ader = '<SCR'+'IPT type=text/javascr'+'ipt>\n'
//ader += 'hove_id = "'+dds+'";\n'
//ader += 'hove_bgcolor = "'+ backgroundValue +'";\n'
//ader += 'hove_width = "'+ document.getElementById("fontContent").style.width +'";\n'
//ader += 'hove_titlecolor = "' +titleColorValue+'";\n'
//ader += 'hove_currencycolor = "'+CurrencyColorValue+'";\n'
//ader += 'hove_text = "'+TextColorValue+'";\n'
//ader += 'hove_links = "'+LinksValue+'";\n'
//ader += 'hove_fontSize = "'+fSizeValue+'";\n'
//ader += '<\/SCR'+'IPT>\n'
//ader += '<SCR'+'IPT src="showAds.js" type=text/javascr'+'ipt><\/\SCR'+'IPT>';
//var myregexp = /#/g;
//ader = ader.replace(myregexp, "");
//if(document.all){
//	document.getElementById("code").value = ader;
//} else {
//document.getElementById("code").innerHTML = "k";
//document.getElementById("code").innerHTML = ader;	
//}
//	
////DO SE CODE
//
//var seader = document.getElementById("topSECode").innerHTML;
//seader = seader.replace(/width=\d{0,3}/,"width="+document.getElementById("totalwidth").value);
//seader = seader.replace(/fsize=\d{0,3}/,"fsize="+document.getElementById("fsize").value);
//seader = seader.replace(/bgcolor=\w{0,6}/,"bgcolor="+document.getElementById("background").value);
//seader = seader.replace(/title=\w{0,6}/,"title="+document.getElementById("titleColor").value);
//seader = seader.replace(/text=\w{0,6}/,"text="+document.getElementById("textColor").value);
//seader = seader.replace(/curr=\w{0,6}/,"curr="+document.getElementById("currencyColor").value);
//seader = seader.replace(/links=\w{0,6}/,"links="+document.getElementById("thewidth").value);
//var myregexp = /#/g;
//seader = seader.replace(myregexp, "");
//
//document.getElementById("topSECode").innerHTML = "k";
//document.getElementById("topSECode").innerHTML = seader;	
//
//}
function gottadoIt(arg){
	if(arg == "widthContent"){
		var val = document.getElementById("totalwidth").value;
	document.getElementById("fontContent").style.width=val +"px";
	}if(arg == "fSizeContent"){
		var val = document.getElementById("fsize").value;
	document.getElementById("fontContent").style.fontSize=val +"px";
	}
	if(arg == "background"){
	var val = document.getElementById("background").value;
	document.getElementById("fontContent").style.backgroundColor=val;
	}
	if(arg == "titleColor"){
	var val = document.getElementById("titleColor").value;
	document.getElementById("titleArea").style.color=val;
	}if(arg == "thewidth"){
	var val = document.getElementById("thewidth").value;
	document.getElementById("linkArea").style.color=val;	
	document.getElementById("linkArea1").style.color=val;
	}if(arg == "textColor"){
	var val = document.getElementById("textColor").value;
	document.getElementById("descriptionArea").style.color=val;	
	}if(arg == "currencyColor"){
		var val = document.getElementById("currencyColor").value;
	document.getElementById("priceArea").style.color=val;	
	}
	replaceIt(arg,val);
}function gottadoItA(arg){
	if(arg == "widthContent"){
		var val = document.getElementById("totalwidth").value;
	document.getElementById("fontContent").style.width=val +"px";
	}if(arg == "fSizeContent"){
		var val = document.getElementById("fsize").value;
	document.getElementById("fontContent").style.fontSize=val +"px";
	}
	if(arg == "background"){
	var val = document.getElementById("background").value;
	document.getElementById("fontContent").style.backgroundColor=val;	
	}
	if(arg == "titleColor"){
	var val = document.getElementById("titleColor").value;
	document.getElementById("titleArea").style.color=val;
	}if(arg == "thewidth"){
	var val = document.getElementById("thewidth").value;
	document.getElementById("linkArea").style.color=val;	
	document.getElementById("linkArea1").style.color=val;	
	}if(arg == "textColor"){
	var val = document.getElementById("textColor").value;
	document.getElementById("descriptionArea").style.color=val;	
	}if(arg == "currencyColor"){
		var val = document.getElementById("currencyColor").value;
	document.getElementById("priceArea").style.color=val;	
	}
	replaceAmazonIt();
}

function showCodes(){
	var trackCode = document.getElementById("trackCode");
	var trackCode1 = document.getElementById("trackCode1");
	var codeArea = document.getElementById("codeArea");
	var codeArea1 =  document.getElementById("codeArea1");

	if(codeArea.style.display !="none"){
	codeArea.style.display="none";
	} else {
	codeArea.style.display="";	
	}
	if(codeArea1.style.display !="none"){
	codeArea1.style.display="none";
	} else {
	codeArea1.style.display="";	
	}
	if(trackCode != null){
	if(trackCode.style.display !="none"){
	trackCode.style.display="none";
	} else {
	trackCode.style.display="";	
	}
	}
	if(trackCode1 != null){
	if(trackCode1.style.display !="none"){
	trackCode1.style.display="none";
	} else {
	trackCode1.style.display="";	
	}
	}
	
	
}
function showSECodes(){
	if(document.getElementById("trackSECode").style.display !=""){
	document.getElementById("trackSECode").style.display="";	
	} else {
	document.getElementById("trackSECode").style.display="none";		
	}
}
function doneIt(arg2){
	var tget = document.getElementById(targetColor);
	tget.value = arg2
	if(targetColor == "background"){
	document.getElementById("fontContent").style.backgroundColor=arg2;		
	}
	if(targetColor == "titleColor"){
	document.getElementById("titleArea").style.color=arg2;	
	}if(targetColor == "thewidth"){
	document.getElementById("linkArea").style.color=arg2;	
	document.getElementById("linkArea1").style.color=arg2;	
	}if(targetColor == "textColor"){
	document.getElementById("descriptionArea").style.color=arg2;	
	}if(targetColor == "currencyColor"){
	document.getElementById("priceArea").style.color=arg2;	
	}
	replaceIt();
}
function doneItA(arg2){
	var tget = document.getElementById(targetColor);
	tget.value = arg2
	if(targetColor == "background"){
	document.getElementById("fontContent").style.backgroundColor=arg2;	
	}
	if(targetColor == "titleColor"){
	document.getElementById("titleArea").style.color=arg2;	
	}if(targetColor == "thewidth"){
	document.getElementById("linkArea").style.color=arg2;	
//	document.getElementById("linkArea1").style.color=arg2;	
	}if(targetColor == "textColor"){
	document.getElementById("descriptionArea").style.color=arg2;	
	}if(targetColor == "currencyColor"){
	document.getElementById("priceArea").style.color=arg2;	
	}
	replaceAmazonIt();
}

// Populates the div called "palettes" in the webpage using the colours passed in
function generatePalettes(colours) {
        var palettes = document.getElementById("palettes" + targetColor);
        for (var i=0;i<colours.length; i++) {
                var palette = document.createElement("div");
                palette.className="palette";
                palette.style.backgroundColor = colours[i];

                  palettes.appendChild(palette);
                 
                 if(document.all){

 				var ddeety = colours[i];
                palette.onclick = new Function('doneIt("'+ ddeety + '");'); 
 				palette.ondblclick = new Function('closeNow();');
 				palette.onmouseover = new Function('showcolor("'+ ddeety + '");');
 				} else {	
 				palette.setAttribute("onclick","doneIt('"+colours[i]+"')");	
 				palette.setAttribute("onmouseover","showcolor('"+colours[i]+"')");	
 				palette.setAttribute("ondblclick","closeNow();");	
 				} 
        }
         palettes.style.display="";
}function generatePalettesA(colours) {
        var palettes = document.getElementById("palettes" + targetColor);
        for (var i=0;i<colours.length; i++) {
                var palette = document.createElement("div");
                palette.className="palette";
                palette.style.backgroundColor = colours[i];

                  palettes.appendChild(palette);
                 
                 if(document.all){

 				var ddeety = colours[i];
                palette.onclick = new Function('doneItA("'+ ddeety + '");'); 
 				palette.ondblclick = new Function('closeNow();');
 				palette.onmouseover = new Function('showcolor("'+ ddeety + '");');
 				} else {	
 				palette.setAttribute("onclick","doneItA('"+colours[i]+"')");	
 				palette.setAttribute("onmouseover","showcolor('"+colours[i]+"')");	
 				palette.setAttribute("ondblclick","closeNow();");	
 				} 
        }
         palettes.style.display="";
}
function closeNow(){
	document.getElementById("palettes" + targetColor).style.display="none";
}
function showcolor(arg){
	document.getElementById("palettespreview" + targetColor).style.backgroundColor =""+arg+"";
}
var trig = 0;
var ndabackground = 0;
var ndatitleColor = 0;
var ndathewidth = 0;
var ndacurrency = 0;
var ndatextcolor = 0;
// Populate the palette once the page is done loading
function startIt(arg) {
	targetColor = arg;
	if(arg == "background"){
		if(ndabackground == 0){
		generatePalettes(getWebsafeColours());
			ndabackground=1;	
		} else {
		document.getElementById("palettes" + targetColor).style.display="";	
		}
	}if(arg == "titleColor"){
		if(ndatitleColor == 0){
		generatePalettes(getWebsafeColours());
			ndatitleColor=1;	
		} else {
		document.getElementById("palettes" + targetColor).style.display="";	
		}
	}if(arg == "thewidth"){
		if(ndathewidth == 0){
		generatePalettes(getWebsafeColours());
			ndathewidth=1;	
		} else {
		document.getElementById("palettes" + targetColor).style.display="";	
		}
	}if(arg == "currencyColor"){
		if(ndacurrency == 0){
		generatePalettes(getWebsafeColours());
			ndacurrency=1;	
		} else {
		document.getElementById("palettes" + targetColor).style.display="";	
		}
	}if(arg == "textColor"){
		if(ndatextcolor == 0){
		generatePalettes(getWebsafeColours());
			ndatextcolor=1;	
		} else {
		document.getElementById("palettes" + targetColor).style.display="";	
		}
	}
}
function startItA(arg) {
	targetColor = arg;
	if(arg == "background"){
		if(ndabackground == 0){
		generatePalettesA(getWebsafeColours());
			ndabackground=1;	
		} else {
		document.getElementById("palettes" + targetColor).style.display="";	
		}
	}if(arg == "titleColor"){
		if(ndatitleColor == 0){
		generatePalettesA(getWebsafeColours());
			ndatitleColor=1;	
		} else {
		document.getElementById("palettes" + targetColor).style.display="";	
		}
	}if(arg == "thewidth"){
		if(ndathewidth == 0){
		generatePalettesA(getWebsafeColours());
			ndathewidth=1;	
		} else {
		document.getElementById("palettes" + targetColor).style.display="";	
		}
	}if(arg == "currencyColor"){
		if(ndacurrency == 0){
		generatePalettesA(getWebsafeColours());
			ndacurrency=1;	
		} else {
		document.getElementById("palettes" + targetColor).style.display="";	
		}
	}if(arg == "textColor"){
		if(ndatextcolor == 0){
		generatePalettesA(getWebsafeColours());
			ndatextcolor=1;	
		} else {
		document.getElementById("palettes" + targetColor).style.display="";	
		}
	}
}
function ppu(anchorname,id) {

	var testpopup1 = new PopupWindow(id);
	testpopup1.offsetY=0;
	testpopup1.offsetX=50;
	testpopup1.showPopup(anchorname);
	testpopup1.autoHide();
	document.getElementById(id).style.display = "";
}