﻿// JavaScript Document
function DD_showHideLayers() { //v9.0
  var i,p,v,obj,args=DD_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.display) { obj=obj.style; v=(v=='show')?'':(v=='hide')?'none':v; }
    obj.display=v; }
}

function bluring(){ 
if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG") 

document.body.focus(); 
} 
document.onfocusin=bluring; 

function setPng24(obj) {
  obj.width=obj.height=1;
  obj.className=obj.className.replace(/\bpng24\b/i,'');
  obj.style.filter =
  "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');";
  obj.src=''; 
  return '';
}

function flash(url,w,h,bg,win,vars,base){
	var s=
	"<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='"+w+"' height='"+h+"' align='middle'>"+
	"<param name='allowScriptAccess' value='always' />"+
	"<param name='movie' value='"+url+"' />"+
	"<param name='wmode' value='"+win+"' />"+
	"<param name='menu' value='false' />"+
	"<param name='quality' value='high' />"+
	"<param name='FlashVars' value='"+vars+"' />"+
	"<param name='bgcolor' value='"+bg+"' />"+
	"<param name='base' value='"+base+"' />"+
	"<embed src='"+url+"' base='"+base+"' wmode='"+win+"' menu='false' quality='high' bgcolor='"+bg+"' width='"+w+"' height='"+h+"' align='middle' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />"+
	"</object>";
	document.write(s);
}
 
function make_swf(swf_url,swf_width,swf_height,swf_wmode,swf_flashvars){
  document.write("<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.c-ab#version=8,0,0,0\" width=\""+swf_width+"\" height=\""+swf_height+"\" id=\"external_flash\">");
        document.write("<param name=\"movie\" value=\""+swf_url+"\">");
        document.write("<param name=\"quality\" value=\"high\">");
        document.write("<param name=\"menu\" value=\"false\">");
 document.write("<param name=\"allowScriptAccess\" value=\"always\">");
   if(swf_flashvars!=""){
        document.write("<param name=\"flashVars\" value=\""+swf_flashvars+"\">");
   }
   if(swf_wmode!=""){
   document.write("<param name=\"wmode\" value=\""+swf_wmode+"\">");
   }
  document.write("<embed src=\""+swf_url+"\" quality=\"high\" pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" width=\""+swf_width+"\" height=\""+swf_height+"\" allowScriptAccess=\"always\" swLiveConnect=\"true\" name=\"external_flash\"></embed>");
  document.write("</object>");

}

function addCommas(strValue){ 
var objRegExp = new RegExp('(-?[0-9]+)([0-9]{3})'); 
  while(objRegExp.test(strValue)) { 
  strValue = strValue.replace(objRegExp, '$1,$2'); 
  } 
return strValue; 
} 
 
 $(function() {
//		var id = $("#id");
		var address = $("#address");
//		var idcheck = $("#idcheck");
//		var company = $("#company");
//		var no = $("#no");
//
		function checkLength(o,n,min,max) {
			if ( o.val().length > max || o.val().length < min ) {
				alert(n+" "+min+"자 이상 "+max+"자 이하로 입력해 주세요.");
				$(o).focus();
				return false;
			} else {
				return true;
			}

		}
//
//		$('#search').click(function() {
//
//			 $.ajax({
//			   type: "POST",
//			   url: "php/msearch.php",
//			   data: "area="+$("#area :selected").val()+"&part="+$("#part :selected").val()+"&company="+company.val(),
//			   success: function(html){
//				   //$("#list").val()="";
//				   $("#list").html(html);
//			   }
//			 });
//
//		});
//
//		$('#checkid').click(function() {
//			if(checkLength(id,"아이디는",4,16)){
//			idcheck.val(1);
//			 $.ajax({
//			   type: "POST",
//			   url: "php/checkid.php",
//			   data: "id="+id.val(),
//			   success: function(msg){
//				 alert( msg );
//			   }
//			 });
//			}
//		});
//		
		$('#zipsearch').click(function() {
			if(checkLength(address,'검색하실 내용을',2,16)){
			 $.ajax({
			   type: "POST",
			   url: "../zipcode/exec.php",
			   data: "address="+address.val(),
			   success: function(html){
				   $("#results").html(html);
			   }
			 });
			}
		});
//		
});

function getCookie(NameCookie)
{
	var i = document.cookie.indexOf(NameCookie + '=' );
	if (i != -1) {
		i += NameCookie.length + 1;
		NameEnd = document.cookie.indexOf(';', i);
		if (NameEnd == -1){
			NameEnd = document.cookie.length;
		}
		return  unescape(document.cookie.substring(i, NameEnd));
	} else {
		return "";
	}
}

function setCookie( name, value, expiredays )
{
	var todayDate = new Date();
	todayDate.setDate( todayDate.getDate() + expiredays );
	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}// Comma separated list of images to rotate
var imgs = new Array('/img/kr/img/img1.jpg','/img/kr/img/img2.jpg','/img/kr/img/img3.jpg','/img/kr/img/img4.jpg','/img/kr/img/img5.jpg','/img/kr/img/img6.jpg','/img/kr/img/img7.jpg');
// delay in milliseconds between image swaps 1000 = 1 second
var delay = 4000;
var counter = 0;

function preloadImgs(){
  for(var i=0;i<imgs.length;i++){
    MM_preloadImages(imgs[i]);
  }
}

function randomImages(){
  if(counter == (imgs.length)){
    counter = 0;
  }
  MM_swapImage('rotator', '', imgs[counter++]);
  setTimeout('randomImages()', delay);
}
