// È­¸éÁß¾Ó¿¡¼­ Ã¢¿­±â
var win= null;
function nwindow(page,name,w,h,scroll,resize){
  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/3;
  var settings  ='height='+h+',';
      settings +='width='+w+',';
      settings +='top='+wint+',';
      settings +='left='+winl+',';
      settings +='scrollbars='+scroll+',';
      settings +='resizable='+resize+',';
      settings +='status=no';
  win=window.open(page,name,settings);
  if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
}

//¼ýÀÚ¸¸ÀÔ·Â
function num_only(){
  if((event.keyCode<48) || (event.keyCode>57)){
    event.returnValue=false;
  }
}
//¼ýÀÚ¸¸Ã¼Å©
function isNum(num) {
	for(var i=0; i < num.length;i++){
    achar=num.substring(i,i+1);
      if( achar < "0" || achar > "9") {
        return false;
      }
	return true;
  }
}
//°ø¹éÁ¦°Å
function Trim(string) {
    for(;string.indexOf(" ")!= -1;){
        string=string.replace(" ","")
    }
    return string;
}

//ÀÔ·Â°Ë»ç
function Exists(input,types) {
    if(types) if(!Trim(input.value)) return false;
    return true;
}
//¹ÙÀÌÆ®°Ë»ç
function Byte(input) {
    var i, j=0;
    for(i=0;i<input.length;i++) {
        val=escape(input.charAt(i)).length;
        if(val==  6) j++;
        j++;
    }
    return j;
}

// ºñ¹Ð¹øÈ£ Ã¼Å©
function check_passwd(input, input2, min) {
    if(!input.value) {
        alert('ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇØ ÁÖ½Ê½Ã¿À.');
        input.focus();
        return false;
    }
    else if(BYTE(input.value) < min) {
        alert('ºñ¹Ð¹øÈ£ÀÇ ±æÀÌ°¡ ³Ê¹« Âª½À´Ï´Ù.');
        input.focus();
        input.value='';
        input2.value='';
        return false;
    }
    else if(!input2.value) {
        alert('È®ÀÎºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇØ ÁÖ½Ê½Ã¿À.');
        input2.focus();
        return false;
    }
    else if(input.value != input2.value) {
        alert('ºñ¹Ð¹øÈ£°¡ ¼­·Î ´Ù¸£°Ô ÀÔ·ÂµÇ¾ú½À´Ï´Ù.');
        input2.value='';
        input2.focus();
        return false;
    }
    else return true;
}

//ÀÌ¹ÌÁö ½½¶óÀÌµå Çü½ÄÀ¸·Î º¸¿©ÁÖ±â
var _dropinslideshowcount=0

function dropinslideshow(imgarray, w, h, delay){
    this.id="_dropslide"+(++_dropinslideshowcount) //Generate unique ID for this slideshow instance (automated)
    this.createcontainer(parseInt(w), parseInt(h))
    this.delay=delay
    this.imgarray=imgarray
    var preloadimages=[]
    for (var i=0; i<imgarray.length; i++){
        preloadimages[i]=new Image()
        preloadimages[i].src=imgarray[i][0]
    }
    this.animatestartpos=parseInt(h)*(-1) //Starting "top" position of an image before it drops in
    this.slidedegree=10 //Slide degree (> is faster)
    this.slidedelay=30 //Delay between slide animation (< is faster)
    this.activecanvasindex=0 //Current "active" canvas- Two canvas DIVs in total
    this.curimageindex=0
    this.zindex=100
    this.isMouseover=0
    this.init()
}


dropinslideshow.prototype.createcontainer=function(w, h){
document.write('<div id="'+this.id+'" style="position:relative; width:'+w+'px; height:'+h+'px; overflow:hidden">')
    document.write('<div style="position:absolute; width:'+w+'px; height:'+h+'px; top:0;"></div>')
    document.write('<div style="position:absolute; width:'+w+'px; height:'+h+'px; top:-'+h+'px;"></div>')
    document.write('</div>')
    this.slideshowref=document.getElementById(this.id)
    this.canvases=[]
    this.canvases[0]=this.slideshowref.childNodes[0]
    this.canvases[1]=this.slideshowref.childNodes[1]
}

dropinslideshow.prototype.populatecanvas=function(canvas, imageindex){
    var imageHTML='<img src="'+this.imgarray[imageindex][0]+'" style="border: 0" />'
    if (this.imgarray[imageindex][1]!="")
        imageHTML='<a href="'+this.imgarray[imageindex][1]+'" target="'+this.imgarray[imageindex][2]+'">'+imageHTML+'</a>'
    canvas.innerHTML=imageHTML
}


