function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            if (oldonload) {
                oldonload();
            }
            func();
        }
    }
    
}

var ImgPath='http://www.artflute.com/';
var ImgAry=[];
var ImgAry1=[];
var strAppPath=ImgPath;

var preLoad = new Array()
var rankImgSet=new Array();

function PreloadImages()
{
	preLoad[0] = new Image(200,100)
	preLoad[0].src = strAppPath + "images/addtocart.gif"

	preLoad[1] = new Image(200,100)
	preLoad[1].src = strAppPath + "images/sold.gif"

	preLoad[2] = new Image(200,100)
	preLoad[2].src = strAppPath + "images/Soldoffline.gif"

	preLoad[3] = new Image(200,100)
	preLoad[3].src = strAppPath + "images/onhold.gif"

	preLoad[4] = new Image(200,100)
	preLoad[4].src = strAppPath + "images/cart.gif"

	preLoad[5] = new Image(200,100)
	preLoad[5].src = strAppPath + "images/cartsold.gif"

	preLoad[6] = new Image(200,100)
	preLoad[6].src = strAppPath + "images/cartsold.gif"

	preLoad[7] = new Image(200,100)
	preLoad[7].src = strAppPath + "images/carthold.gif"

	rankImgSet[0]=new Image();
	rankImgSet[0].src=strAppPath + "images/star.gif"
	rankImgSet[1]=new Image();
	rankImgSet[1].src=strAppPath + "images/star_over.gif"
}
addLoadEvent(PreloadImages);
function swapImgRestore(objimg) { 
	objimg.src=rankImgSet[0].src;
}
function swapImage(objimg) { 
	objimg.src=rankImgSet[1].src;
}


function windowopen(stringhref)
{
 	showPopWin(stringhref, 650, 600,null)
	return false;
}
function artid(id)
{
	var arthref="frmArtist" + id + ".shtml";
	window.open(arthref,"_blank","toolbars=0,status=0,scrollbars=1,00px,dialogWidth=1010px,dialogLeft=0,dialogTop=0")
}

function DisplayDetails(id)
{
	document.getElementById('trdisplay' + id).style.display='none';
	document.getElementById('trhide' + id).style.display='';
	document.getElementById('trdesc' + id).style.display='';            
}
function HideDetails(id)
{
	document.getElementById('trdisplay' + id).style.display='';
	document.getElementById('trhide' + id).style.display='none';
	document.getElementById('trdesc' + id).style.display='none';            
}
 function popUpPoistion(popUpId)
    {
        document.getElementById(popUpId).style.display = "";
        
        var divHeight = 300;
        var divWidth = 200;  

       if(parseInt(document.getElementById(popUpId).style.heigh) > 0)
       {
            divHeight = parseInt(document.getElementById(popUpId).style.heigh);
       }     
       
       if(parseInt(document.getElementById(popUpId).style.width) > 0)
       {
            divWidth = parseInt(document.getElementById(popUpId).style.width);
       }

       document.getElementById(popUpId).style.top = ((screen.availHeight - divHeight)/2 + document.documentElement.scrollTop) + "px";
       document.getElementById(popUpId).style.left = ((screen.availWidth - divWidth)/2 + document.documentElement.scrollLeft - 150) + "px";
     
       return true;
    }

function zxcScroller(zxcmde,zxcid,zxcrun,zxcud,zxcspd,zxcsrt){
 var zxcp=document.getElementById(zxcid);
 if (!zxcp[zxcmde+'scroll']) return zxcp[zxcmde+'scroll']= new zxcScrollerOOP(zxcmde,zxcp,zxcrun,zxcud,zxcspd,zxcsrt);
 var zxcoop=zxcp[zxcmde+'scroll']
 clearTimeout(zxcp.to);
 zxcoop.spd=zxcspd||zxcoop.spd;
 zxcoop.ud=zxcud||-zxcoop.ud; 
 zxcp[zxcmde+'run']=(zxcrun=='stop'||zxcrun=='start')?zxcrun:(zxcp[zxcmde+'run']=='stop')?'start':'stop';
    if (zxcp[zxcmde+'run']=='start')
    {           
        zxcoop.scroll();
    } 
}

