serverSideFile='/servlet/AJAXServlet';//liveda ve test sunucu da
//serverSideFile = '/CamlicaPortakalWebpage/servlet/AJAXServlet';//test localde

function closeAllFlashMenus()
{
	var flashMovie=thisMovie("myFlashMovie");
	if(flashMovie != null && flashMovie != undefined){
		flashMovie.TGotoFrame("_root/b1",0);
		flashMovie.TGotoFrame("_root/b2",0);
		flashMovie.TGotoFrame("_root/b3",0);
		flashMovie.TGotoFrame("_root/b4",0);
		flashMovie.TGotoFrame("_root/b5",0);
		flashMovie.TGotoFrame("_root/b6",0);
	}
}
function submitToIframeEglenceyeKatil(parameters){
	parent.document.getElementById('eglenceyekatilcontent').src = "eglenceye-katil-content.jsp?content="+parameters;
}

function popUpDinle(playlist){muteVolume(); changeMuteImg();var URL="dinle.jsp?popup=1&playlist="+playlist;eval("pageDinle = window.open(URL, 'dinle', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=350,height=205,left = 490,top = 250');");pageDinle.focus();}
function popUpIzle(){var URL="video-player.jsp?popup=1";eval("pageIzle = window.open(URL, 'izle', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=410,height=505,left = 490,top = 250');");pageIzle.focus();}
function popUpIndir(fileLink){var URL=fileLink; var password = password; eval("pageIndir = window.open(URL, 'indir', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=600,height=369,left=390,top=250');");pageIndir.focus();}
function popUpSifre(){var URL="sifre-gonder.jsp?popup=1";eval("pageSifre = window.open(URL, 'sifre', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=200,height=200,left=390,top=250');");pageSifre.focus();}
function popUpRetro(){var URL="retro-gece.jsp?popup=1";eval("pageRetro = window.open(URL, 'retro', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=490,height=550,left = 490,top = 30');");pageRetro.focus();}
function popUpKampanyaDetay(){var URL="kampanya_detaylari_popup.jsp";eval("pageKampanyaDetay = window.open(URL, 'retro', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=396,height=195,left = 490,top = 30');");pageKampanyaDetay.focus();}

function introPopup(popupNr){
	var URL="intro_popup.jsp?popup="+popupNr;
	eval("pageIntro = window.open(URL, 'intro', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=600,height=418,left = 100,top = 100');");
	pageIntro.focus();
}

function changeMuteImg(){
	obj = document.getElementById("mute");
	if(obj){
	 if(-1 != obj.src.indexOf("tv_sound_on.png")){
	 	obj.src="img/tv_sound_off.png;"
	 } 
	}
}

function changeTown (cityId){
	new Ajax.Request(serverSideFile, {
    	method: "post",  
		parameters: {cmd: 'CHANGETOWN', city: cityId},
		onSuccess: function(transport){ 
			response = transport.responseText;
			document.getElementById('divIlce').innerHTML = response;	
		},
		onFailure: function(){ alert('L\u00fctfen daha sonra tekrar deneyiniz.') }
		});
}
function submitContactForm(surname, phoneCode, phoneNumber, email, message, city, town){
		new Ajax.Request(serverSideFile, {
    	method: "post",  
		parameters: {cmd: 'SUBMITFORM', surname: surname, phoneCode: phoneCode, phoneNumber: phoneNumber, email: email, message: message, city: city, town: town},
		onSuccess: function(transport){ 
			response = transport.responseText;
			document.getElementById('contact_div_inner').innerHTML = response;	
		},
		onFailure: function(){ alert('L\u00fctfen daha sonra tekrar deneyiniz.') }
		});
}

function submitPasswordForm(password, fileName, fileLink){
		new Ajax.Request(serverSideFile, {
    	method: "post",  
		parameters: {cmd: 'SUBMITPASSWORD', password: password},
		onSuccess: function(transport){ 
			response = transport.responseText;
			if (response == "success"){
				varFileName = fileName; 
				varFileLink = fileLink; 
				varPassword = password;
				response = "<a href='javascript:onSuccessPassword();' style='cursor:pointer;text-decoration:none;'>Şifreniz başarılı,<br />lütfen indirmek için tıklayınız.</a>";
				document.getElementById('msg').innerHTML = response;
				//window.location='indir.jsp?fileName='+fileName+"&fileLink="+fileLink+"&password="+password;
				//popUpIndir('indir.jsp?fileName='+fileName+"&fileLink="+fileLink+"&password="+password);
			} else {
				document.getElementById('msg').innerHTML = response;
			}	
		},
		onFailure: function(){ alert('L\u00fctfen daha sonra tekrar deneyiniz.') }
		});
}

