﻿//Created by Sangmin Shim, 02/19/2010, KR web) Wish list box notice, 013-4257

//쇼핑카트/////////////////////////////////////////////////////////////////////////////////////////////////
function fn_AddToBasket(valResponseText, imgURL, divID, brandType)
{
	var htmlBody;
	var product_name,price,type,basket_count;
	
	eval("var response = ( " + valResponseText + ")");

	for(var i = 0; i <response.length;i++){
		switch(response[i].title){
			case "type":
				type = response[i].value;
				break;
			case "product_name":
				product_name = response[i].value;
				break;
			case "price":
				price = response[i].value;
				break;
			case "basket_count":
				basket_count = response[i].value;
				break;
			default:
				break;
		}
	}
			
	htmlBody = "<table width='144' border='0' cellspacing='0' cellpadding='0'>";
	htmlBody += "<tr>";
	if(brandType != "tbt")
	{
	    htmlBody += "<td><img src='/images/ly_top.gif'></td>";
	}
	else
	{
	    htmlBody += "<td><img src='/images/ly_top_tbt.gif'></td>";
	}
	htmlBody += "</tr>";
	htmlBody += "<tr>";
	
	if(brandType != "tbt")
	{
	    htmlBody += "<td align='center' background='/images/ly_bg.gif'><table width='100%' border='0' cellspacing='0' cellpadding='6'>";
	}
	else
	{
	    htmlBody += "<td align='center' background='/images/ly_bg_tbt.gif'><table width='100%' border='0' cellspacing='0' cellpadding='6'>";
	}
    htmlBody += "<tr>";
    
    if (type=='add'){
	htmlBody += "<td width='63'><img src='" + imgURL + "' onError=\"this.src='/images/no_image.jpg'\" width='63' height='77' alt='' /></td>";
	htmlBody += "<td>" + product_name + "<br />" + MoneyPay(parseInt(price)) + "원</td>";
	} else if(type=='out'){
	htmlBody += "<td width='63'><img src='" + imgURL + "' onError=\"this.src='/images/no_image.jpg'\" width='63' height='77' alt='' /></td>";
	htmlBody += "<td>해당 상품이 품절되었습니다.</td>";
	}else if(type=='error'){
	htmlBody += "<td width='63'><img src='" + imgURL + "' onError=\"this.src='/images/no_image.jpg'\" width='63' height='77' alt='' /></td>";
	htmlBody += "<td>쇼핑카트 담기가 실패하였습니다.</td>";
	}else if(type=='basket'){
	htmlBody += "<td width='63'><img src='" + imgURL + "' onError=\"this.src='/images/no_image.jpg'\" width='63' height='77' alt='' /></td>";
	htmlBody += "<td>쇼핑카트에 상품이 너무 많습니다.</td>";
	}else if(type=='count'){
	htmlBody += "<td width='63'><img src='" + imgURL + "' onError=\"this.src='/images/no_image.jpg'\" width='63' height='77' alt='' /></td>";
	htmlBody += "<td>구매하신 물건의 수량이 부족합니다.</td>";
	}
	htmlBody += "</tr>";
	
	if (type=='add'){
	htmlBody += "<tr>";
	htmlBody += "<td colspan='2' align='center'>쇼핑카트에 담겼습니다";
	htmlBody += "</tr>";
	}
	
	htmlBody += "<tr>";
	htmlBody += "<td colspan='2' align='center'><a href='/product/basket.aspx'><img src='/images/btn_viewcart.gif' width='67' height='19' border='0'></a>&nbsp;";
	htmlBody += "&nbsp;<a href='javascript:win_close_QuickView(\""+ divID +"\");'><img src='/images/btn_cartclose.gif' width='47' height='19' border='0'></a></td>";
	htmlBody += "</tr>";
	htmlBody += "</table> </td>";
	htmlBody += "</tr>";
	htmlBody += "<tr>";
	if(brandType != "tbt")
	{
	    htmlBody += "<td><img src='/images/ly_btm.gif'></td>";
	}
	else
	{
	    htmlBody += "<td><img src='/images/ly_btm_tbt.gif'></td>";
	}
	htmlBody += "</tr>";
	htmlBody += "</table>";
	
	fn_showBasket(htmlBody, basket_count, divID);
}

