﻿var SiteURL = "http://www.cokenmusic.com";
//www.cokenmusic.com

try {
window.parent.document.title =' Coke’n Music';
}
catch (err) {
        a1 = "";
    }
window.onload = titleChange();

function titleChange() {
    try {
         
            window.parent.document.title = parent.frames["FrameMain"].document.title;
         
    }
    catch (err) {
        a1 = "";
    }
}



function titleChange() {
    try {
        if (parent.frames["FrameMain"] != undefined) {
			var frameTitle=parent.frames["FrameMain"].document.title;
            window.parent.document.title = frameTitle;
        }
    }
    catch (err) {
        a1 = "";
    }
}

function facebookConnectCallBack() {
    var result = "1";
    result = SiteFunctions.FacebookConnectEnterUser();
	var QueryStrURL = location.href
	
	if (QueryStrURL.indexOf('Welcome.aspx')>-1) {
	   location.href='Welcome.aspx'
	}

}
     
function facebookConnectCallCancelBack() {
    result = SiteFunctions.FacebookConnectCancelUser();
    


}


function imageError(img) {
  img.src = "http://www.cokenmusic.com/Images/Member/120x110/noimage.gif";
}



function getQueryStringValue(Deger) {
var QueryStrURL = location.href
  if(Deger!=null) {
    var regEx = new RegExp("(\\?|&)("+Deger+"=)(.*?)(&|$|#)","i")
    var exec = regEx.exec(QueryStrURL)
    var Sonuc = RegExp.$3
  } else {
    var regEx = new RegExp("(\\?)(.*?)($)","i")
    var exec = regEx.exec(QueryStrURL)
    var Sonuc = RegExp.$2
  }

  return(Sonuc);
}


function MoodPlayerFrameReload() {
    Navigator('FrameMoodPlayer', 'MoodPlayer.aspx');
}
function ExtSongLink(SongId, ArtistName, SongName) {
    //...
    var LocalShareURL="http://www.cokenmusic.com/extShare.aspx?ContentId="+SongId+"&A="+ArtistName+"&T="+SongName;
    var LocalShareTitle="Cokenmusic.com "+ ArtistName+" - "+SongName;
    window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(LocalShareURL)+'&t='+encodeURIComponent(LocalShareTitle),' sharer', 'toolbar=0, status=0, width=626, height=436');
    
}

function ExtSongLink2(SongId, ArtistName, SongName) {
    //...
    var LocalShareURL = "http://www.cokenmusic.com/extShare.aspx?ContentId=" + SongId + "&A=" + ArtistName + "&T=" + SongName;
    var LocalShareTitle = "Cokenmusic.com " + ArtistName + " - " + SongName;
    var mywindow = window.open('http://www.cokenmusic.com/sharer.html?u=' + encodeURIComponent(LocalShareURL) + '&t=' + encodeURIComponent(LocalShareTitle), encodeURIComponent(LocalShareTitle) + " - Cokenmusic.com", "toolbar=0, status=0, width=750px, height=200px");
    mywindow.moveTo(0, 0);
}

// This function calling from MoodPlayer.swf
/*function ModuleStatus(_status) {
    var fs = parent.document.getElementById("frameset1");

    switch (_status) {
        case "mini": fs.rows = '25px,*';
            break;
        case "midi": fs.rows = '144px,*';
            break;
        case "maxi": fs.rows = '244px,*';
            break;
        default: fs.rows = '144px,*';
    }
}*/
function ModuleStatus2(_status) {
    var fs = parent.document.getElementById("frameset1");

    switch (_status) {
        case "mini": fs.rows = '*,65px';
            break;
        case "midi": fs.rows = '*,410px';
            break;
        case "maxi": fs.rows = '*,410px';
            break;
        default: fs.rows = '*,65px';
    }
}
function ModuleStatus(_status) {
    var fs = parent.document.getElementById("frameset1");

    switch (_status) {
        default: fs.rows = '70px,*';
        case "mini": fs.rows = '70px,*';
            break;
        case "midi": fs.rows = '410px,*';
            break;
        case "maxi": fs.rows = '410px,*';
            break;
        
    }
}
//function RedirectFromFacebookConnect() {

//    u = location.href;
//    var RedirectStatus = u.indexOf("main.aspx");
//    var RedirectStatus2 = u.indexOf("Main.aspx");
////    var isRegistered= ""; 
////    isRegistered = CokeUser.CheckFacebookRegister("123456");
////    if(isRegistered!="-1")
////    {
////    alert('REGISTERED USER!');
////    }
////    else
////    {
////    alert('NOT REGISTERED!');
////    }
//    if (RedirectStatus >= 0 || RedirectStatus2 >= 0) {
//        if (u == SiteURL + '/Main.aspx?t=1') {
//            alert("IF: "+u);
//        }
//        else {
//            alert("ElSE: " + u);
//            window.location = SiteURL + '/Main.aspx?t=1';
//        }
//    }
//}


