
function  startUpload(filename) {
	document.getElementById('PostFileAreaDiv').innerHTML = "Please wait while we upload your file, " + filename + ".<br><img src=\"../images/loader.gif\" width=\"480\" height=\"360\" />";
	document.getElementById('PostFileAreaDiv').style.visibility = "visible";
}

function PrintUploadForm(type,filename) {
	var xmlHttp;
	try {
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	} catch (e) {
		// Internet Explorer
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4) {
			document.getElementById('PostFileArea').innerHTML=xmlHttp.responseText;
		}
	}
	if (type.length) {
		parameter="?type="+type+"&filename="+filename;
	} else {
		parameter="";
	}
	xmlHttp.open("GET","uploadfile.php"+parameter,true);
	xmlHttp.send(null);
}

function ClipBoard() {
	holdtext.innerText = copytext.innerText;
	Copied = holdtext.createTextRange();
	Copied.execCommand("Copy");
}


function str_replace (search, replace, subject, count) {
    // Replaces all occurrences of search in haystack with replace  
    // 
    // version: 908.406
    // discuss at: http://phpjs.org/functions/str_replace
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Gabriel Paderni
    // +   improved by: Philip Peterson
    // +   improved by: Simon Willison (http://simonwillison.net)
    // +    revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +   bugfixed by: Anton Ongson
    // +      input by: Onno Marsman
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +    tweaked by: Onno Marsman
    // +      input by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   input by: Oleg Eremeev
    // +   improved by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Oleg Eremeev
    // %          note 1: The count parameter must be passed as a string in order
    // %          note 1:  to find a global variable in which the result will be given
    // *     example 1: str_replace(' ', '.', 'Kevin van Zonneveld');
    // *     returns 1: 'Kevin.van.Zonneveld'
    // *     example 2: str_replace(['{name}', 'l'], ['hello', 'm'], '{name}, lars');
    // *     returns 2: 'hemmo, mars'
    var i = 0, j = 0, temp = '', repl = '', sl = 0, fl = 0,
            f = [].concat(search),
            r = [].concat(replace),
            s = subject,
            ra = r instanceof Array, sa = s instanceof Array;
    s = [].concat(s);
    if (count) {
        this.window[count] = 0;
    }

    for (i=0, sl=s.length; i < sl; i++) {
        if (s[i] === '') {
            continue;
        }
        for (j=0, fl=f.length; j < fl; j++) {
            temp = s[i]+'';
            repl = ra ? (r[j] !== undefined ? r[j] : '') : r[0];
            s[i] = (temp).split(f[j]).join(repl);
            if (count && s[i] !== temp) {
                this.window[count] += (temp.length-s[i].length)/f[j].length;}
        }
    }
    return sa ? s : s[0];
}


function InsertUploadBoxes(NumPics)
  {
  var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
    xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
        document.getElementById("UploadBoxes").innerHTML=xmlHttp.responseText;
        }
      }
    xmlHttp.open("GET","insertuploadbox.php?NumPics="+NumPics,true);
    xmlHttp.send(null);
  }

function ItemPhoto(Table,ID,RandomString) {
	var xmlHttp;
	try {
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	} catch (e) {
		// Internet Explorer
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4) {
			document.getElementById("ItemPhoto").innerHTML=xmlHttp.responseText;
		}
	}
	xmlHttp.open("GET","itemphotos.php?Table="+Table+"&ID="+ID+"&RandomString="+RandomString,true);
	xmlHttp.send(null);
}

function ItemPhotoAction(Table,ID,PhotoID,Action) {
	var xmlHttp;
	try {
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	} catch (e) {
		// Internet Explorer
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4) {
			document.getElementById("ItemPhoto").innerHTML=xmlHttp.responseText;
		}
	}
	xmlHttp.open("GET","itemphotos.php?Action="+Action+"&PhotoID="+PhotoID+"&ID="+ID+"&Table="+Table,true);
	xmlHttp.send(null);
}

