﻿$(document).ready( function init() {
	openMplayer();
});
var mpwidth =240;
var mpheight=350;

var topX = window.screen.width-mpwidth;
var topY = window.screen.height-mpheight;

var u = this.location.href;
var URLSTR = '/musicPlayer/MusicPlayer.jspx';
if(u.indexOf("https") > -1)
  URLSTR = '/common/musicPlayer/MusicPlayer.jspx';

var newWindow;
var userAgent = navigator.userAgent.toLowerCase();


function openMplayer(){
	if(userAgent.indexOf('firefox')>0){
		
		mpwidth =240;
		mpheight=350;
	//	alert(mpwidth+','+mpheight);
	}else if(userAgent.indexOf('msie 7.0')>0){
	//	alert(userAgent);
		mpwidth =240;
		mpheight=350;
		
	}else{
		mpwidth =240;
		mpheight=350;
		
	}
	
	if ((isOpenMPlayer=='null')){
		openNewMplayer();
	} 
}

function openNewMplayer(){
    var str =window.open(URLSTR+"?doFunction=first","mPlayer","height="+mpheight+",width="+mpwidth+",channelmode=0, directories=0, fullscreen=0,location=0, menubar=0, resizable=0, scrollbars=0, status=0, titlebar=0, toolbar=0");
	newWindow=str;
	//newWindow.resizeTo(mpwidth,mpheight);
	topX = window.screen.width-mpwidth;
	 topY = window.screen.height-mpheight;
	 //alert(topX+','+topY);
	if (newWindow != null && newWindow != undefined)
	    newWindow.moveTo(topX,topY);
	
	//newWindow.location=URLSTR+"?doFunction=first";
	//document.cookie="isOpened=1";
}				
function closeMplayer(){
	if (window.location.search('www.starbucks.com.tw')==-1){
		newWindow.close();
	}
	
}