//8/12/2010 sm.shim added jeans free cami
function fn_AddToFreeCami(valResponseText, imgURL, divID, brandType)
{
	var htmlBody;
	var product_name,price,type,basket_count;
	
	eval("var response = ( " + valResponseText + ")");

	for(var i = 0; i <response.length;i++){
		switch(response[i].title){
			case "type":
				type = response[i].value;
				break;
			case "product_name":
				product_name = response[i].value;
				break;
			case "price":
				price = response[i].value;
				break;
			case "basket_count":
				basket_count = response[i].value;
				break;
			default:
				break;
		}
	}
			
	htmlBody = "<table width='144' border='0' cellspacing='0' cellpadding='0'>";
	htmlBody += "<tr>";
	if(brandType != "tbt")
	{
	    htmlBody += "<td><img src='/images/ly_top.gif'></td>";
	}
	else
	{
	    htmlBody += "<td><img src='/images/ly_top_tbt.gif'></td>";
	}
	htmlBody += "</tr>";
	htmlBody += "<tr>";
	
	if(brandType != "tbt")
	{
	    htmlBody += "<td align='center' background='/images/ly_bg.gif'><table width='100%' border='0' cellspacing='0' cellpadding='6'>";
	}
	else
	{
	    htmlBody += "<td align='center' background='/images/ly_bg_tbt.gif'><table width='100%' border='0' cellspacing='0' cellpadding='6'>";
	}
    htmlBody += "<tr>";
    
    if (type=='add'){
	htmlBody += "<td width='63'><img src='" + imgURL + "' onError=\"this.src='/images/no_image.jpg'\" width='63' height='77' alt='' /></td>";
	htmlBody += "<td>" + product_name + "<br />" + MoneyPay(parseInt(0)) + "원</td>";
	} else if(type=='out'){
	htmlBody += "<td width='63'><img src='" + imgURL + "' onError=\"this.src='/images/no_image.jpg'\" width='63' height='77' alt='' /></td>";
	htmlBody += "<td>해당 상품이 품절되었습니다.</td>";
	}else if(type=='error'){
	htmlBody += "<td width='63'><img src='" + imgURL + "' onError=\"this.src='/images/no_image.jpg'\" width='63' height='77' alt='' /></td>";
	htmlBody += "<td>쇼핑카트 담기가 실패하였습니다.</td>";
	}else if(type=='basket'){
	htmlBody += "<td width='63'><img src='" + imgURL + "' onError=\"this.src='/images/no_image.jpg'\" width='63' height='77' alt='' /></td>";
	htmlBody += "<td>쇼핑카트에 상품이 너무 많습니다.</td>";
	}else if(type=='count'){
	htmlBody += "<td width='63'><img src='" + imgURL + "' onError=\"this.src='/images/no_image.jpg'\" width='63' height='77' alt='' /></td>";
	htmlBody += "<td>구매하신 물건의 수량이 부족합니다.</td>";
	}
	htmlBody += "</tr>";
	
	if (type=='add'){
	htmlBody += "<tr>";
	htmlBody += "<td colspan='2' align='center'>쇼핑카트에 담겼습니다";
	htmlBody += "</tr>";
	}
	
	htmlBody += "<tr>";
	htmlBody += "<td colspan='2' align='center'><a href='/product/basket.aspx'><img src='/images/btn_viewcart.gif' width='67' height='19' border='0'></a>&nbsp;";
	htmlBody += "&nbsp;<a href='javascript:win_close_QuickView(\""+ divID +"\");'><img src='/images/btn_cartclose.gif' width='47' height='19' border='0'></a></td>";
	htmlBody += "</tr>";
	htmlBody += "</table> </td>";
	htmlBody += "</tr>";
	htmlBody += "<tr>";
	if(brandType != "tbt")
	{
	    htmlBody += "<td><img src='/images/ly_btm.gif'></td>";
	}
	else
	{
	    htmlBody += "<td><img src='/images/ly_btm_tbt.gif'></td>";
	}
	htmlBody += "</tr>";
	htmlBody += "</table>";
	
	fn_showBasket(htmlBody, basket_count, divID);
}


