	
var _indexTitle = "UNIVERSAL", _currentTitle = "";
var addressLocation = "";


function setTitle(type, interval, title){
	if (type == "set"){
		var _title = ($.trim(title) != "") ?
			((($.trim(title)).indexOf("#") === -1) ?	$.trim(title) : _indexTitle) : _indexTitle;
			_currentTitle = _title;
		$.address.title(_title);
	}else if (type == "get"){
		window.setTimeout(function(){
			var _title = (_currentTitle && _currentTitle.indexOf("#") === -1) ? _currentTitle : _indexTitle;
			$.address.title(_title);
		}, parseInt(interval));
	}
}

function resizeFn(h){
  	var iFrame = ('#ifrPlayerPage');
			
		$(iFrame).css("height", h+ 'px');			
}

function displayMainFrm(_url){
    
    // 스토어 링크일 경우 스토어로 이동 
    if(_url.indexOf('store.universalmusic.co.kr') != -1){
        document.location.href =_url;
        return;
    }
    
	setTitle("get", 100); //title = # 방지
		
	var __url = "";

	if ( _url.indexOf(location.protocol + "//" + location.hostname) === 0 )
		__url = _url.substr((location.protocol + "//" + location.hostname).length).replace(/^#/, '');
	else
		__url = _url.replace(/^#/, '');
		
	$.address.value($.trim(__url));
}

	
$(document).ready(function(){
	
	_indexTitle = _currentTitle = $.trim(document.title);

	$.address.init(function(event){
			
		}).change(function(event){		
		
		//기본 경로 셋팅		
		addressLocation = $.address.value().replace(/^#/, '');
		
		if ((addressLocation == "/" && $.address.path() == "/") || addressLocation == "")
			addressLocation = "";
		
				
		if (addressLocation == "")
			addressLocation = "/home/homeMain";

		_urlMainFrm = $.trim(addressLocation);
		
		
		var _loadMainFrm = function(){
			$("iframe").remove("#ifrPlayerPage");
			
			var _scrolling = "no";
			var iFrame = document.createElement('iframe');
			$(iFrame).attr("frameBorder", "0").attr("scrolling", _scrolling).css("width","100%").css("height","600px")
				.prependTo("#content").attr("name", "ifrPlayerPage").attr("id", "ifrPlayerPage")
				

.load(function(){
				this.style.height = this.contentWindow.document.body.offsetHeight + 'px';
				top.layerClose();
			}).attr("src", _urlMainFrm);
						
			return false;
		};

		_loadMainFrm();
	});
	
});


