

if(kw_amc_ad_display_flag == 'Y') {
//if("N" == 'Y') {
	if(kw_amc_product == 6) {		
		if(kw_amc_product_type == 2){
			kw_ad_url = "http://svc.wisenut.co.kr/shopPlusAd2.asp";
		}else if(kw_amc_product_type == 3){
			kw_ad_url = "http://svc.wisenut.co.kr/shopPlusAd3.asp";
		}else if(kw_amc_product_type == 4){
			kw_ad_url = "http://svc.wisenut.co.kr/shopPlusAd4.asp";
		}else{
			kw_ad_url = "http://svc.wisenut.co.kr/shopPlusAd.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;
		
		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 sec = new Date().getSeconds();
			var day = new Date().getDay();
	 
			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 += "&rand="+Math.floor(sec%10);
			if(window.kw_amc_outline){
					kw_ad_url += "&outline="+kw_amc_outline;
			}
			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;
}