//function Popup(url) {
//    window.open(url, "myWindow", "status = 1, height = 600, width = 960,scrollbars=1")
//}

function Popup(url, windowWidth, windowHeight) 
{
    myleft = (screen.width) ? (screen.width-windowWidth) / 2 : 100;
    mytop = (screen.height) ? (screen.height-windowHeight) / 2 : 100;
    properties = "width=" + windowWidth + ",height=" + windowHeight + ",status=yes,scrollbars=yes,top=" + mytop + ",left=" + myleft;
    window.open(url, "myWindow", properties)
}


function MoodVisibility() {
    var fs = parent.document.getElementById('frameset1');
    var frame = parent.document.getElementById("FrameMoodPlayer");
    var MoodHeight = 0;
    MoodHeight = frame.scrollHeight;
    if (MoodHeight > 25) {
        if (fs) {
            fs.rows = '25px,*';
        }
    }
    else {
        fs.rows = '125px,*';
    }
}

function Redirect(Url) {
    Navigator('FrameMoodPlayer', 'MoodPlayer.aspx');
    Navigator('FrameMain', 'RegisterSuccess.aspx');

    //window.top.location="/Profileme.aspx";
    //parent.frames[FrameName].document.location = "/Default.aspx";
}

function RegisterSuccess() {
    Navigator('FrameMoodPlayer', 'MoodPlayer.aspx');
    Navigator('FrameMain', 'profileme.aspx');

    //window.top.location="/Profileme.aspx";
    //parent.frames[FrameName].document.location = "/Default.aspx";
}

function Navigator(FrameName, Link) {
    parent.frames[FrameName].document.location = Link;
}


function findPositionLeft(oLink) {
    try {
        if (oLink != undefined) {
            if (typeof (oLink.offsetParent) != 'undefined') {
                for (var posX = 0, posY = 0; oLink; oLink = oLink.offsetParent) {
                    posX += oLink.offsetLeft;
                    posY += oLink.offsetTop;
                }
                return posX;
            } else {
                return [oLink.x, oLink.y];
            }
        }
    }
    catch (Err) {
        a1 = "";
    }
}


function findPositionTop(oLink) {
    if (typeof (oLink.offsetParent) != 'undefined') {
        for (var posX = 0, posY = 0; oLink; oLink = oLink.offsetParent) {
            posX += oLink.offsetLeft;
            posY += oLink.offsetTop;
        }
        return posY;
    } else {
        return [oLink.x, oLink.y];
    }
}

function ClearTextBox(object) {
    document.getElementById(object).value = "";
}

//var dynamicLeft = findPositionLeft(document.getElementById("rvdHakkinda"));
//var screenwidth = screen.width;
//document.getElementById("menus1").style.marginLeft = "206px";

function ChangeLeftMargin() {
    var dynamicTop = findPositionTop(parent.frames["FrameMain"].document.getElementById("CenterReference"));
    //alert(dynamicTop);
    var ScreenHeight = screen.height;
    //alert(ScreenHeight);



    //---------

    if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)) {
        //alert('firegox');
        if (ScreenHeight - dynamicTop - 310 < 0) {
            //alert('scrollu firefox');
            SetLeftMargin(0);
        }
        else {
            //alert('scrollsuz firefox');
            SetLeftMargin(8);
        }
    }
    else if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) {
        var ieversion = new Number(RegExp.$1)
        if (ieversion == 6) {
            if (ScreenHeight - dynamicTop - 300 < 0) {
                //alert('scrollu explorer 6');
                SetLeftMargin(8);
            }
            else {
                //alert('scrollsuz explorer 6');
                SetLeftMargin(8);
            }
        }
        else {
            //alert(ScreenHeight + '-' + dynamicTop + '-' + 300);
            if (ScreenHeight - dynamicTop - 300 < 0) {
                SetLeftMargin(0);
            }
            else {
                //alert('scrollsuz');
                SetLeftMargin(8);
            }
        }
    }
    else if (/Chrome[\/\s](\d+\.\d+)/.test(navigator.userAgent)) {
        //alert('chrome');
        if (ScreenHeight - dynamicTop - 310 < 0) {
            SetLeftMargin(0);
        }
        else {
            //alert('scrollsuz');
            SetLeftMargin(8);
        }
    }

    else if (/Safari[\/\s](\d+\.\d+)/.test(navigator.userAgent)) {
        //alert('Safari');
        //alert('chrome');
        if (ScreenHeight - dynamicTop - 310 < 0) {
            SetLeftMargin(0);
        }
        else {
            //alert('scrollsuz');
            SetLeftMargin(8);
        }
    }
}

