function oImage(pIndex,pImageId,pImageExtension,pKeyCount,pImageTitle,pDescritpion,pImageOwner) {
	this.index=pIndex
	this.dommId="img" + pIndex
	this.imageId=pImageId
	this.title=pImageTitle
	this.pImageOwner=pImageOwner
	this.ext=pImageExtension
	this.score=pKeyCount
	this.description=pDescritpion
	this.thumbUrl="http://easygome.com/imgsxxx/imgsmall" + pImageId + ".jpg"
	this.askerUrl="http://easygome.com/imgsxxx/imgSmall" + pImageId + ".jpg"
	this.imageUrl="http://easygome.com/imgsxxx/imgLarge" + pImageId + "." + pImageExtension
	this.makeThumb=makeThumb
	this.createImageGroup=createImageGroup
}

var groupTransport
var arImages
var activeImageId=0
function createImageGroup(pImageId) {
if (activeImageId>0) {
var oldObj=document.getElementById("askerThumbLink" + arImages[getIndexFromId(activeImageId)].dommId)
	if (oldObj) {
		oldObj.style.borderColor="black"
		}
		}
	var index=getIndexFromId(pImageId)
	activeImageId=pImageId
	// alert(index)
	var theObj=document.getElementById("askerThumbLink" + arImages[index].dommId)
	theObj.style.borderColor="yellow"
	// sizeIt(index,200,254)
	document.getElementById("drillingText").style.display="block"
		var txtUrl="http://easygome.com/inc/ajgetdrilledimages.asp?rc=20&imageId=" + pImageId + "&slevel=" + slevel
        groupTransport=GetXmlHObject(proccessImageGroup)
        groupTransport.open("GET", txtUrl , true)
        groupTransport.send(null)
}
function reCreateGroup(pImageId) {
	activeImageId=pImageId
	// sizeIt(index,200,254)
	document.getElementById("drillingText").style.display="block"
		var txtUrl="http://easygome.com/inc/ajgetdrilledimages.asp?rc=20&imageId=" + pImageId + "&slevel=" + slevel
        groupTransport=GetXmlHObject(proccessImageGroup)
        groupTransport.open("GET", txtUrl , true)
        groupTransport.send(null)
}
function sizeIt(pIndex,pWidth,pHeight) {

	var oImg=document.getElementById(arImages[pIndex].dommId)
	if (oImg) {
		oImg.style.width=pWidth + "px"
		oImg.style.height=pHeight + "px"
	}

}
function shrinkImage(pImageId) {
var oldObj=document.getElementById(arImages[getIndexFromId(pImageId)].dommId)
	if (oldObj) {
		oldObj.style.width="100px"
		oldObj.style.height="125px"
		}

}
function createRandomImageGroup(pCount) {
	document.getElementById("drillingText").style.display="block"
		var txtUrl="http://easygome.com/inc/ajgetdrilledimages.asp?rc=" + pCount + "&slevel=" + slevel
		 groupTransport=GetXmlHObject(proccessImageGroup)
        groupTransport.open("GET", txtUrl , true)
        groupTransport.send(null)
}
function getIndexFromId(pImageId) {
	var intIndex=-1
	var i
	for (i=0;i<arImages.length;i++) {
		if (arImages[i].imageId==pImageId) {
			intIndex=i
		}	
	}
	return intIndex
}
function proccessImageGroup() {
    if (groupTransport.readyState==4 || groupTransport.readyState=="complete") {
    var strResponse=groupTransport.responseText
	 arImages=null
	arImages=new Array()
	var arImageData=strResponse.split("####")
	var i
	for (i=0;i<arImageData.length;i++) {
		arImages[arImages.length]=new oImage(arImages.length,arImageData[i].split("@@@")[0],arImageData[i].split("@@@")[1],arImageData[i].split("@@@")[2],arImageData[i].split("@@@")[5],arImageData[i].split("@@@")[6],arImageData[i].split("@@@")[8])
	}
	outputImageGroup("rightResultBox")
		var index=getIndexFromId(activeImageId)
		if (index>=0) {
		activeImageId=arImages[index].imageId
	var theObj=document.getElementById("askerThumbLink" + arImages[index].dommId)
	if (theObj) {
		theObj.style.borderColor="yellow"
	var oldObj=document.getElementById(arImages[index].dommId)
	if (oldObj) {
		oldObj.style.width="100px"
		oldObj.style.height="127px"
		}
		}
		} else {
		activeImageId=0
		}
		document.getElementById("drillingText").style.display="none"
		setTimeout("fitImages()",2000)
		// fitImages()
}
}
function outputImageGroup(pContainer) {

var container=document.getElementById(pContainer)
 if (container.childNodes.length>0) {
 	for (i=0;i<container.childNodes.length;i++) {
			container.removeChild(container.childNodes[i])
	}
}
container.innerHTML=""
// container.innerHTML="Click on any thumbnail image to view it's original size<br>"
var i
for (i=0;i<arImages.length;i++) {
container.appendChild(arImages[i].makeThumb())
}
	//initLightbox()
}

