if(kw_amc_ad_display_flag == 'Y') {
	//if("N" == 'Y') {
	//if((kw_amc_site == 1015 || kw_amc_site == 1044 )) {
	if(kw_amc_product == 6) {		
		if(kw_amc_product_type == 2){
			kw_ad_url = "http://svc.wisenut.co.kr/shopPlusAd2_utf8.asp";
		}else if(kw_amc_product_type == 3){
			kw_ad_url = "http://svc.wisenut.co.kr/shopPlusAd3_utf8.asp";
		}else if(kw_amc_product_type == 4){
			kw_ad_url = "http://svc.wisenut.co.kr/shopPlusAd4_utf8.asp";
		}else{
			kw_ad_url = "http://svc.wisenut.co.kr/shopPlusAd_utf8.asp";
		}
		
		kw_ad_url += "?scode="+kw_amc_site;
		kw_ad_url += "&pcode="+kw_amc_product;
		kw_ad_url += "&ptype="+kw_amc_product_type;	
		if( typeof(kw_amc_max_cnt) == 'number') {
			kw_ad_url += "&maxCnt="+kw_amc_max_cnt;
		}
		kw_ad_url += "&categoryId="+kw_amc_category_id;
		kw_ad_url += "&adult="+kw_amc_adult_flag;
		kw_ad_url += "&charset="+kw_amc_client_encoding;
		if(window.kw_amc_content_url){
			kw_ad_url += "&contentUrl=" + encodeURL(kw_amc_content_url);
		}	
		kw_ad_url += "&ad_width="+kw_amc_width;
		kw_ad_url += "&ad_height="+kw_amc_height;
		
		if(window.kw_amc_header){
			kw_ad_url += "&header="+kw_amc_header;
		}
		if(window.kw_amc_text_type){
			kw_ad_url += "&textType="+kw_amc_text_type;
		}
		if(window.kw_amc_line_color){
			kw_ad_url += "&lineColor="+kw_amc_line_color;
		}


		var svcUrl="<iframe id='adSvcIframe' name='adSvcIframe'  src=\""+kw_ad_url+"\"";
		svcUrl += " width="+kw_amc_width;
		svcUrl += " height="+kw_amc_height;
		svcUrl += " frameborder='0' scrolling='no' allowtransparency='true'></iframe>"; 
		document.write(svcUrl);

	} else {
		var today = new Date(Date.parse(new Date()) - 10* 1000*60);
		var hour = today.getHours();
		var sec = today.getSeconds();
		var day = today.getDate();

/*
		var ranNum = Math.floor(Math.random() * 10);
		if (ranNum < 2 && ((kw_amc_site == 1072 && kw_amc_product == 4) || (kw_amc_product == 4 && kw_amc_width == 250 && kw_amc_height == 250)) && kw_amc_site != 999) {
			kw_amc_width = 250;
			kw_amc_height = 250;
			var iframeStr = "<iframe src='http://adsvc2.wisenut.co.kr/amc/amc_svc_27.php?";
			iframeStr += "scode=" + kw_amc_site;
			if (window.kw_amc_width)
				iframeStr += "&width=" + kw_amc_width;
			if (window.kw_amc_height)
				iframeStr += "&height=" + kw_amc_height;
			if (window.kw_amc_category_id)
				iframeStr += "&cate=" + kw_amc_category_id;
			if (window.wiseType)
				iframeStr += "&type=" + wiseType;
			iframeStr += "' width=250 height=250 frameborder=0 scrolling=no></iframe>";
			document.write(iframeStr);
		} else {
*/		
			//if( kw_amc_product == 4 && (kw_amc_site == 29  || kw_amc_site == 6 || kw_amc_site == 1015)){
			//if( kw_amc_product == 4 && (kw_amc_site == 1015 || kw_amc_site == 58 || kw_amc_site == 1032)){
			//	kw_ad_url = "http://adsvc.wisenut.co.kr/amc/amc_svc_"+kw_amc_product+"_test.asp";
			//}else if(kw_amc_product == "mix" && (kw_amc_site == 6) ){
			//	kw_ad_url = "http://adsvc.wisenut.co.kr/amc/amc_svc_"+kw_amc_product+"_test.asp";			
			//}else{
			//kw_ad_url = "http://adsvc.wisenut.co.kr/amc/amc_svc_"+kw_amc_product+".asp";
			//}
			
			var ranNum = Math.floor(Math.random() * 5);
		
			if (ranNum == 0 && kw_amc_product == "4") {
				var adUrl = "scode=" + kw_amc_site;
				adUrl += "&ptype=" + kw_amc_product_type + "&ad_width=" + kw_amc_width + "&ad_height=" + kw_amc_height;
				adUrl += "&adult=" + kw_amc_adult_flag;
				adUrl += "&charset=" + kw_amc_client_encoding;
				if (window.wiseOutline)
					adUrl += "&outline=" + kw_amc_outline;
				if (window.wiseHeadline)
					adUrl += "&headline=" + kw_amc_headline;
				if (window.wiseFlag)
					adUrl += "&flag=" + kw_amc_flag;
				if (window.wiseSmax)
					adUrl += "&smax=" + kw_amc_max_cnt;
				if (window.wiseBgColor)
					adUrl += "&bgcolor=" + wiseBgColor;
				var iframeStr = "<iframe src='http://adsvc2.wisenut.co.kr/amc/amc_svc_30.php?" + adUrl;
				iframeStr += "' width=" + kw_amc_width + " height=" + kw_amc_height + " frameborder=0 scrolling=no></iframe>";
				document.write(iframeStr);
			} else {
				kw_ad_url = "http://adsvc.wisenut.co.kr/amc/amc_svc_"+kw_amc_product+".asp";
				
				kw_ad_url += "?scode="+kw_amc_site;
				kw_ad_url += "&pcode="+kw_amc_product;
				kw_ad_url += "&ptype="+kw_amc_product_type;
				kw_ad_url += "&adult="+kw_amc_adult_flag;
				kw_ad_url += "&charset="+kw_amc_client_encoding;
				kw_ad_url += "&day="+day;
				kw_ad_url += "&hour="+hour;
				kw_ad_url += "&rand="+Math.floor(sec%3);
				if(window.kw_amc_outline){
						kw_ad_url += "&outline="+kw_amc_outline;
				}
				if(window.kw_amc_headline){
						kw_ad_url += "&headline="+kw_amc_headline;
				}
				if(window.kw_amc_flag){
						kw_ad_url += "&flag="+kw_amc_flag;
				}
				if(window.kw_amc_max_cnt) {
					kw_ad_url += "&smax="+kw_amc_max_cnt;
				}	
		 
				kw_ad_url += "&ad_width="+kw_amc_width;
				kw_ad_url += "&ad_height="+kw_amc_height;
				/*
				if( typeof(kw_amc_wsn_width) == 'number') {
						kw_ad_url += "&ad_width="+kw_amc_wsn_width;
				}
				if( typeof(kw_amc_wsn_height) == 'number') {
						kw_ad_url += "&ad_height="+kw_amc_wsn_height;
				}
				*/
				
				var svcUrl="<iframe id='adSvcIframe' name='adSvcIframe'  src=\""+kw_ad_url+"\"";
				svcUrl += " width="+kw_amc_width;
				svcUrl += " height="+kw_amc_height;
				svcUrl += " frameborder='0' scrolling='no' allowtransparency='true'></iframe>";
				document.write(svcUrl);
			}
//		}
	}
//	}
}