function SetLeftMargin(Correction) {
    var Lefter = findPositionLeft(parent.frames["FrameMain"].document.getElementById("MemberBar"));
    //alert(Lefter);

    parent.frames["FrameMain"].document.getElementById("Content").style.marginLeft = (Lefter - Correction) + "px";
    //    parent.frames["FrameMain"].document.getElementById("MemberBar").style.marginLeft = (Lefter - Correction) + "px";
    //    parent.frames["FrameMain"].document.getElementById("ContentBody").style.marginLeft = (Lefter - Correction) + "px";
}

function InsertSongVote(ContentId, Vote, DivId) {
    var _ContentId = "";
    var _Vote = "";
    var _DivId = "";

    _ContentId = ContentId;
    _Vote = Vote;
    _DivId = DivId;

    var number = "0";
    number = SiteFunctions.InsertStarRating(_ContentId, _Vote, _DivId);
    //number = SiteFunctions.InsertStarRating(_ContentId,_Vote,_DivId);
    if (number.value == "0") {
        alert('Oy verebilmek için üye girişi yapmalısın!');
    }
    else {
        document.getElementById(_DivId).innerHTML = number.value;
        var VoteCountDivName = "";
        VoteCountDivName = "VoteCount_" + ContentId;
        GetStarRatingVoteCount(_ContentId, VoteCountDivName);
        return false;
    }
    return false;

}

function GetStarRatingVoteCount(ContentId, DivId) {
    //alert('girdi' + ContentId + '-' + DivId);

    var x = document.getElementById(DivId);
    if (x == null) {

    }
    else {
        var number = "0";
        number = SiteFunctions.GetStarRatingVoteCount(ContentId);
        document.getElementById(DivId).innerHTML = number.value;
    }
}

function LoginPopup() {
    document.getElementById('PopupLogin').style.visibility = 'visible';
}

function AlertPopup() {
    var scrollTop = document.body.scrollTop;

    if (scrollTop == 0) {
        if (window.pageYOffset)
            scrollTop = window.pageYOffset;
        else
            scrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
    }

    if(document.getElementById('AlertDiv')!=null)
	{
		document.getElementById('AlertDiv').style.top = scrollTop + 200;
		document.getElementById('AlertDiv').style.visibility = 'visible';
	}
}

function HideAlertPopup() {
    document.getElementById('AlertDiv').style.visibility = 'hidden';
}
function AddComment(ContentId) {
    var objTextBox = document.getElementById('txt_Comment');
    var MessageBody = objTextBox.value;
    var CaptchaText = document.getElementById('txt_Comment_Captcha').value;
    SiteFunctions.AddComment(ContentId, MessageBody);
    AlertPopup();
    objTextBox.value = "";
}

function LikeIt(ContentId, UserId, DivName) {
    var result = "";
    result = SiteFunctions.AddLikeContentTemplate1(ContentId, UserId, DivName);
    if (result.value == "0") {
        LoginPopup();
    }
    else {
        document.getElementById(DivName).innerHTML = result.value;
    }


}
////Share Javascript Functions
function fbs_click() {
    u = location.href;
    t = document.title;
    window.open('http://www.facebook.com/sharer.php?u=' + encodeURIComponent(u) + '&t=' + encodeURIComponent(t), 'sharer', 'toolbar=0,status=0,width=626,height=436');
    return false;
}
function StumbleUpon_click() {
    u = location.href;
    t = document.title;
    window.open('http://www.stumbleupon.com/submit?url=' + encodeURIComponent(u) + '&title=' + encodeURIComponent(t));
    return false;
}
function Digg_click() {
    u = location.href;
    window.open('http://digg.com/submit?phase=2&url=' + encodeURIComponent(u));
    return false;
}
function Delicious_click() {
    u = location.href;
    t = document.title;
    window.open('http://del.icio.us/post?url=' + encodeURIComponent(u) + ';title=' + encodeURIComponent(t));
    return false;
}
function Twitter_click() {
    u = location.href;
    window.open('http://twitter.com/home?status=' + encodeURIComponent(u));
    return false;
}
function SendMail() {
    u = location.href;
    t = document.title;
    window.open('mailto:?subject=' + encodeURIComponent(t) + '&body=' + encodeURIComponent(u));
}
function AddToFavourites() {
    u = location.href;
    t = document.title;
    if (window.sidebar) { // Mozilla Firefox Bookmark
        window.sidebar.addPanel(t, u, "");
    } else if (window.external) { // IE Favorite
        window.external.AddFavorite(u, t);
    }
    else if (window.opera && window.print) { // Opera Hotlist
        return true;
    }
}