function createPlayer(theFile, theAutoStart) {
	var flashvars = {
		barwidth:"370",
		width:"224",
		height:"101",
		enablejs:"true",
		javascriptid:"mpl",
		volume:"80",
		displayheight:"0",
		searchbar:"false",
		repeat:"true",
		shuffle:"false",
		thumbsinplaylist:"false",
		usefullscreen:"false",
		screencolor:"0xf5a843",
		frontcolor:"0xc60a20",
		lightcolor:"0xc60a20",
		backcolor:"0xf5a843",
		file: theFile,			                    
		autostart:theAutoStart
	}            
    var params = {
         allowfullscreen:"false", 
         allowscriptaccess:"always",
         wmode:"opaque"
    }
    var attributes = {
         id:"mpl",  
         name:"mpl"
    }					            	            
    swfobject.embedSWF("swf/mediaplayer.swf", "playerholder", "224", "101", "9.0.115", false, flashvars, params, attributes);
}
/******************* Flash Player ***********************/
/*
http://www.jeroenwijering.com/?item=Javascript_interaction
http://home5.inet.tele.dk/nyboe/flash/mediaplayer/
http://blog.deconcept.com/swfobject/	
http://www.jeroenwijering.com/?thread=5586
http://www.jeroenwijering.com/?thread=10158
http://home5.inet.tele.dk/nyboe/flash/mediaplayer/loadandplay.htm
http://home5.inet.tele.dk/nyboe/flash/test/javascripttimer.htm
*/
var currentItem;
var currentState;
var currentVolume = 80;
var prevVolume = currentVolume;
function thisMovie(movieName) {
	if(navigator.appName.indexOf("Microsoft") != -1) {
		if(parent != self)
			return parent.window[movieName];
		else
			return window[movieName];
	} else {
		if(parent != self)
			return parent.document[movieName];
		else
			return document[movieName];
	}
}
// Play First Item : sendEvent('mpl','playitem','0') 
function sendEvent(swf,typ,prm) {
	thisMovie(swf).sendEvent(typ,prm); 
}
function setFlashPlayerVolume(swf,type,prm) {
	if(currentVolume == undefined || currentVolume ==  null)
		currentVolume = 80;
	currentVolume = currentVolume + prm;
	if(currentVolume >= 0){
		if(thisMovie(swf) != null)
			thisMovie(swf).sendEvent(type, currentVolume);
	} 	
}

function volumeMute(){
	if(currentVolume != 0){
		if(document.getElementById("soundBtn"))
			document.getElementById("soundBtn").src = "img/sound_off.png";
		prevVolume = currentVolume;
		setFlashPlayerVolume('mpl', 'volume', -currentVolume);
	} else {
		if(document.getElementById("soundBtn"))
			document.getElementById("soundBtn").src = "img/sound_on.png";
		setFlashPlayerVolume('mpl', 'volume', prevVolume);
	}
} 

function volumeOrganizeButton(){
	if(currentVolume == 0){
		if(document.getElementById("soundBtn"))
			document.getElementById("soundBtn").src = "img/sound_off.png";
	} else {
		if(document.getElementById("soundBtn"))
			document.getElementById("soundBtn").src = "img/sound_on.png";
	}
} 

function getUpdate(type,pr1,pr2,swf) {
	if(swf != "null") {
		if(type == "volume") { 
			currentVolume = parseInt(pr1); 
			volumeOrganizeButton();
		} else if((type == "state")&&(pr1 != undefined)) { 
			currentState = pr1; 			
			if(currentState=="2" || currentState=="3"){
				playFlashMovie('hoparlorMovie');
			} else {
				stopFlashMovie('hoparlorMovie');
			}
		} else if(type == "item") { 
			currentItem = pr1; 
			setTimeout("getItemData(currentItem)",100);
		}		
	}
}
function trim(obj) {
	return obj.replace(/^\s+|\s+$/g,"");
}

// http://home5.inet.tele.dk/nyboe/flash/mediaplayer/javascript.htm
function getItemData(idx) {
	var obj = thisMovie("mpl").itemData(idx);	
	var link = obj["link"];
	if(link == "" || link == undefined){	
		document.getElementById("playerDownload").innerHTML = "";
	} else {	
		document.getElementById("playerDownload").innerHTML = "<a href='#' onclick='javascript:popUpIndir(\""+trim(link)+"\");' title='İndir'>Şarkıyı İndir</a>";	
	}
};

/******************* Flash Interaction with Javascript ***********************/
/*http://www.permadi.com/tutorial/flashjscommand/*/
function stopFlashMovie(flashMovieId){
	var flashMovie = thisMovie(flashMovieId);
	if(flashMovie != null)
		flashMovie.StopPlay();
}
function playFlashMovie(flashMovieId){
	var flashMovie = thisMovie(flashMovieId);
	if(flashMovie != null)
		flashMovie.Play();
}



