//Ŭ¸¯ À̺¥Æ® ÈÄ À̹ÌÁö ¹Ù²Ù±â var ClickChangeImage = function(){ this.saveimage = new Array(); //Ãâ·Â À̹ÌÁö ÀúÀå this.saveid = new Array(); //Ãâ·Â ¾ÆÀ̵ð ÀúÀå this.changecssname = ""; //¹Ù²ðcss¸í ÁöÁ¤ this.currentcssname = ""; //±âÁ¸css¸í ÁöÁ¤ this.printnum = 1; //Ãâ·Â °¹¼ö this.timedelay = 3000; //3ÃÊ this.autowordcssidx = 0; //cssÀû¿ëµÈ ¹è¿­ index this.currentviewnum = 1; // ÇöÀç º¸¿©Áö°í ÀÖ´Â È­¸é this.settimeoutid = false; this.secondsaveimage = new Array(); //µÎ¹øÂ° Ãâ·ÂÀ̹ÌÁö ÀúÀå this.secondsaveid = new Array(); //µÎ¹øÂ° Ãâ·Â ¾ÆÀ̵ð ÀúÀå this.secondgroup = new Array(); //µÎ¹øÂ° Ãâ·Â ±×·ì ÀúÀå this.savearray = new Array(); //Á¿ì È­»ìÇ¥ ÀúÀå this.layersize = new Array(); //Á¿ì À̵¿ ·¹ÀÌ¾î °¹¼ö this.layermax = new Array(); //ÁÂ¿ì ·¹À̾î Àüü Å©±â this.moveposition = 4; //À̵¿ ¼Óµµ (°Å¸®) this.currentlayer = new Array(); //ÇöÀç ·¹À̾îÀ§Ä¡ this.choicelayer = 0; //À̵¿ÇÑ ·¹À̾î this.layercount = new Array(); this.layerid = 0; this.layerspeed =40; //º¯È¯ ¼Óµµ (½Ã°£) this.arrowsize = 0; this.savebutton = new Array(); //¹öưÀ̹ÌÁö ÀúÀå this.saveradiobutton = new Array(); //Radio ¹öư ¼ºÁú ¾ÆÀ̵ð ÀúÀå this.browerinfo = ""; //ºê¶ó¿ìÀú Á¤º¸ this.browerinfo_array = new Array("MSIE 8.0","MSIE 9.0","Chrome","Safari","Opera","Firefox"); for( var i=0; i < this.browerinfo_array.length; i++){ if( navigator.userAgent.indexOf( this.browerinfo_array[i] ) > 0 ){ this.browerinfo = this.browerinfo_array[i]; } } } //Ãâ·ÂµÉ À̹ÌÁö ÀúÀåÇϱâ ClickChangeImage.prototype.setImageSave = function( imagearray ){ for ( var i = 0; i < imagearray.length; i++ ){ this.saveimage[i] = imagearray[i]; } } //Ãâ·Â ¾ÆÀ̵𰪠ÀúÀåÇϱâ ClickChangeImage.prototype.setId = function( idarray ){ for ( var i = 0; i < idarray .length; i++ ){ this.saveid[i] = idarray[i]; } } //µÎ¹øÂ° Ãâ·ÂµÉ À̹ÌÁö ÀúÀåÇϱâ ClickChangeImage.prototype.setSecondImageSave = function( imagearray ){ for ( var i = 0; i < imagearray.length; i++ ){ this.secondsaveimage[i] = imagearray[i]; } } //µÎ¹øÂ° Ãâ·Â ¾ÆÀ̵𰪠ÀúÀåÇϱâ ClickChangeImage.prototype.setSecondId = function( idarray ){ for ( var i = 0; i < idarray .length; i++ ){ this.secondsaveid[i] = idarray[i]; } } //µÎ¹øÂ° Ãâ·Â ±×·ì ÀúÀåÇϱâ ClickChangeImage.prototype.setSecondGroup = function( secondgrou ){ for ( var i = 0; i < secondgroup.length; i++ ){ this.secondgroup[i] = secondgrou[i]; } } //Á¿ì È­»ìÇ¥ ÀúÀå ClickChangeImage.prototype.setArrow = function( arrowarray ){ for ( var i = 0; i < arrowarray.length; i++ ){ this.savearray[i] = arrowarray[i]; } } //¹öư À̹ÌÁö ÀúÀå ClickChangeImage.prototype.setButton = function( buttonarray ){ for ( var i = 0; i < buttonarray.length; i++ ){ this.savebutton[i] = buttonarray[i]; } } //Radio¹öư ¼ºÁú ¾ÆÀ̵ð ÀúÀå ClickChangeImage.prototype.setRadioButton = function( radioarray ){ for ( var i = 0; i < radioarray.length; i++ ){ this.saveradiobutton[i] = radioarray[i]; } } //¹Ù²ð css ÀúÀå ClickChangeImage.prototype.setchangecss = function( cssname ){ this.changecssname = cssname; } //±âÁ¸ css ÀúÀå ClickChangeImage.prototype.setcurrentcss = function( cssname ){ this.currentcssname = cssname; } //µô·¹À̽ð£ ClickChangeImage.prototype.setTimeDelay = function( sec ){ this.timedelay = sec * 1000; } //Ãâ·Â °¹¼ö - »ç¿ëµÇÁö ¾ÊÀ½ ClickChangeImage.prototype.setPrintNum = function( num ){ this.printnum = num; } //ÇöÀç º¸¿©Áö°í ÀÖ´Â È­¸é ¹øÈ£ ClickChangeImage.prototype.setCurrentNumber = function( pagenum ){ this.currentviewnum = pagenum; } //on off ¹öư ±¸Çö -- ´Üµ¶ÀÏ ¶§´Â üũ¹Ú½º ¼ºÁú , setRadioButton ÇÔ¼ö°¡ ½ÇÇà µÇ¸é Radio¹öư ¼ºÁúÀ» °¡Áü ClickChangeImage.prototype.OnOffButton = function( obj ){ var b1 = new Array(); var b2 = new Array(); var bool = false; if( this.saveradiobutton.length > 0 ){ //Radio¹öư ¼ºÁúÀ» °®°Ô ÇÔ for(var j =0; j < this.saveradiobutton.length; j++){ if( obj.id != this.saveradiobutton[j] ) eval("document.getElementById('" + this.saveradiobutton[j] + "')").src = this.savebutton[1]; } } for ( var i = 0; i < 2; i++ ){ if( bool ) continue; b1 = obj.src.split("/"); b2 = this.savebutton[i].split("/"); if( b1[b1.length-1] != b2[b2.length-1] ){ obj.src = this.savebutton[i]; bool = true; } } } //È­¸é¿¡ Ãâ·Â Çϱâ ClickChangeImage.prototype.OutPut = function( viewnum ){ var a = this; var k=0; for( var i = 1; i <= Math.round(this.saveimage.length/this.saveid.length); i++ ){ k=0; for( var j = (i-1) * this.saveid.length ; j < i * this.saveid.length; j++ ){ if( eval("document.getElementById('" + this.saveid[k] + "')") && i == viewnum && this.saveimage[j] ){ eval("document.getElementById('" + this.saveid[k] + "')").innerHTML = this.saveimage[j]; }else if(eval("document.getElementById('" + this.saveid[k] + "')") && i == viewnum) { eval("document.getElementById('" + this.saveid[k] + "')").innerHTML = " "; } k++; } } } //È­¸é¿¡ Ãâ·Â Çϱâ ClickChangeImage.prototype.SecondOutPut = function( viewnum ){ var k=0; for( var i = 1; i <= Math.round(this.secondsaveimage.length/this.secondsaveid.length); i++ ){ k=0; for( var j = (i-1) * this.secondsaveid.length ; j < i * this.secondsaveid.length; j++ ){ if( eval("document.getElementById('" + this.secondsaveid[k] + "')") && i == viewnum && this.secondsaveimage[j] ){ eval("document.getElementById('" + this.secondsaveid[k] + "')").innerHTML = this.secondsaveimage[j]; }else if(eval("document.getElementById('" + this.secondsaveid[k] + "')") && i == viewnum) { eval("document.getElementById('" + this.secondsaveid[k] + "')").innerHTML = " "; } k++; } } } //autowordcssidx ÃʱâÈ­ Çϱâ ClickChangeImage.prototype.setInitAutowordcssidx = function(idx){ this.autowordcssidx = idx; } //¼øÂ÷ÀûÀ¸·Î CSS Àû¿ëÇϱâ ClickChangeImage.prototype.ApplyCss = function( viewnum ){ var a = this; var k=0; var k_group = 0; if( !viewnum ) viewnum = this.currentviewnum; for( var i = 1; i <= Math.round(this.saveimage.length/this.saveid.length); i++ ){ k=0; for( var j = (viewnum-1) * this.saveid.length ; j < i * this.saveid.length; j++ ){ if( eval("document.getElementById('" + this.saveid[k] + "')") && i == viewnum && j == this.autowordcssidx && this.saveimage[j] ){ if( this.changecssname ){ //eval("document.getElementById('" + this.saveid[k] + "')").setAttribute("className",this.changecssname); //IE ¿ë //eval("document.getElementById('" + this.saveid[k] + "')").setAttribute("class",this.changecssname); //Å©·Ò, »çÆÄ¸®, ÆÄÀÌ¾îÆø½º¿ë eval("document.getElementById('" + this.saveid[k] + "')").className = this.changecssname; //eval("document.getElementById('" + this.saveid[k] + "')").class = this.changecssname; //eval("document.getElementById('" + this.saveid[k] + "')").style.color="pink"; //eval("document.getElementById('" + this.saveid[k] + "')").style.fontWeight="bold"; } k_group = k+1; }else if(eval("document.getElementById('" + this.saveid[k] + "')") && i == viewnum ) { if( this.changecssname ){ //eval("document.getElementById('" + this.saveid[k] + "')").setAttribute("className",this.currentcssname); //eval("document.getElementById('" + this.saveid[k] + "')").setAttribute("class",this.currentcssname); eval("document.getElementById('" + this.saveid[k] + "')").className = this.currentcssname; //eval("document.getElementById('" + this.saveid[k] + "')").class = this.currentcssname; } } k++; } } //ÁöÁ¤µÈ ±×·ìÀÌ ÀÖ´Ù¸é if (this.secondgroup.length > 0) { if( k_group == 1 ) a.SecondOutPut( k_group ); else if( k_group > 1 ) { var t=0; for( var i=0; i < k_group-1; i++){ t += this.secondgroup[k_group-1]; } a.SecondOutPut( t + 1 ); } } this.autowordcssidx++; if( (this.autowordcssidx % this.saveid.length) == 0 ) this.autowordcssidx = (viewnum-1) * this.saveid.length; // ¸¶Áö¸·¿¡ µµ´ÞÇß´Ù¸é óÈìÀ¸·Î À̵¿ } //ÀÏÁ¤ ½Ã°£ÀÌ µÇ¸é CSS Àû¿ëÇϱâ ClickChangeImage.prototype.SetIntervalS = function(){ var a = this; this.settimeoutid = setInterval( function(){a.ApplyCss('');}, this.timedelay ); } //µÎ¹øÂ° Ãâ·Â ±×·ì ¾ÆÀ̵𿡠À̺¥Æ® ÁöÁ¤Çϱâ ClickChangeImage.prototype.SecondOutPutIdEvent = function(){ var a = this; //À̺¥Æ® ³Ö±â for( k=0; k < this.secondsaveid.length; k++ ){ if( eval("document.getElementById('" + this.secondsaveid[k] + "')") ){ eval("document.getElementById('" + this.secondsaveid[k] + "')").onmouseover = function(event){ clearInterval(a.settimeoutid); } /*eval("document.getElementById('" + this.secondsaveid[k] + "')").setAttribute( 'onmouseover', function () { clearInterval(a.settimeoutid); });*/ //eval("document.getElementById('" + this.secondsaveid[k] + "')").setAttribute( 'onmouseout', function () { eval("document.getElementById('" + this.secondsaveid[k] + "')").onmouseout = function(event){ a.SetIntervalS(); } //}); eval("document.getElementById('" + this.secondsaveid[k] + "')").style.cursor = "pointer"; } } } //È­»ìÇ¥ ¾ÆÀ̵𿡠À̺¥Æ® ÁöÁ¤Çϱâ ClickChangeImage.prototype.ArrowIdEvent = function(){ var a = this; //0 = ¿ÞÂÊ //1 = ¿À¸¥ÂÊ //À̺¥Æ® ³Ö±â for( k=0; k < this.savearray.length; k++ ){ if( eval("document.getElementById('" + this.savearray[k] + "')") ){ eval("document.getElementById('" + this.savearray[k] + "')").onmouseover = function(event){ clearInterval(a.settimeoutid); } //eval("document.getElementById('" + this.savearray[k] + "')").setAttribute( 'onmouseout', function () { eval("document.getElementById('" + this.savearray[k] + "')").onmouseout = function(event){ a.SetIntervalS(); } //}); eval("document.getElementById('" + this.savearray[k] + "')").style.cursor = "pointer"; switch( k ){ case 0 : // eval("document.getElementById('" + this.savearray[k] + "')").setAttribute( 'onclick', function () { eval("document.getElementById('" + this.savearray[k] + "')").onclick = function (event){ a.LayerLeftGo(); } // }); break; case 1 : // eval("document.getElementById('" + this.savearray[k] + "')").setAttribute( 'onclick', function () { eval("document.getElementById('" + this.savearray[k] + "')").onclick = function (event){ a.LayerRightGo(); } // }); break; } } } } //·¹ÀÌ¾î ¹èÄ¡Çϱâ ClickChangeImage.prototype.setLayerPosition = function(){ for(var i=0; i < this.secondsaveid.length; i++){ this.currentlayer[i] = eval("document.getElementById('" + this.secondsaveid[i] + "')").style.left = i * this.layermax[i]; } } //·¹À̾î Á·ΠÀ̵¿ ClickChangeImage.prototype.LayerLeftMove = function(){ var a = this; for(var i=0; i < this.secondsaveid.length; i++){ //if( i == this.secondsaveid.length - 1 ) continue; if( eval("document.getElementById('" + this.secondsaveid[i] + "')") ){ if( this.layercount[i] < this.layersize[i] ){ clearInterval(a.settimeoutid); this.currentlayer[i] += this.moveposition * -1; eval("document.getElementById('" + this.secondsaveid[i] + "')").style.left = this.currentlayer[i]+"px"; this.layercount[i]++; }else { clearInterval( this.layerid ); a.SetIntervalS(); } } } } ClickChangeImage.prototype.LayerLeftGo = function(){ var a = this; for(var i=0; i < this.secondsaveid.length; i++){ if( this.layercount[i] == this.layersize[i] ) this.layercount[i] = 0; } if( this.choicelayer < this.currentlayer.length -1 ) { this.choicelayer++; this.layerid = setInterval( function(){a.LayerLeftMove();}, this.layerspeed ); } } //·¹ÀÌ¾î ¿ì·Î À̵¿ ClickChangeImage.prototype.LayerRightMove = function(){ var a = this; for(var i=0; i < this.secondsaveid.length; i++){ //if( this.choicelayer == 0 ) continue; if( eval("document.getElementById('" + this.secondsaveid[i] + "')") ){ if( this.layercount[i] < this.layersize[i] ){ clearInterval(a.settimeoutid); this.currentlayer[i] += this.moveposition; eval("document.getElementById('" + this.secondsaveid[i] + "')").style.left = this.currentlayer[i]+"px"; this.layercount[i]++; }else { clearInterval( this.layerid ); a.SetIntervalS(); } } } } ClickChangeImage.prototype.LayerRightGo = function(){ var a = this; for(var i=0; i < this.secondsaveid.length; i++){ if( this.layercount[i] == this.layersize[i] ) this.layercount[i] = 0; } if( this.choicelayer > 0 ){ this.choicelayer--; this.layerid = setInterval( function(){a.LayerRightMove();}, this.layerspeed ); } } //·¹À̾î À̵¿ °¹¼ö ±¸Çϱâ ClickChangeImage.prototype.getLayerCount = function(){ for(var i=0; i < this.secondsaveid.length; i++){ if( eval("document.getElementById('" + this.secondsaveid[i] + "')") ){ // for ( var i = 0; i < this.savearray.length; i++ ){ // this.arrowsize += eval("document.getElementById('" + this.savearray[i] + "')").clientWidth; // } // var layermax = eval("document.getElementById('" + this.secondsaveid[0] + "')").clientWidth + this.arrowsize; // this.layersize = (eval("document.getElementById('" + this.secondsaveid[0] + "')").clientWidth + this.arrowsize) / this.moveposition; this.layermax[i] = eval("document.getElementById('" + this.secondsaveid[i] + "')").clientWidth; this.layersize[i] = eval("document.getElementById('" + this.secondsaveid[i] + "')").clientWidth / this.moveposition; if( eval("document.getElementById('" + this.secondsaveid[i] + "')").clientWidth % this.moveposition ) this.layersize[i]++; } this.layercount[i] = 0; } } //À̵¿ ±ÛÀÚ ½ÃÀÛ ClickChangeImage.prototype.StartCss = function( viewnum ){ var a = this; var idx = (viewnum-1) * this.saveid.length; a.setInitAutowordcssidx(idx); a.setTimeDelay(3); a.OutPut(viewnum); a.ApplyCss(viewnum); a.setCurrentNumber( viewnum ); a.SetIntervalS(); a.SecondOutPutIdEvent(); a.ArrowIdEvent(); a.getLayerCount(); a.setLayerPosition(); } ClickChangeImage.prototype.JustSlide = function( viewnum ){ var a = this; a.OutPut(viewnum); a.ApplyCss(viewnum); a.SecondOutPutIdEvent(); a.ArrowIdEvent(); a.getLayerCount(); a.setLayerPosition(); } ClickChangeImage.prototype.JustSlide2 = function( viewnum ){ var a = this; a.SecondOutPut(viewnum); a.SecondOutPutIdEvent(); a.ArrowIdEvent(); a.getLayerCount(); a.setLayerPosition(); }