function encodeURL(str){
	var s0, i, s, u;
	s0 = "";                // encoded str
	for (i = 0; i < str.length; i++){   // scan the source
		s = str.charAt(i);
		u = str.charCodeAt(i);          // get unicode of the char
		if (s == " "){s0 += "+";}       // SP should be converted to "+"
		else {
			if ( u == 0x2a || u == 0x2d || u == 0x2e || u == 0x5f || ((u >= 0x30) && (u <= 0x39)) || ((u >= 0x41) && (u <= 0x5a)) || ((u >= 0x61) && (u <= 0x7a))){       // check for escape
				s0 = s0 + s;            // don't escape
			}
			else {                  // escape
				if ((u >= 0x0) && (u <= 0x7f)){     // single byte format
					s = "0"+u.toString(16);
					s0 += "%"+ s.substr(s.length-2);
				}
				else if (u > 0x1fffff){     // quaternary byte format (extended)
					s0 += "%" + (oxf0 + ((u & 0x1c0000) >> 18)).toString(16);
					s0 += "%" + (0x80 + ((u & 0x3f000) >> 12)).toString(16);
					s0 += "%" + (0x80 + ((u & 0xfc0) >> 6)).toString(16);
					s0 += "%" + (0x80 + (u & 0x3f)).toString(16);
				}
				else if (u > 0x7ff){        // triple byte format
					s0 += "%" + (0xe0 + ((u & 0xf000) >> 12)).toString(16);
					s0 += "%" + (0x80 + ((u & 0xfc0) >> 6)).toString(16);
					s0 += "%" + (0x80 + (u & 0x3f)).toString(16);
				}
				else {                      // double byte format
					s0 += "%" + (0xc0 + ((u & 0x7c0) >> 6)).toString(16);
					s0 += "%" + (0x80 + (u & 0x3f)).toString(16);
				}
			}
		}
	}
	return s0;
}

