/*
 * Prototypes
 */

function Colorshop() {}
var colorshop = new Colorshop();
Colorshop.prototype.setVariable = function (obj) {
    for (var i in obj) {
        this[i] = obj[i];
    }
}
Colorshop.prototype.createFlash = function (movie, w, h, ids, flashvars) {
    var strflash = '<object id="' + ids + '" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" height="' + h + '" width="' + w + '" align="middle" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000">';
    strflash += '<param name="_cx" value="25400">';
    strflash += '<param name="_cy" value="9260">';
    strflash += '<param name="flashvars" value="' + flashvars + '">';
    strflash += '<param name="movie" value="'+movie+'">';
    strflash += '<param name="src" value="'+movie+'">';
    strflash += '<param name="wmode" value="transparent">';
    strflash += '<param name="play" value="-1">';
    strflash += '<param name="loop" value="-1">';
    strflash += '<param name="quality" value="high">';
    strflash += '<param name="salign" value="">';
    strflash += '<param name="menu" value="-1">';
    strflash += '<param name="base" value="">';
    strflash += '<param name="allowscriptaccess" value="samedomain">';
    strflash += '<param name="scale" value="showall">';
    strflash += '<param name="devicefont" value="0">';
    strflash += '<param name="embedmovie" value="0">';
    strflash += '<param name="bgcolor" value="">';
    strflash += '<param name="swremote" value="">';
    strflash += '<param name="moviedata" value="">';
    strflash += '<param name="seamlesstabbing" value="1">';
    strflash += '<param name="profile" value="0">';
    strflash += '<param name="profileaddress" value="">';
    strflash += '<param name="profileport" value="0">';
    strflash += '<embed src="' + movie + '" quality="high" wmode="transparent" width="' + w+'" height="'+h+'" name="'+ids+'" align="middle" allowscriptaccess="samedomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
    strflash += '</object>';
    document.write(strflash);
}
Colorshop.prototype.bookmarksite = function(title,url) {
    if (window.sidebar) { // firefox
        window.sidebar.addPanel(title, url, "");
    } else if(window.opera && window.print)  { // opera
        var elem = document.createElement('a');
        elem.setAttribute('href',url);
        elem.setAttribute('title',title);
        elem.setAttribute('rel','sidebar');
        elem.click();
    } else if(document.all) {
        window.external.AddFavorite(url, title);
    }
}
Colorshop.prototype.popupCookie = function(code, expire) {
	var todayDate = new Date();
	todayDate.setDate(todayDate.getDate()+expire);
	var expireTime = todayDate.getTime();

	var cookieContents = colorshop.getCookie('popupInformation');
	if (!cookieContents) {
		var popupObject = {};
	} else {
		var popupObject = unserialize(cookieContents);
	}

	popupObject[code] = expireTime;
	var popupString = serialize(popupObject);
	colorshop.setCookie('popupInformation', popupString, 365);
}
Colorshop.prototype.getCookie = function(name) {
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1) {
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
	} else {
		begin += 2;
	}
	var end = document.cookie.indexOf(";", begin);
	if (end == -1) {
		end = dc.length;
	}

	return unescape(dc.substring(begin + prefix.length, end));
}
Colorshop.prototype.setCookie = function(name,value,expiredays) {
	var todayDate = new Date();
	todayDate.setDate(todayDate.getDate()+expiredays);
	document.cookie = name+"="+escape(value)+"; path=/; expires=" + todayDate.toGMTString() + ";";
}


// 상품 이미지 확대보기
Colorshop.prototype.zoom = function (ref, title, w, h) {
	var window_left = (screen.width-640)/2;
	var window_top = (screen.height-550)/2;
	zoom_popup=window.open(ref,title,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no, width=' + w + ',height=' + h + ',top=' + window_top + ',left=' + window_left + '');
	zoom_popup.focus();
}

Colorshop.prototype.addfavorite = function (href, title) {
    browserName = navigator.appName;
    browserVer = parseInt(navigator.appVersion);
    if (browserName == "Microsoft Internet Explorer" && browserVer >= 4) {
        window.external.AddFavorite(href, title);
    }
}

Colorshop.prototype.commPopupOpen = function (ret, name, w, h) {
    var window_left = (screen.width-750)/2;
    var window_top = (screen.height-850)/2;
    name = window.open(ret,name,'width=' + w + ', height=' + h + ', scrollbars=yes, resizable=no, status=no,top=' + window_top + ',left=' + window_left + '');
    name.focus();
}

Colorshop.prototype.writeQna = function (pid) {
//		alert(pid + ' 상품 게시판 오픈전입니다!');
/*
    var window_left = (screen.width-750)/2;
    var window_top = (screen.height-850)/2;
	var w = 600;
	var h = 300;
    name = window.open('/product/qna.php?pid='+pid,'상품문의','width=' + w + ', height=' + h + ', scrollbars=yes, resizable=no, status=no,top=' + window_top + ',left=' + window_left + '');
    name.focus();
*/
  callQnaDialog();
}