function fn_showBasket(html,basket_count, divID)
{
    if(document.getElementById(divID))
    {
        document.getElementById(divID).style.left = "0px";
        document.getElementById(divID).innerHTML = html; 
        document.getElementById(divID).style.display = "block";   
        
        if(basket_count != undefined)
	    {
	        document.getElementById('ShoppingCartCnt').innerHTML = basket_count;
	    }
    }
    else if(parent.document.getElementById(divID))
    {
        parent.document.getElementById(divID).style.left = "0px";
        parent.document.getElementById(divID).innerHTML = html; 
        parent.document.getElementById(divID).style.display = "block";   
        
        if(basket_count != undefined)
	    {
	        parent.document.getElementById('ShoppingCartCnt').innerHTML = basket_count;
	    }
    }
    else if(parent.parent.document.getElementById(divID))
    {
        parent.parent.document.getElementById(divID).style.left = "0px";
        parent.parent.document.getElementById(divID).innerHTML = html; 
        parent.parent.document.getElementById(divID).style.display = "block";   
        
        if(basket_count != undefined)
	    {
	        parent.parent.document.getElementById('ShoppingCartCnt').innerHTML = basket_count;
	    }
    }
	
	opacity(divID,0,100,1000);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////

//위시리스트/////////////////////////////////////////////////////////////////////////////////////////////////
function fn_AddToWishList(valResponseText, imgURL, divID, brandType)
{
	var htmlBody;
	var product_name,price,type;
	
	eval("var response = ( " + valResponseText + ")");

	for(var i = 0; i <response.length;i++){
		switch(response[i].title){
			case "type":
				type = response[i].value;
				break;
			case "product_name":
				product_name = response[i].value;
				break;
			case "price":
				price = response[i].value;
				break;
			default:
				break;
		}
	}
			
	htmlBody = "<table width='144' border='0' cellspacing='0' cellpadding='0'>";
	htmlBody += "<tr>";
	if(brandType != "tbt")
	{
	    htmlBody += "<td><img src='/images/ly_top_wish.gif'></td>";
	}
	else
	{
	    htmlBody += "<td><img src='/images/ly_top_tbt_wish.gif'></td>";
	}
	htmlBody += "</tr>";
	htmlBody += "<tr>";
	
	if(brandType != "tbt")
	{
	    htmlBody += "<td align='center' background='/images/ly_bg.gif'><table width='100%' border='0' cellspacing='0' cellpadding='6'>";
	}
	else
	{
	    htmlBody += "<td align='center' background='/images/ly_bg_tbt.gif'><table width='100%' border='0' cellspacing='0' cellpadding='6'>";
	}
    htmlBody += "<tr>";
    
    if (type=='add'){
	htmlBody += "<td width='63'><img src='" + imgURL + "' onError=\"this.src='/images/no_image.jpg'\" width='63' height='77' alt='' /></td>";
	htmlBody += "<td>" + product_name + "<br />" + MoneyPay(parseInt(price)) + "원</td>";
	} else if(type=='out'){
	htmlBody += "<td width='63'><img src='" + imgURL + "' onError=\"this.src='/images/no_image.jpg'\" width='63' height='77' alt='' /></td>";
	htmlBody += "<td>해당 상품이 품절되었습니다.</td>";
	}else if(type=='error'){
	htmlBody += "<td width='63'><img src='" + imgURL + "' onError=\"this.src='/images/no_image.jpg'\" width='63' height='77' alt='' /></td>";
	htmlBody += "<td>위시리스트 담기가 실패하였습니다.</td>";
	}else if(type=='basket'){
	htmlBody += "<td width='63'><img src='" + imgURL + "' onError=\"this.src='/images/no_image.jpg'\" width='63' height='77' alt='' /></td>";
	htmlBody += "<td>위시리스트에 상품이 너무 많습니다.</td>";
	}else if(type=='count'){
	htmlBody += "<td width='63'><img src='" + imgURL + "' onError=\"this.src='/images/no_image.jpg'\" width='63' height='77' alt='' /></td>";
	htmlBody += "<td>구매하신 물건의 수량이 부족합니다.</td>";
	}
	htmlBody += "</tr>";
	
	if (type=='add'){
	htmlBody += "<tr>";
	htmlBody += "<td colspan='2' align='center'>위시리스트에 담겼습니다";
	htmlBody += "</tr>";
	}
	
	htmlBody += "<tr>";
	htmlBody += "<td colspan='2' align='center'><a href='/Mypage/WishList.aspx'><img src='/images/btn_viewwish.gif' width='67' height='19' border='0'></a>&nbsp;";
	htmlBody += "&nbsp;<a href='javascript:win_close_QuickView(\""+ divID +"\");'><img src='/images/btn_cartclose.gif' width='47' height='19' border='0'></a></td>";
	htmlBody += "</tr>";
	htmlBody += "</table> </td>";
	htmlBody += "</tr>";
	htmlBody += "<tr>";
	if(brandType != "tbt")
	{
	    htmlBody += "<td><img src='/images/ly_btm.gif'></td>";
	}
	else
	{
	    htmlBody += "<td><img src='/images/ly_btm_tbt.gif'></td>";
	}
	htmlBody += "</tr>";
	htmlBody += "</table>";
	
	fn_showWishList(htmlBody, divID, brandType);
}


function fn_showWishList(html, divID, brandType)
{
    var wishleft = "76px";
    
    if(brandType == "tbt")
    {
        wishleft = "70";
    }
    
	if(document.getElementById(divID))
    {
        document.getElementById(divID).style.left = wishleft;
        document.getElementById(divID).innerHTML = html; 
        document.getElementById(divID).style.display = "block";   
    }
    else if(parent.document.getElementById(divID))
    {
        parent.document.getElementById(divID).style.left = wishleft;
        parent.document.getElementById(divID).innerHTML = html; 
        parent.document.getElementById(divID).style.display = "block";   
    }
    else if(parent.parent.document.getElementById(divID))
    {
        parent.parent.document.getElementById(divID).style.left = wishleft;
        parent.parent.document.getElementById(divID).innerHTML = html; 
        parent.parent.document.getElementById(divID).style.display = "block";   
    }
	
	opacity(divID,0,100,1000);
}
/////////////////////////////////////////////////////////////////////////////////////////////////

//기본함수///////////////////////////////////////////////
function getXMLHttpRequest()
{
	if(window.ActiveXObject)
	{
		try{
			return new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				return new ActiveXObject("Microsoft.XMLHTTP"); 
			}
			catch(e1)
			{
				return null;
			}
	
		}
	}
	else if (window.XMLHttpRequest)
	{
		return new XMLHttpRequest();
	}
	else
	{
		return null;
	}
}


