 /******************************************************************************
 Copyright (c) 2007 Samsung Electronics. All Rights Reserved.
 Project: Samsung.com Site Renewal(2009.05~09)

 File Name : s3_util.js
 Description : SUPPORT3에서 사용하고자 하는 공통 JS

 Author : deuksoo.bang
 Since : 2009.08.04
 
 Modification Information
 Mod Date        Modifier         Description
 ----------      --------         ---------------------------
 2009.08.04      deuksoo.bang     create
******************************************************************************/

//set domain
document.domain = "samsung.com";

var S3Util = function(){}; 
var winCnt = 1;

/**
 * 팝업창
 */
S3Util.OpenWindow = function(url,intWidth,intHeight,resizeable,scrollbars,status,target,posX,posY)  {
	var defaultPosX = (screen.availWidth/2)-(intWidth/2);
	var defaultPosY = (screen.availHeight/2)-(intHeight/2);
	var winoption = "";
	
	if (resizeable) resizeable = 'yes'; else resizable = 'no';
	if (scrollbars) scrollbars = 'yes'; else scrollbars = 'no';	//no auto
	if (status) status = 'yes'; else status = 'no';
	
	if (!target) target = 'winPoP';
	if (!posX) posX = defaultPosX;
	if (!posY) posY = defaultPosY;
	
	winoption = "toolbar=no,location=no,directories=no,width="+intWidth;
	winoption = winoption + ",height="+intHeight+",left="+posX+",top="+posY;
	winoption = winoption + ",resizable="+resizeable+",scrollbars="+scrollbars;
	winoption = winoption + ",status=" + status;
	winoption = winoption + ",status=Internet Explorer 7.location=no";
	
	//alert(winoption);
	var win = window.open(url, target, winoption);
	
	//return win;
};

S3Util.PostWindow = function(theForm, url, intWidth, intHeight, resizeable,scrollbars,status, target) { 
	var posX = (screen.availWidth/2)-(intWidth/2);
	var posY = (screen.availHeight/2)-(intHeight/2);
	var winoption = "";
	
	if(resizeable) resizeable = 'yes'; else resizable = 'no';
	if(scrollbars) scrollbars = 'yes'; else scrollbars = 'no';
	if(status) status = 'yes'; else status = 'no';
	if(!target) target = 'postWindow_'+(winCnt++);
	
	winoption = "toolbar=no,location=no,directories=no,width="+intWidth;
	winoption = winoption + ",height="+intHeight+",left="+posX+",top="+posY;
	winoption = winoption + ",resizable="+resizeable+",scrollbars="+scrollbars;
	winoption = winoption + ",status=" + status;
	//alert(winoption);
	
	var win = window.open('about:blank', target, winoption);
	
	theForm.action = url;		
	theForm.target = target;
	theForm.submit();
	
	//return win;
};

/*
 * show only one div
 * - onload : call Layers.init()
 */
S3Util.Layers = {
	id: '#layout_backgroud',
	idx: 0,
	showGrps: new Array(),
	
	init: function() {
	
		var html = '<div id=\'layout_backgroud\'>&nbsp;</div>';
		var paramCss = {
						'display':'none',
						'position':'absolute',
						'left':'0',
						'top':'0',
						'background':'#03162e',
						'filter':'alpha(opacity=0)',
						'margin':'0 auto',
						'opacity':'0',
						'z-index':'10' };
		
		$('#header').after(html);
		$(this.id).css(paramCss)
				  .click(function() { S3Util.Layers.hide(); } );
	},
	
	setCss: function() {
		var w = $('body').attr('clientWidth');
		var h = $('body').attr('clientHeight');
		$(this.id).css({width:w,height:h});
		$(this.id).show();
	},
	
	show: function(s_id) {
		if(!$('div').is(this.id))
			return;
		this.showGrps[this.idx++] = s_id;
		this.setCss();
	},
	
	hide: function() {
		$(this.showGrps).each( function(idx,item) { $(item).hide();	});
		this.reset();
		$(this.id).hide();
	},
	
	reset: function() {
		this.idx = 0;
		this.showGrps.length = 0;
	}
};

/**
 * div를 display:block; 한다.
 * @param id	jquery selector
 */
S3Util.showLayer = function(id) {
	$(id).show();
	S3Util.Layers.show(id);	// show background
};

	
/**
 * div를 display:none; 한다.
 */
S3Util.hideLayer = function(id) {
	$(id).hide();
	S3Util.Layers.hide();	// hide background
};

S3Util.toConvertJavascript = function(str) {
	//str.replace(/\'/gi, '');
};

/**
 * 문자열 empty 체크
 */
S3Util.empty = function(str,defaultStr) {
	if(str == 'undefined' || str == null || str=='')
		return defaultStr;
	else
		return str;
};


/**
 * iframe Resizing
 * @param {Object} iframeObj	iframe Object
 */
S3Util.resizeFrame = function(iframeObj) {
    var innerBody = iframeObj.contentWindow.document.body;
    var innerHeight = innerBody.scrollHeight + (innerBody.offsetHeight - innerBody.clientHeight);
    var innerWidth = innerBody.scrollWidth + (innerBody.offsetWidth - innerBody.clientWidth);
	
	//default size
	//if(innerWidth<500) innerWidth = 500;
	
    iframeObj.style.height = innerHeight;
    iframeObj.style.width = innerWidth;     
}


/**
* ie6에서 png처리함수  :: javascript.js
*/
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 '';
}