function makeThumb() {

var img = document.createElement('IMG');
img.setAttribute('src', this.askerUrl);
img.className="askerThumb"
img.id=this.dommId
img.height=127
img.width=100
 var thumbLink = document.createElement("a");
						// thumbLink.setAttribute("rel", "lightbox");
						thumbLink.href = "javascript:void(0)"
						thumbLink.id="askerThumbLink" + this.dommId
						thumbLink.className="askerThumbLink"
						thumbLink.setAttribute("title",this.title)
						var theId=this.imageId
						thumbLink.onclick=function(){ 
								// showHotPhoto(theId);
								createImageGroup(theId);
						 } 
						 
						//	thumbLink.onmouseover=function(){ 
								// showHotPhoto(theId);
							//	shrinkImage(theId);
					//	 } 
					
						var vl=document.createElement("DIV")
						vl.className="voteLabelBox"
						vl.innerHTML=this.score + "%"
						thumbLink.appendChild(vl)
							thumbLink.appendChild(img)
						return thumbLink
			}
	function getImageIds() {
	var i
	var str=""
	for (i=0;i<arImages.length;i++) {
	if (str!="") {
	str=str + ","
	}
	str=str + arImages[i].imageId
	}
	return str
	}		
			
function toTagifier() {
	window.location="http://easygome.com/photo-sharing/image-tagifier.asp?lst=" + getImageIds()
}

function fitImages() {
	var i
	for (i=(arImages.length-1);i>=0;i--) {
	var imgo=document.getElementById(arImages[i].dommId)
	if (imgo) {
			imgo.style.width="100px"
		imgo.style.height="127px"
	}
	
	}

}
function toScopinator() {
	window.location="http://easygome.com/photo-sharing/scopinator-photo-manager.asp?lsl=" + getImageIds()
}

function toScraper() {
	window.location="http://easygome.com/photo-sharing/picture-scraper.asp?lst=" + getImageIds()
}
function toProfiler() {
	window.location="http://easygome.com/photo-sharing/image-profile.asp?timgid=" + arImages[1].imageId + "&nme=Photo Drilled Set&lts=" + getImageIds()
}
function GetXmlHObject(handler){
var objXmlHttpShare=null

if (navigator.userAgent.indexOf("Opera")>=0)
{
alert("This doesn\'t work in Opera")
return
}
if (navigator.userAgent.indexOf("MSIE")>=0)
{
var strName="MSXML2.XMLHTTP"
if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
{
strName="Microsoft.XMLHTTP"
}
try
{
objXmlHttpShare=new ActiveXObject(strName)
objXmlHttpShare.onreadystatechange=handler
return objXmlHttpShare
}
catch(e)
{
alert("Error. Scripting for ActiveX might be disabled  errors: " + e)

return
}
}
if (navigator.userAgent.indexOf("Mozilla")>=0)
{
objXmlHttpShare=new XMLHttpRequest()
objXmlHttpShare.onload=handler
objXmlHttpShare.onerror=handler
return objXmlHttpShare
}
}

function makePoster(h,w,c) {
		document.getElementById("posterizing").style.display="block"
var txtUrl="http://easygome.com/inc/ajmakedrillerpostera.asp?scopeList=" + getImageIds() + "&h=" + h + "&w=" + w + "&c=" + c + "&memId=" + memId
        groupTransport=GetXmlHObject(makeCustomPosterResponse)
        groupTransport.open("GET", txtUrl , true)
        groupTransport.send(null)

}


var custPost


function makePosterSmall(h,w,c) {
		document.getElementById("posterizing").style.display="block"
var txtUrl="http://easygome.com/inc/ajmakedrillerpoatersmall.asp?scopeList=" + getImageIds() + "&h=" + h + "&w=" + w + "&c=" + c + "&memId=" + memId
        groupTransport=GetXmlHObject(makeCustomPosterSmallResponse)
        groupTransport.open("GET", txtUrl , true)
        groupTransport.send(null)

}

function makeCustomPosterSmallResponse() {
      if (groupTransport.readyState==4 || groupTransport.readyState=="complete"){
  var rt=groupTransport.responseText
 var ht=parseInt(rt.split("@@")[1])
 var wd=parseInt(rt.split("@@")[2])
var imgName=rt.split("@@")[0]

		document.getElementById("posterizing").style.display="none"
setTimeout("showLightbox('http://easygome.com/imgsxxx/" + imgName + "','new poster');",1000)
 // showInModel("http://easygome.com/gview.asp?strImage=" + imgName + "&wd=" + wd + "&ht=" + ht,ht,wd) 

}
}


function makeCustomPosterResponse() {
      if (groupTransport.readyState==4 || groupTransport.readyState=="complete"){
  var rt=groupTransport.responseText
 var ht=parseInt(rt.split("@@")[1])
 var wd=parseInt(rt.split("@@")[2])
var imgName=rt.split("@@")[0]

		document.getElementById("posterizing").style.display="none"
setTimeout("showLightbox('http://easygome.com/imgsxxx/" + imgName + "','new poster');",1000)
 // showInModel("http://easygome.com/gview.asp?strImage=" + imgName + "&wd=" + wd + "&ht=" + ht,ht,wd) 

}
}