function ChangeFeature(ID,Table) {
	var Feature;
	if(document.getElementById("feature"+Table+ID).checked) {
		Feature = 1;
	} else {
		Feature = 0;
	}
	var xmlHttp;
	try {
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	} catch (e) {
		// Internet Explorer
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
/*	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4) {
			alert(xmlHttp.responseText);
		}
	}*/
	xmlHttp.open("GET","../admin/changefeature.php?feature="+Feature+"&ID="+ID+"&Table="+Table,true);
	xmlHttp.send(null);
};

function PageHeight() {
	return (document.documentElement && document.documentElement.scrollHeight) ? document.documentElement.scrollHeight : (document.body.scrollHeight > document.body.offsetHeight) ? document.body.scrollHeight : document.body.offsetHeight;
};

function LoadColumns() {
  var xmlHttp;
  strPage = window.location.pathname;
  if (strPage.substring(1,7)=="wanted") {
	  strType = "wanted";
  } else {
	  strType = "product";
  };
//  document.getElementById("PrintPathname").innerHTML = strType; 
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
    xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
			if(xmlHttp.responseText=="right") {
        		document.getElementById("RightColumn").innerHTML="<iframe src=\""+strType+"listside.php\" name=\"Event Calendar\" width=\"188\" height=\""+PageHeight()+"\" scrolling=\"no\" frameborder=\"0\" allowtransparency=\"true\"></iframe>";
				document.getElementById("RightColumnTD").style.backgroundImage="url(/images/linevert.gif)";
				document.getElementById("RightColumnTD").style.backgroundPosition="right";
				document.getElementById("RightColumnTD").style.backgroundRepeat="repeat-y";
			} else if(xmlHttp.responseText=="left") {
				document.getElementById("LeftColumn").innerHTML="<iframe src=\"categorysample.html\" name=\"Categories\" width=\"188\" height=\""+String(parseInt(PageHeight())-263)+"\" scrolling=\"no\" frameborder=\"0\" allowtransparency=\"true\"></iframe>";
				document.getElementById("LeftColumnTD").style.backgroundImage="url(/images/linevert.gif)";
				document.getElementById("LeftColumnTD").style.backgroundPosition="right";
				document.getElementById("LeftColumnTD").style.backgroundRepeat="repeat-y";
			} else if(xmlHttp.responseText=="rightleft") {
        		document.getElementById("RightColumn").innerHTML="<iframe src=\""+strType+"listside.php\" name=\"Event Calendar\" width=\"188\" height=\""+PageHeight()+"\" scrolling=\"no\" frameborder=\"0\" allowtransparency=\"true\"></iframe>";
				document.getElementById("RightColumnTD").style.backgroundImage="url(/images/linevert.gif)";
				document.getElementById("RightColumnTD").style.backgroundPosition="right";
				document.getElementById("RightColumnTD").style.backgroundRepeat="repeat-y";
				document.getElementById("LeftColumn").innerHTML="<iframe src=\"categorysample.html\" name=\"Categories\" width=\"188\" height=\""+String(parseInt(PageHeight())-263)+"\" scrolling=\"no\" frameborder=\"0\" allowtransparency=\"true\"></iframe>";
				document.getElementById("LeftColumnTD").style.backgroundImage="url(/images/linevert.gif)";
				document.getElementById("LeftColumnTD").style.backgroundPosition="right";
				document.getElementById("LeftColumnTD").style.backgroundRepeat="repeat-y";
			};
        }
      }
    xmlHttp.open("GET","/Scripts/CheckColumns.php",true);
    xmlHttp.send(null);
};

function DisplayItemList(CategoryID,Page) {
  document.getElementById("ItemList").innerHTML="<p align=\"center\"><img src=\"../images/preloader.gif\" width=\"58\" height=\"63\" /></p>";
  var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
    xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
        document.getElementById("ItemList").innerHTML=xmlHttp.responseText;
        }
      }
    xmlHttp.open("GET","itemlist.php?CategoryID="+CategoryID+"&Page="+Page,true);
    xmlHttp.send(null);
};
function IMGZoom(Zoom,PhotoID,Table) {
	if(Zoom) {
		
		var xmlHttp;
		try {
			// Firefox, Opera 8.0+, Safari
			xmlHttp=new XMLHttpRequest();
		} catch (e) {
			// Internet Explorer
			try {
				xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try {
					xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {
					alert("Your browser does not support AJAX!");
					return false;
				}
			}
		}
		xmlHttp.onreadystatechange=function() {
			if(xmlHttp.readyState==4) {
				
				var AjaxResult = xmlHttp.responseText;
				var ImageSize = AjaxResult.split("|");
				
				if (document.getElementById("MainImage").alt=="Photo") {
					document.getElementById("ImageTD").innerHTML='<img src="admin/displayphoto.php?Type='+Table+'Photo&ID='+PhotoID+'&FieldName=FullSize" id="MainImage" alt="FullSize" width="'+ImageSize[0]+'" height="'+ImageSize[1]+'" />';
					
				} else {
					document.getElementById("MainImage").width = ImageSize[0];
					document.getElementById("MainImage").height = ImageSize[1];
				};
				
				if(Zoom==5) {
					document.getElementById("ZoomTD").innerHTML='<a href="javascript:void()" onclick="IMGZoom(4,'+PhotoID+',\''+Table+'\')"><img src="../images/zoomout.gif" width="111" height="30" border="0" /></a>';
				} else {
					if(ImageSize[2]>400) {
						document.getElementById("ZoomTD").innerHTML='<a href="javascript:void()" onclick="IMGZoom('+(parseInt(Zoom)+1)+','+PhotoID+',\''+Table+'\')"><img src="../images/zoomin.gif" width="98" height="30" border="0" /></a>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<a href="javascript:void()" onclick="IMGZoom('+(parseInt(Zoom)-1)+','+PhotoID+',\''+Table+'\')"><img src="../images/zoomout.gif" width="111" height="30" border="0" /></a>';	
					} else {
						document.getElementById("ZoomTD").innerHTML='<a href="javascript:void()" onclick="IMGZoom(0,'+PhotoID+',\''+Table+'\')"><img src="../images/zoomout.gif" width="111" height="30" border="0" /></a>';
					};
				};
				
				
			}
		}
		xmlHttp.open('GET','imagesize.php?PhotoID='+PhotoID+'&Table='+Table+'&Zoom='+Zoom,true);
		xmlHttp.send(null);		
		
	} else {
		document.getElementById("ImageTD").innerHTML='<img src="admin/displayphoto.php?Type='+Table+'Photo&ID='+PhotoID+'&FieldName=Photo" id="MainImage" alt="Photo" />';
		document.getElementById("ZoomTD").innerHTML='<a href="javascript:void()" onclick="IMGZoom(1,'+PhotoID+',\''+Table+'\')"><img src="../images/zoomin.gif" width="98" height="30" border="0" /></a>';
	}
};

function CheckAuction() {
	var xmlHttp;
	try {
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	} catch (e) {
		// Internet Explorer
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4) {
			var NumRows = parseInt(xmlHttp.responseText);
			if (NumRows < 1) {
				document.getElementById("Image5").style.display = "none";
			}
		}
	}
	xmlHttp.open("GET","auctionlist.php?Action=Check",true);
	xmlHttp.send(null);
}