function zxcScrollerOOP(zxcmde,zxcp,zxcrun,zxcud,zxcspd,zxcsrt)
{ 
 this.p=zxcp;
 var zxcc=this.p.getElementsByTagName('DIV')[0]
 this.vh=(StrCharAt(zxcmde,0,'L')=='v');
 this.mde=zxcmde;
 this.ary=[]; 
 this.ary[0]=[zxcc,0];
 var zxcmax=(((this.vh)?this.ary[0][0].offsetHeight:this.ary[0][0].offsetWidth))+((this.vh)?this.p.offsetHeight:this.p.offsetWidth);
 this.wh=(StrCharAt(this.mde,0,'L')=='v')?this.ary[0][0].offsetHeight:this.ary[0][0].offsetWidth;
 var zxcpos=0;  
 while (zxcpos<zxcmax)
 {  
  var zxc1=this.ary.length;     
  this.ary[zxc1]=[zxcES(this.ary[0][0].cloneNode(true),{},this.p),zxcpos+=this.wh];  
 } 
 this.ud=zxcud||-1;
 this.spd=zxcspd||100;
 this.p.to=null;
 this.data=[zxcpos,-this.wh];
 this.p[this.mde+'run']=(zxcrun=='stop'||zxcrun=='start')?zxcrun:'start';
 if (this.p[this.mde+'run']) this.p.to=setTimeout(function(zxcoop){return function(){zxcoop.scroll();}}(this),zxcsrt||500);
}

zxcScrollerOOP.prototype.scroll=function(){
 if (this.p[this.mde+'run']=='start'){
  for (var zxc1=0;zxc1<this.ary.length;zxc1++){   
   this.ary[zxc1][1] +=this.ud;      
   zxcES(this.ary[zxc1][0],{position:'absolute',left:((this.vh)?0:this.ary[zxc1][1])+'px',top:((this.vh)?this.ary[zxc1][1]:0)+'px'});   
   if ((this.ud<0&&this.ary[zxc1][1]<=this.data[1])||(this.ud>0&&this.ary[zxc1][1]>this.data[0])) this.ary[zxc1][1]=this.data[(this.ud<0)?0:1];
  }
 }
 this.p.to=setTimeout(function(zxcoop){return function(){zxcoop.scroll();}}(this),this.spd);
}

function zxcES(zxcele,zxcstyle,zxcp,zxctxt)
{     
 if (typeof(zxcele)=='string'){ zxcele=document.createElement(zxcele); }
 for (key in zxcstyle)
 {  
    zxcele.style[key]=zxcstyle[key];     
 }  
 if (zxcp){zxcp.appendChild(zxcele);} 
 if (zxctxt){zxcele.appendChild(document.createTextNode(zxctxt));} 
 return zxcele;
}