dropinslideshow.prototype.animateslide=function(){
    if (this.curimagepos<0){ //if image hasn't fully dropped in yet
        this.curimagepos=this.curimagepos+this.slidedegree
        this.activecanvas.style.top=this.curimagepos+"px"
    }
    else{
        clearInterval(this.animatetimer)
        this.activecanvas.style.top=0
        this.setupnextslide()
        var slideshow=this
        setTimeout(function(){slideshow.rotateslide()}, this.delay)
    }
}


dropinslideshow.prototype.setupnextslide=function(){
    this.activecanvasindex=(this.activecanvasindex==0)? 1 : 0
    this.activecanvas=this.canvases[this.activecanvasindex]
    this.activecanvas.style.top=this.animatestartpos+"px"
    this.curimagepos=this.animatestartpos
    this.activecanvas.style.zIndex=(++this.zindex)
    this.curimageindex=(this.curimageindex<this.imgarray.length-1)? this.curimageindex+1 : 0
    this.populatecanvas(this.activecanvas, this.curimageindex)
}

dropinslideshow.prototype.rotateslide=function(){
    var slideshow=this
    if (this.isMouseover)
        setTimeout(function(){slideshow.rotateslide()}, 50)
    else
        this.animatetimer=setInterval(function(){slideshow.animateslide()}, this.slidedelay)
}

dropinslideshow.prototype.init=function(){
    var slideshow=this
    this.populatecanvas(this.canvases[this.activecanvasindex], 0)
    this.setupnextslide()
    this.slideshowref.onmouseover=function(){slideshow.isMouseover=1}
    this.slideshowref.onmouseout=function(){slideshow.isMouseover=0}
    setTimeout(function(){slideshow.rotateslide()}, this.delay)
}


function Zipcode1(){
  nwindow('index_zip.php?form=order_in&address=saddr', 'zipcode', '480' , '200' ,'yes','yes');
}
function Zipcode2(){
  nwindow('index_zip.php?form=order_in&address=eaddr', 'zipcode', '480' , '200' ,'yes','yes');
}

function checkit() {
var f=document.jform;
 if(!f.curname.value) {
    alert('¼º¸íÀ» ÀÔ·ÂÇÏ¼Å¾ßÇÕ´Ï´Ù.!');
    f.curname.focus();
    return;
    }
 if(!f.jumin2.value) {
    alert('ÁÖ¹Îµî·Ï¹øÈ£µÞÀÚ¸®¸¦ ÀÔ·ÂÇÏ¼Å¾ßÇÕ´Ï´Ù.!');
    f.jumin2.focus();
    return;
    }
	 f.submit();
}

function sendit(){
  var f=document.order_in;
  if(!f.cname.value || f.cname.value.length < 3){
    alert('°í°´¸íÀ» ÀÔ·Â ÇÏ¼Å¾ß ÇÕ´Ï´Ù.');
    f.cname.focus();
    return;
  }
  if(!f.hp1.value || f.hp1.value.length < 2){
    alert('ÈÞ´ëÆù ¹øÈ£¸¦ Á¤È®ÇÏ°Ô ÀÔ·Â ÇÏ¼Å¾ß ÇÕ´Ï´Ù.');
    f.hp1.focus();
    return;
  }
  if(!f.hp2.value || f.hp2.value.length < 3 || f.hp2.value.length > 4){
    alert('ÈÞ´ëÆù ¹øÈ£¸¦ Á¤È®ÇÏ°Ô ÀÔ·Â ÇÏ¼Å¾ß ÇÕ´Ï´Ù.');
    f.hp2.focus();
    return;
  }
  if(!f.hp3.value || f.hp3.value.length < 3 || f.hp3.value.length > 4){
    alert('ÈÞ´ëÆù ¹øÈ£¸¦ Á¤È®ÇÏ°Ô ÀÔ·Â ÇÏ¼Å¾ß ÇÕ´Ï´Ù.');
    f.hp3.focus();
    return;
  }
  if(!f.saddr.value || f.saddr.value.length < 7){
    alert('Ãâ¹ßÁö¸¦ ÀÔ·Â ÇÏ¼Å¾ß ÇÕ´Ï´Ù.');
    f.saddr.focus();
    return;
  }
  if(!f.eaddr.value || f.eaddr.value.length < 7){
    alert('µµÂøÁö¸¦ ÀÔ·Â ÇÏ¼Å¾ß ÇÕ´Ï´Ù.');
    f.eaddr.focus();
    return;
  }
  f.submit();
}