function OpacityInit(divID)
{
    //'showBasket'
	opacity(divID,100,0,10);
}

function opacity(id, opacStart, opacEnd, millisec)
{
	var speed = Math.round(millisec / 100);
	var op_timer = 0;

	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(op_timer * speed));
			op_timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)
			{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(op_timer * speed));
			op_timer++;
		}
	}
}

function changeOpac(opacity, id)
{
    var object;
	if(document.getElementById(id))
	{
	    object = document.getElementById(id).style;
	    object.opacity = (opacity / 100);
	    object.MozOpacity = (opacity / 100);
	    object.KhtmlOpacity = (opacity / 100);
	    object.filter = "alpha(opacity=" + opacity + ")";
	}
	else if(parent.document.getElementById(id))
	{
	    object = parent.document.getElementById(id).style;
	    object.opacity = (opacity / 100);
	    object.MozOpacity = (opacity / 100);
	    object.KhtmlOpacity = (opacity / 100);
	    object.filter = "alpha(opacity=" + opacity + ")";
	}
	else if(parent.parent.document.getElementById(id))
	{
	    object = parent.parent.document.getElementById(id).style;
	    object.opacity = (opacity / 100);
	    object.MozOpacity = (opacity / 100);
	    object.KhtmlOpacity = (opacity / 100);
	    object.filter = "alpha(opacity=" + opacity + ")";
	}
	
	
}


function win_close_QuickView(divID)
{
    //showBasket
	if(document.getElementById(divID))
	{
	    opacity(divID,100,0,1000);
	    document.getElementById(divID).style.display = "none";    
	}
}