function ChangeFramePosition() {
  try {
      
    
    var dynamicLeft = findPositionLeft(parent.frames["FrameMoodPlayer"].document.getElementById("Mood"));
    //alert(dynamicLeft);

    var root = document.compatMode == 'BackCompat' ? document.body : document.documentElement;
    var isVerticalScrollbar = root.scrollHeight > root.clientHeight;
    var isHorizontalScrollbar = root.scrollWidth > root.clientWidth;
    //alert(isVerticalScrollbar);
    //alert(isHorizontalScrollbar);

    if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)) {
        //alert('firegox');
        if (isVerticalScrollbar) {
            //alert('scrollu firefox');
            SetLeftPos(dynamicLeft);
        }
        else {
            //alert('scrollsuz firefox');
            SetLeftPos(dynamicLeft);
        }
    }
    else if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) {
        var ieversion = new Number(RegExp.$1)
        if (ieversion == 6) {
            if (isVerticalScrollbar) {
                //alert('scrollu explorer 6');
                SetLeftPos(dynamicLeft);
            }
            else {
                //alert('scrollsuz explorer 6');
                SetLeftPos(dynamicLeft);
            }
        }
        else {
            if (isVerticalScrollbar) {
                //alert("ie7scroll");
                SetLeftPos(dynamicLeft);
            }
            else {
                SetLeftPos(dynamicLeft);
            }
        }
    }
    else if (/Chrome[\/\s](\d+\.\d+)/.test(navigator.userAgent)) {
        //alert('chrome');
        if (isVerticalScrollbar) {
            SetLeftPos(dynamicLeft);
        }
        else {
            //alert('scrollsuz');
            SetLeftPos(dynamicLeft);
        }
    }

    else if (/Safari[\/\s](\d+\.\d+)/.test(navigator.userAgent)) {
        //alert('Safari');
        //alert('chrome');
        if (isVerticalScrollbar) {
            SetLeftPos(dynamicLeft);
        }
        else {
            //alert('scrollsuz');
            SetLeftPos(dynamicLeft);
        }
    }
	
	}
    catch (err) {
        a1 = "";
    }
}

function SetLeftPos(LeftWidth) {
    try {
        parent.frames["FrameMain"].document.getElementById("Content").style.marginLeft = LeftWidth + "px";
    }
    catch (err) {
        a1 = "";
    }
}

function CheckFrame() {
    var fs = parent;
    if (fs != top) {
        top.window.location = "Default.aspx";
    }
}
function CheckTopFrame() {

    var u = GetTopURL();
	var topFrame = top.document.getElementById("FrameMain");
	
	var urlString = top.window.location.href;
            var strASPX = urlString.indexOf(".aspx");
            urlString = urlString.substring(0, strASPX);
			// cokenmusic.com -> char count:14
            var slashIndex = urlString.lastIndexOf("cokenmusic.com")+14;
            urlString = top.window.location.href;
			urlString = urlString.substring(slashIndex, urlString.length);
			
	if (topFrame != null) {
		
	}
    else {
			var isSecure=0;
			if(top.window.location.href.indexOf("https://www.cokenmusic.com") == 0 && getQueryStringValue("isSecure") == 1 )
			{
				isSecure=1;
			}
			
			if((top.window.location.href.indexOf("http://www.cokenmusic.com") == 0 || top.window.location.href.indexOf("https://www.cokenmusic.com") == 0) 
				|| (urlString.indexOf("http://")== -1 && urlString.indexOf("script")== -1) )
            {
			
			if(isSecure==1)
				{
					top.window.location = "https://www.cokenmusic.com/Default.aspx?u=" + escape(urlString)+"#";
				}
			else
				{
					top.window.location = "http://www.cokenmusic.com/Default.aspx?u=" + escape(urlString);
				}
            }
			
            else
            {
              top.window.location = "http://www.cokenmusic.com/Default.aspx?r=1";
            }
            //www.cokenmusic.com/
        
    }

}
function GetTopURL() {
    return top.window.location.href;
}
function queryString(Deger) {
    if (Deger != null) {
        var regEx = new RegExp("(\\?|&)(" + Deger + "=)(.*?)(&|$|#)", "i")
        var exec = regEx.exec(GetTopURL())
        var Sonuc = RegExp.$3
    } else {
        var regEx = new RegExp("(\\?)(.*?)($)", "i")
        var exec = regEx.exec(GetTopURL())
        var Sonuc = RegExp.$2
    }

    return (Sonuc)
}
function doClick(buttonName, e) {
    var key;

    if (window.event)
        key = window.event.keyCode;     //IE
    else
        key = e.which;     //firefox

    alert(key);
    if (key == 13) {
        //Get the button the user wants to have clicked
        var btn = document.getElementById(buttonName);
        btn.click();
        event.keyCode = 0
    }
}