function zxcBAnimator(zxcmde,zxcobj,zxcsrt,zxcfin,zxctime){
 if (typeof(zxcobj)=='string'){ zxcobj=document.getElementById(zxcobj); }
 if (!zxcobj||(!zxcsrt&&!zxcfin)) return;
 var zxcoop=zxcobj[StrReplace(zxcmde,/[-#]/g,'')+'oop'];
 if (zxcoop){
  clearTimeout(zxcoop.to);
  if (zxcoop.srtfin[0]==zxcsrt&&zxcoop.srtfin[1]==zxcfin&&zxcmde.match('#')) zxcoop.update([zxcoop.data[0],(zxcoop.srtfin[0]==zxcoop.data[2])?zxcfin:zxcsrt],zxctime);
  else zxcoop.update([zxcsrt,zxcfin],zxctime);
 }
 else zxcobj[StrReplace(zxcmde,/[-#]/g,'')+'oop']=new zxcBAnimatorOOP(zxcmde,zxcobj,zxcsrt,zxcfin,zxctime);
}

function zxcBAnimatorOOP(zxcmde,zxcobj,zxcsrt,zxcfin,zxctime){
 this.srtfin=[zxcsrt,zxcfin];
 this.to=null;
 this.obj=zxcobj;
 this.mde=StrReplace(zxcmde,/[-#]/g,'');
 this.update([zxcsrt,zxcfin],zxctime);
}

zxcBAnimatorOOP.prototype.update=function(zxcsrtfin,zxctime){
 this.time=zxctime||this.time||2000;
 if (zxcsrtfin[0]==zxcsrtfin[1]) return;
 this.data=[zxcsrtfin[0],zxcsrtfin[0],zxcsrtfin[1]];
 this.srttime=new Date().getTime();
 this.cng();
}

zxcBAnimatorOOP.prototype.cng=function(){
 var zxcms=new Date().getTime()-this.srttime;
 this.data[0]=(this.data[2]-this.data[1])/this.time*zxcms+this.data[1];
 if (this.mde!='opacity') this.obj.style[this.mde]=this.data[0]+'px';
 else  this.opacity(this.data[0]);
 if (zxcms<this.time) this.to=setTimeout(function(zxcoop){return function(){zxcoop.cng();}}(this), 10);
 else {
  if (this.mde!='opacity') this.obj.style[this.mde]=this.data[2]+'px';
  else  this.opacity(this.data[2]);
 }
}

zxcBAnimatorOOP.prototype.opacity=function(zxcopc){
 if (zxcopc<0||zxcopc>100){ return; }
}




// parameter 0 = the id of the parent Node.              (string)
// parameter 1 = the image array.                        (array)
// parameter 2 = the width * height of the image parent. (string)
// parameter 3 = the width * height of the image.        (string)
// parameter 4 = the speed on the resize effect.         (string)

function zxcScrollContent(zxcid,zxcary,zxcdivsz,zxcimgsz,zxcopac,zxcspd)
{      
    
 zxcdivsz=zxcdivsz||'120*100';
 zxcimgsz=zxcimgsz||'80*80';
 zxcopac=zxcopac||'100*50';
 zxcspd=zxcspd||200;
 var zxcp=document.getElementById(zxcid);
 zxcdivsz=StrSplit(zxcdivsz,'*');
 zxcimgsz=StrSplit(zxcimgsz,'*');
 zxcopac=StrSplit(zxcopac,'*');
 var zxcc=zxcES('DIV',{position:'relative'},zxcp);  
 
 for (var zxc0=0;zxc0<zxcary.length;zxc0++)
 {  
    var zxcdiv=zxcES('DIV',{position:'absolute',left:zxcdivsz[0]*zxc0+'px',top:'0px',width:zxcdivsz[0]+'px',height:zxcdivsz[1]+'px'},zxcc);
    if (zxcary[zxc0][1]) zxcdiv.title=zxcary[zxc0][1];  
    var zxca=null;
    if (zxcary[zxc0][2]&&zxcary[zxc0][2]!='')
    {        
        zxca=zxcES('A',{},zxcdiv);
        zxca.href=zxcary[zxc0][2];  
    }
    var zxcimg=zxcES('IMG',{position:'absolute',left:(zxcdivsz[0]-zxcimgsz[0])/2+'px',top:(zxcdivsz[1]-zxcimgsz[1])/2+'px',width:zxcimgsz[0]+'px',height:zxcimgsz[1]+'px',borderWidth:'0px'},(zxcary[zxc0][2])?zxca:zxcdiv);    
    //zxcimg.src=zxcary[zxc0][0];
	 var srctemp=zxcary[zxc0][0];
    if(srctemp.indexOf("ImageThumbnailer.ashx")<0)
    {   
        srctemp=srctemp.replace(ImgPath,"");
        zxcimg.src= "ImageThumbnailer.ashx?sizeType=OriSize&img=" + srctemp;
    }
    else
    {
        zxcimg.src= srctemp;
    }
 }  
 zxcES(zxcc,{width:zxcdivsz[0]*zxcary.length+'px',height:zxcdivsz[1]+'px'});
 zxcScroller('h',zxcid,'start',-1,10,1200); 
 
 var zxcimgs=zxcp.getElementsByTagName('IMG');
 var zxccnt=0;   
 for (var zxc1=0;zxc1<zxcimgs.length;zxc1++)
 { 
  zxcimgs[zxc1].data=[(zxcdivsz[0]-zxcimgsz[0])/2,(zxcdivsz[1]-zxcimgsz[1])/2,zxcimgsz[0]*1,zxcdivsz[0]*1,zxcimgsz[1]*1,zxcdivsz[1]*1,zxcopac[0]*1,zxcopac[1]*1];
  if (window[zxcary[zxccnt][3]])
  {   
   zxcimgs[zxc1].nu=zxccnt;
   zxcimgs[zxc1].fun=zxcary[zxccnt][3];
   zxcimgs[zxc1].onclick=function(){ window[this.fun](this.nu); }
  }
  zxccnt=++zxccnt%zxcary.length  
 }
}

function zxcReSize(zxcobj,zxcspd){
 zxcBAnimator('width#',zxcobj,zxcobj.data[2],zxcobj.data[3],zxcspd);
 zxcBAnimator('left#',zxcobj,zxcobj.data[0],0,zxcspd);
 zxcBAnimator('height#',zxcobj,zxcobj.data[4],zxcobj.data[5],zxcspd);
 zxcBAnimator('top#',zxcobj,zxcobj.data[1],0,zxcspd);
 zxcBAnimator('opacity#',zxcobj,zxcobj.data[6],zxcobj.data[7],zxcspd);
}

function MyFunction(nu){
 document.Show.Show0.value=ImgAry[nu]; 
 return false;
}