function EmailClearer() {
    if (document.getElementById('ctl00_UC_MemberBar1_txt_Email').value == 'e-posta') {
        document.getElementById('ctl00_UC_MemberBar1_txt_Email').value = '';
    }
}

function PassWordClearer() {
    //    if (document.getElementById('ctl00_UC_MemberBar1_txt_PassWord').type != 'password') {
    //        document.getElementById('ctl00_UC_MemberBar1_txt_PassWord').type = 'password';
    //    }
    if (document.getElementById('ctl00_UC_MemberBar1_txt_PassWord').value == 'şifre') {
        document.getElementById('ctl00_UC_MemberBar1_txt_PassWord').value = '';
    }
}
function SearchSongTextBoxClearer() {
    if (document.getElementById('ctl00_ContentPlaceHolder1_txt_SearchSong').value == 'Şarkı adı yaz') {
        document.getElementById('ctl00_ContentPlaceHolder1_txt_SearchSong').value = '';
    }
}

function SearchArtistTextBoxClearer() {
    if (document.getElementById('ctl00_ContentPlaceHolder1_txt_SearchArtist').value == 'Sanatçı adı yaz') {
        document.getElementById('ctl00_ContentPlaceHolder1_txt_SearchArtist').value = '';
    }
}
function SearchAudioClearer() {
    if (document.getElementById('ctl00_ContentPlaceHolder1_txt_SearchAudio').value == 'şarkı adı yaz') {
        document.getElementById('ctl00_ContentPlaceHolder1_txt_SearchAudio').value = '';
    }
}



function EnterCatcher(ElementId,event)
{
    if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {document.getElementById(ElementId).click();return false;}} else {return true};
}

function thisMovie(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return parent.frames["FrameMoodPlayer"].document.getElementById(movieName);
    } else {
    return parent.frames["FrameMoodPlayer"].document[movieName];
    }
}
function AddToSongList(value) {
    thisMovie("moodplayer").AddNewSong(value);
}

function PlayNewSongList(value) {
    //thisMovie("moodplayer").PlayNewSong(value);
	thisMovie("moodplayer").AddNewSong(value);
}

function PopupFacebook(Url) {
    window.open(Url, 'sharer', 'toolbar=0,status=0,width=626,height=436');
}

var t;
function MM_swapImgRestore() { //v3.0
    var i, x, a = document.MM_sr; for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;
}
function MM_preloadImages() { //v3.0
    var d = document; if (d.images) {
        if (!d.MM_p) d.MM_p = new Array();
        var i, j = d.MM_p.length, a = MM_preloadImages.arguments; for (i = 0; i < a.length; i++)
            if (a[i].indexOf("#") != 0) { d.MM_p[j] = new Image; d.MM_p[j++].src = a[i]; }
    }
}

function MM_findObj(n, d) { //v4.01
    var p, i, x; if (!d) d = document; if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
        d = parent.frames[n.substring(p + 1)].document; n = n.substring(0, p);
    }
    if (!(x = d[n]) && d.all) x = d.all[n]; for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
    for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
    if (!x && d.getElementById) x = d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
    var i, j = 0, x, a = MM_swapImage.arguments; document.MM_sr = new Array; for (i = 0; i < (a.length - 2); i += 3)
        if ((x = MM_findObj(a[i])) != null) { document.MM_sr[j++] = x; if (!x.oSrc) x.oSrc = x.src; x.src = a[i + 2]; }
}

function ShowPopup(hoveritem) {
    hp = document.getElementById("hoverpopup");
    hp.style.visibility = "Visible";
}


function HidePopup() {

    hp = document.getElementById("hoverpopup");
    hp.style.visibility = "Hidden";
}

function resize(which, max) {
  var elem = document.getElementById(which);
  if (elem == undefined || elem == null) return false;
  if (max == undefined) max = 75;
  if (elem.width > elem.height) {
    if (elem.width > max) elem.width = max;
  } else {
    if (elem.height > max) elem.height = max;
  }
}

function ChangeVisible(var1, var2)
{
	document.getElementById(var1).style.visibility="hidden";
	document.getElementById(var2).style.visibility='visible';
}