
var playButton
var trackId
var trackDetails, albumId
var albumButton = ''
var player
var iframe
var iframeUrl = ""


	
      function handler(newHash, initial) {
		var oIframe 	=	document.getElementById("iframe");

	   iframe = oIframe.contentWindow || oIframe.contentDocument;

	     if (iframe.document) {
        iframe = iframe.document;
    }

          if (initial){
			  if(newHash=="")
             	iframe.location.replace("index.php")
			  else
			  	iframe.location.replace("index.php?" + newHash)
		  }else{
          	iframe.location.replace("index.php?" + newHash)

		  }
	  }
      
	
	/*
		newIframeUrl = window.location.hash.replace('#/', '')
		//alert(iframeUrl + '\n' + newIframeUrl)
		if (iframeUrl!==newIframeUrl){
			iframeUrl=newIframeUrl
			jQuery('#iframe').attr('src', 'index.php?'+iframeUrl);
		}
		*/


jQuery(document).ready(function(){
	iframe = document
	
	//Hash.init(handler, document.getElementById('hashistory'));
	
		//iframeUrl = window.location.hash.replace('#/', '')
	
	//jQuery('#iframe').attr('src', iframeUrl);
	
	/*jQuery('#iframe').load(function(){
		var oIframe 	=	document.getElementById("iframe");

	   iframe = oIframe.contentWindow || oIframe.contentDocument;

	     if (iframe.document) {
        iframe = iframe.document;
    }
	
 	jQuery('.play-icon', iframe).live('click', parent.play)
	jQuery('.play-icon, .play-icon-large', iframe).live('mouseover mouseout', 
	function(event){
		if (event.type == 'mouseover') {
		jQuery(this).addClass('play-icon-hover')
		}else{
		jQuery(this).removeClass('play-icon-hover')
		}
	}
	)
	



	jQuery("a", iframe).click(
function()
{  
       
		Hash.go(jQuery(this).attr('href').replace('/islam/index.php?', ''))
		return false
		
         
 }); 

 
	})
	 */
		
 
	
	initiate()
	
 	jQuery('.play-icon-large:not(.play-icon-disabled)').live('click', function(){playAlbum(this)})
 	jQuery('.play-icon:not(.play-icon-disabled)').live('click', play)
 	jQuery('.play:not(.play-icon-disabled)').live('click', togglePlayState)
 	jQuery('.play-icon:not(.play-icon-disabled),.play:not(.play-icon-disabled),.play-icon-large:not(.play-icon-disabled)')
	.live('mouseover mouseout', 
	function(event){
		if (event.type == 'mouseover') {
		jQuery(this).addClass('play-icon-hover')
		}else{
		jQuery(this).removeClass('play-icon-hover')
		}
	}
	)
	
})

function getPlayList(el){
		
		var playlist = []
		el.each(function(){
			playlist.push({id: jQuery(this).attr('id')})
		})
		return playlist
}

function addAlbumToPlaylist(tracklist, next){
	clearPlaylist()
	var newList = []
	for (i=0; i<=(tracklist.length-1); i++){
		var track = tracklist[i]
		//update array with all items in playlist
		newList.push({file: track.file, title: track.title, streamer: "rtmp://media.islamise.co.uk/cfx/st/", provider: "rtmp" })			
		//reload flash playlist and play latest item
	
		var newPlayListItemHtml		=	jQuery("<tr id='" + track.id + "' class='item'><td width='5%' align='center'><img src='images/mediaplayer/spacer.gif' alt='Play' class='play-icon track" + track.id + " queue'></td><td width='50%'>" + track.title + "</td><td width='45%'>" + track.artist + "</td></tr>");
		//var newPlayListItemHtml	=	jQuery("<div class='" + track.file + "' > <span>" + track.title + "</span></div>");
		//var playButtonHtml = jQuery("<img />").attr('class', 'play-icon track' + track.id + ' album' + track.albumId + ' queue').attr('src', 'images/mediaplayer/spacer.gif').prependTo(newPlayListItemHtml)
		//<img src='spacer.v1223634230.gif' alt='Play' class='play-icon track" + trackId + "' \/>
		jQuery('#playlist').append(newPlayListItemHtml)
		if (i==0){
			playButton=jQuery(".track" + track.id);
			trackId = track.id
			
		}
	}
			

	jwplayer().load(newList).playlistItem(0)
}

function clearPlaylist(){
	jQuery('#playlist .item').remove()
}

function addToPlayList(trackDetails){
	//alert(trackDetails.file)
	
	//check to see if playlist exists and return index to moved to end of playlist and played
	var playlist	=	getPlayList(jQuery('#playlist .item'))
	var isPlaylistItemMatch	=	false
	var	playlistItemIndex	=	-1
		
	for (var i in playlist){
		if (trackDetails.id == playlist[i].id){
			isPlaylistItemMatch = true; playlistItemIndex = i
		}
			
	}
	
	if(isPlaylistItemMatch){
		
		player.playlistItem(playlistItemIndex)
		//jQuery('#playlist .play-icon:eq(' + playlistItemIndex + ')').click()//.appendTo('#playlist')
		//reloadPlaylistOrig()
		
	}else{
	
	
	//add to html playlist
	//var newPlayListItemHtml	=	jQuery("<div class='" + trackDetails.file + "'> <span>" + trackDetails.title + "</span></div>");
	var newPlayListItemHtml		=	jQuery("<tr id='" + trackDetails.id + "' class='item'><td width='5%' align='center'><img src='images/mediaplayer/spacer.gif' alt='Play' class='play-icon track" + trackId + " queue'></td><td width='50%'>" + trackDetails.title + "</td><td width='45%'>" + trackDetails.artist + "</td></tr>");
							
							
	//var playButtonHtml = jQuery("<img />").attr('class', 'play-icon track' + trackId + ' queue').attr('src', 'images/mediaplayer/spacer.gif').prependTo(newPlayListItemHtml)
	//<img src='spacer.v1223634230.gif' alt='Play' class='play-icon track" + trackId + "' \/>
	jQuery('#playlist').append(newPlayListItemHtml)
	playButton	=	jQuery(".track" + trackId)
	
	
	//reload playlist
	//reloadPlaylistOrig(trackDetails	)
		//create new array
        var newList = parent.jwplayer().getPlaylist()
		
		//update array with all items in playlist
		newList.push({file: trackDetails.file, title: trackDetails.title, streamer: "rtmp://media.islamise.co.uk/cfx/st/", provide: "rtmp" })			
		//reload flash playlist and play latest item
		
		player.load(newList).playlistItem(newList.length-1)
		
	
	
	}
}

function getId(el){
	
	var class1 = el.attr('class').split(" ")
	
	//return class1[1].replace("track", "");
	//var a = class1.replace(/[^\d]/g, "");
	var a// = class1.replace('track', '')
	
	for (var i in class1){
	if(i>0){	
	if (class1[i].match(/track/)) { 
		a = class1[i].replace("track", "");
	}
	}
	}
	return a
	
}

function getAlbumId(el){
	var class1 = el.attr('class').split(" ")
	//return class1[1].replace("track", "");
	//var a = class1.replace(/[^\d]/g, "");
	var a// = class1.replace('track', '')
	for (var i in class1){
	if(i>0){	
	if (class1[i].match(/album/)) { 
		a = class1[i].replace("album", "");
	}
	}
	}
	return a
	
}

function getType(){
	var class1 = el.attr('class')
	if (class1.match(/album/)) { 
		return 'album'
	}else if (class1.match(/track/)) { 
		return 'track'
	}else{
		'track'	
	}

}

function stopPlayer(){
	jwplayer().stop();	
	jQuery('#progress').slider('value', 0)
	jQuery('#current-position').html(secondsToHms(0))
	stopPlayButton()
}

function pausePlayButton(){
	
	jQuery('.track' + trackId + ', .play').removeClass('play-icon-playing').addClass('play-icon-paused')	
	jQuery('.track' + trackId + albumButton, iframe).removeClass('play-icon-playing').addClass('play-icon-paused')	
}

function stopPlayButton(){
	
	jQuery('.track' + trackId + ', .play').removeClass('play-icon-playing').addClass('play-icon-stopped')	
	jQuery('.track' + trackId + albumButton, iframe).removeClass('play-icon-playing').addClass('play-icon-stopped')	
}


function startPlayButton(){
	
	 jQuery('.track' + trackId + ', .play').removeClass('play-icon-paused').addClass('play-icon-playing')	
	 jQuery('.track' + trackId + albumButton, iframe).removeClass('play-icon-paused').addClass('play-icon-playing')
	
}

function removeOldPlayButton(){
		
	 jQuery('.track' + trackId + ', .play').removeClass('play-icon-paused').removeClass('play-icon-hover').removeClass('play-icon-loaded').removeClass('play-icon-playing').removeClass('play-icon-loading').removeClass('play-icon-disabled');	
	 jQuery('.track' + trackId + albumButton, iframe).removeClass('play-icon-paused').removeClass('play-icon-hover').removeClass('play-icon-loaded').removeClass('play-icon-playing').removeClass('play-icon-loading').removeClass('play-icon-disabled');
	 
	 //playButton = undefined
	 //albumButton = ''
}


function showPlayButtonLoading(){
	
	
	 jQuery('.track' + trackId + ', .play').addClass('play-icon-loading').addClass('play-icon-disabled')
	 jQuery('.track' + trackId + albumButton, iframe).addClass('play-icon-loading').addClass('play-icon-disabled').addClass('play-icon-disabled')	
}

function showPlayButtonStart(){
	 jQuery('.track' + trackId + albumButton, iframe).removeClass('play-icon-loading').removeClass('play-icon-disabled').addClass('play-icon-playing')
	 jQuery('.track' + trackId + ', .play').removeClass('play-icon-loading').removeClass('play-icon-paused').removeClass('play-icon-playing').removeClass('play-icon-disabled').addClass('play-icon-playing')
	 //jQuery(playerButton).removeClass('play-icon-loading').addClass('play-icon-playing')	
 	//.removeClass('play-icon-loading').addClass('play-icon-playing')	
}

 
function togglePlayButton(){
	  if(playButton.hasClass('play-icon-playing')){//check if playing then pause
		 pausePlayButton();
	  }else if(playButton.hasClass('play-icon-paused')){//check  if paused then play
		  startPlayButton()
	  }
}
function copyPlayState(){
	/*document.getElementById('iframe').onload = function(){
		//alert('test')
		//iframeUrl = iframe.location.href.replace('http://www.hmhosting.com/islam/index.php?', '')
		url	=	iframe.location.href.replace('http://www.hmhosting.com/islam/index.php?', '')

		
		if(url !== window.location.hash.replace('#/', '')){
			//Hash.go(url)
		}
		
		
			if(playButton!==undefined){
	 if(playButton.hasClass('play-icon-playing')){//check if playing then pause
		startPlayButton()
	  }else if(playButton.hasClass('play-icon-paused')){//check  if paused then play
 		pausePlayButton();	  
 		}
		}
		
		changePageUrl()

	}
	
	*/

}

function togglePlayState(){
	if(playButton!==undefined){
	  if(playButton.hasClass('play-icon-playing')){//check if playing then pause
		  player.pause(); pausePlayButton();
	  }else if(playButton.hasClass('play-icon-paused')){//check  if paused then play
		  player.play(); startPlayButton()
	  }else if(playButton.hasClass('play-icon-stopped')){//check  if paused then play
		  player.play(); startPlayButton()
	  }

	  }
}

function playAlbum(el){
	
	var addNewItem = false
	if(albumId!==undefined){
			
			newAlbumId = getAlbumId(jQuery(el))
			oldAlbumId = albumId
			
			if (oldAlbumId==newAlbumId){//Same button change pause play state
			
				togglePlayState()
			}else{//Different button add to playlist and change current playing button to normal
			
				removeOldPlayButton()
				addNewItem = true
				albumId = getId(jQuery(el))
				albumButton = ', .play-icon-large.album' + albumId
			}
			
	}else{
			
			//create new playlist
			albumId = getId(jQuery(el))
			albumButton = ', .play-icon-large.album' + albumId
			addNewItem	 = true
					
		}
		
		if (addNewItem){
		
		
		albumId = getAlbumId(jQuery(el))
		albumButton = ', .play-icon-large.album' + albumId
	
	
		
	showPlayButtonLoading()
	jQuery.ajax({
				url: "playlist.php",
				data: {id: albumId, a: "album"},
				success: function(xml){
					

					trackDetails = []
					
					
					jQuery(xml).find('track').each(function(i){
						var track = jQuery(this)
						var track_id = track.attr('id')
						var track_title = track.attr('title')
						var artist = track.attr('artist_name')
						var track_file = track.text()
						var track_duration = track.attr('duration')
						var album_id = jQuery(xml).find('album').attr('id');
						//alert(jQuery('#playlist .track'+track_id).html())
						
						trackDetails.push({artist: artist, file: track_file, duration: track_duration, id: track_id, title: track_title, albumId: album_id})
					})
					

					
					addAlbumToPlaylist(trackDetails)	
										
				},
				error: function(xhr){
						alert(xhr.responseText)
				}	
			})
		}
}

function play(){
		
		
		el = jQuery(this)
		var addNewItem = false
		//PLAY:PAUSE
		if(playButton!==undefined){
			
			newPlayButton = el
			newTrackId = getId(newPlayButton)
			oldPlayButton = playButton
			oldTrackId = getId(oldPlayButton)
			if (oldTrackId==newTrackId){//Same button change pause play state
				togglePlayState()
			}else{//Different button add to playlist and change current playing button to normal
				
				removeOldPlayButton()
				addNewItem = true
				playButton = newPlayButton
				trackId = newTrackId
				
			}
			
		//ADD
		}else{
			//stopPlayer()
			//create new playlist
			playButton = el
			trackId = getId(playButton)
			addNewItem	 = true
					
		}
		if (addNewItem){
			showPlayButtonLoading()
			jQuery.ajax({
				url: "playlist.php",
				data: {id: trackId, a: 'track'},
				success: function(xml){
					

					trackDetails = []
					
					
					jQuery(xml).find('track').each(function(i){
						var track = jQuery(this)
						var track_id = track.attr('id')
						var track_title = track.attr('title')
						var track_file = track.text()
						var track_duration = track.attr('duration')
						var album_id = jQuery(xml).find('album').attr('id');
						var artist_name = track.attr('artist_name');
						//alert(jQuery('#playlist .track'+track_id).html())
						
						trackDetails.push({artist: artist_name, file: track_file, duration: track_duration, id: track_id, title: track_title, albumId: album_id})
					})
					
		
						addToPlayList(trackDetails[0])
															
				},
				error: function(xhr){
						alert(xhr.responseText)
				}	
			})
		}
		
}

function initiate(){

jwplayer('container').setup({
flashplayer: "includes/player.swf",
/*playlist: [
{  file: "video.mp4", image: "preview.jpg"},
{ file: "demosong01.mp3"}
],
"playlist.position": "right",*/
plugins: {
//	'yourlytics-1': { 'callback': 'http://hmhosting.com/mediaplayer-5.3/tracking.php'}
	'includes/counttrackula.swf': { dom: 'http://islamise.co.uk/tracking.php', prevsecs:3}

//	'madlytics-1': {'callbacklistener' : 'http://hmhosting.com/mediaplayer-5.3/tracking.php', 'completedpoint': 3}
},
height: 1,
width: 1,
events: {
	onPlay: togglePlayStart ,
	onComplete: togglePlayFinish,
	onTime: timelisten,
	onError: jwError,
	onReady: playReady
}
});	
player = jwplayer()

function jwError(error){
	alert(error.message)	
}

function playReady(){
	//buildPlaylist()
	//jQuery('#volume').slider( "option", "value", player.getVolume() );
	jQuery('.play-icon, .play, .play-icon-large').removeClass('play-icon-disabled')
	jQuery('#volume-ico').bind('mouseover mouseout', 
	function(event){
		if (event.type == 'mouseover') {
			
			jQuery('#vol-container').show()
			jQuery('body').bind('click', hideVolume)
	
		}
		else if(event.type == 'mouseout'){
			//jQuery('body').unbind()
			//jQuery(this).removeClass('play-icon-hover')
		}
	})
	
	
	jQuery("#volume").slider({

			value: player.getVolume(),
			orientation: "vertical",
			range: "min",
			animate: false
		});
}

		
	jQuery("#progress" ).slider({
			value: 0,
			orientation: "horizontal",
			range: "min",
			animate: false/*,
			disabled: true*/
		}).bind( "slide", function(event, ui) {
		
		var duration = player.getDuration()
		position = (duration/100) * ui.value
		player.seek(position)
		
});
	
		jQuery( "#volume" ).bind( "slide", function(event, ui) {
		
		player.setVolume(ui.value)
		
});
	
    
}

function hideVolume(){
		jQuery('#vol-container').hide()
		jQuery('body').unbind()
}

function seek(seconds){
		
		duration = player.getDuration()
		
		position = (duration/100) * seconds
		player.seek(position)	
}

function secondsToHms(d) {
	d = Number(d);
	var h = Math.floor(d / 3600);
	var m = Math.floor(d % 3600 / 60);
	var s = Math.floor(d % 3600 % 60);
	return ((h > 0 ? h + ":" : "") + (m > 0 ? (h > 0 && m < 10 ? "0" : "") + m + ":" : "0:") + (s < 10 ? "0" : "") + s);
}
	
	
function togglePlayFinish(){
	 //player.stop()
	 playItem('next')
	 //removeOldPlayButton()
	 
}	

function testMad(obj){
	alert('works')	
}	

function playItem(type){
	var itemOperand = +1;
	switch(type){
		case "next":
			itemOperand = +1; break;
		case "prev":
			itemOperand = -1; break;
	}	
	
	var nextPlaylistIndex	
	var playlistLength = jQuery('#playlist .item').length-1
	var currentPlayButtonIndex = jQuery('#playlist .item .play-icon').index(jQuery('#playlist .item .play-icon-playing, #playlist .item .play-icon-loading'))
	if(playlistLength>0){
		if(playlistLength==currentPlayButtonIndex){//is the last item in the playlist, return to first item
			//nextPlaylistIndex = 0
			stopPlayer()
		}else{
			nextPlaylistIndex = currentPlayButtonIndex + itemOperand
		}
	}else{
		switch(type){
		case "prev":
			player.seek(0);break;
		default:
			stopPlayer();break;
		}	
		
	}
	
	if (nextPlaylistIndex!==undefined)
		jQuery('#playlist .item .play-icon:eq(' + nextPlaylistIndex + ')').click()
	
}


function timelisten(duration){
	duration1 = player.getDuration()
	durationPercentage = (duration.position*100)/duration1
	jQuery('#current-position').html(secondsToHms(duration.position))
	jQuery('#progress').slider('value', durationPercentage)
	jQuery('#duration').html(secondsToHms(Math.round(duration1)))
}


function togglePlayStart(){
	
	
	
	//duration = Math.round(player.getPlaylistItem().duration)
	showPlayButtonStart()
	var playlistItems = jQuery("#playlist .item").length
	
	var currentPlayItem = jQuery('#playlist .item .play-icon-playing').parent().next()
	jQuery('.playing').html(currentPlayItem.html())
	jQuery('.playing-artist').html("Artist: " + currentPlayItem.next().html())
	//jQuery('.playing-album').css("background", "url(" +  + ")")

	if(playlistItems<1)
		jQuery('.empty').show().html("Your playlist is empty")
	else
		jQuery('.empty').hide()
	/*playButton.removeClass('play-icon-loading').addClass('play-icon-playing').unbind().bind('click', function(){
		if (playButton.hasClass('play-icon-playing')){
		  	player.pause();  playButton.removeClass('play-icon-playing').addClass('play-icon-paused')
	   }
          else
		{
             player.play();  playButton.removeClass('play-icon-paused').addClass('play-icon-playing')
		}
	})*/
	//jQuery('#duration').html(duration)
}	

function showPlaylist(){
	//jQuery('.item').toggle()
	
	/*jQuery('#playlistItems').toggle();
	var class1 = jQuery('#header').attr('class');
	if(class1=='normal'){jQuery('#header').addClass('expanded').removeClass('normal')}else if(class1=='expanded'){jQuery('#header').removeClass('expanded').addClass('normal')}
	*/
}

/*!
 * Copyright (c) 2009 Andreas Blixt <andreas@blixt.org>
 * Contributors: Aaron Ogle <aogle@avencia.com>,
 *               Matti Virkkunen <mvirkkunen@gmail.com>
 * This and more JavaScript libraries: http://blixt.org/js
 * MIT License: http://www.opensource.org/licenses/mit-license.php
 * 
 * Hash handler
 * Keeps track of the history of changes to the hash part in the address bar.
 */
/* WARNING for Internet Explorer 7 and below:
 * If an element on the page has the same ID as the hash used, the history will
 * get messed up.
 *
 * Does not support history in Safari 2 and below.
 * 
 * Example:
 *     function handler(newHash, initial) {
 *         if (initial)
 *             alert('Hash is "' + newHash + '"');
 *         else
 *             alert('Hash changed to "' + newHash + '"');
 *     }
 *     Hash.init(handler, document.getElementById('hidden-iframe'));
 *     Hash.go('abc123');
 * 
 * Updated by Matti Virkkunen (mvirkkunen@gmail.com) on 2009-11-16:
 *   - Added second argument to callback that indicated whether the callback is due
 *     to initial state (true) or due to an actual change to the hash (false).
 * 
 * Updated by Aaron Ogle (aogle@avencia.com) on 2009-08-11:
 *   - Fixed bug where Firefox automatically unescapes location.hash but no other
 *     browsers do. Always get the hash by parsing location.href and never use
 *     location.hash.
 */

var Hash = (function () {
var
// Import globals
window = this,
documentMode = document.documentMode,
history = window.history,
location = window.location,
// Plugin variables
callback, hash,
// IE-specific
iframe,

getHash = function () {
    // Internet Explorer 6 (and possibly other browsers) extracts the query
    // string out of the location.hash property into the location.search
    // property, so we can't rely on it. The location.search property can't be
    // relied on either, since if the URL contains a real query string, that's
    // what it will be set to. The only way to get the whole hash is to parse
    // it from the location.href property.
    //
    // Another thing to note is that in Internet Explorer 6 and 7 (and possibly
    // other browsers), subsequent hashes are removed from the location.href
    // (and location.hash) property if the location.search property is set.
    //
    // Via Aaron: Firefox 3.5 (and below?) always unescape location.hash which
    // causes poll to fire the hashchange event twice on escaped hashes. This is
    // because the hash variable (escaped) will not match location.hash
    // (unescaped.) The only consistent option is to rely completely on
    // location.href.
    var index = location.href.indexOf('#');
    return (index == -1 ? '' : location.href.substr(index + 1));
},

// Used by all browsers except Internet Explorer 7 and below.
poll = function () {
    var curHash = getHash();
    if (curHash != hash) {
        hash = curHash;
        callback(curHash, false);
    }
},

// Used to create a history entry with a value in the iframe.
setIframe = function (newHash) {
    try {
        var doc = iframe.contentWindow.document;
        doc.open();
        doc.write('<html><body>' + newHash + '</body></html>');
        doc.close();
        hash = newHash;
    } catch (e) {
        setTimeout(function () { setIframe(newHash); }, 10);
    }
},

// Used by Internet Explorer 7 and below to set up an iframe that keeps track
// of history changes.
setUpIframe = function () {
    // Don't run until access to the iframe is allowed.
    try {
        iframe.contentWindow.document;
    } catch (e) {
        setTimeout(setUpIframe, 10);
        return;
    }

    // Create a history entry for the initial state.
    setIframe(hash);
    var data = hash;

    setInterval(function () {
        var curData, curHash;

        try {
            curData = iframe.contentWindow.document.body.innerText;
            if (curData != data) {
                data = curData;
                location.hash = hash = curData;
                callback(curData, true);
            } else {
                curHash = getHash();
                if (curHash != hash) setIframe(curHash);
            }
        } catch (e) {
        }
    }, 50);
};

return {
    init: function (cb, ifr) {
        // init can only be called once.
        if (callback) return;

        callback = cb;

        // Keep track of the hash value.
        hash = getHash();
        cb(hash, true);

        // Run specific code for Internet Explorer.
        if (window.ActiveXObject) {
            if (!documentMode || documentMode < 8) {
                // Internet Explorer 5.5/6/7 need an iframe for history
                // support.
                iframe = ifr;
                setUpIframe();
            } else  {
                // Internet Explorer 8 has onhashchange event.
                window.attachEvent('onhashchange', poll);
            }
        } else {
            // Change Opera navigation mode to improve history support.
            if (history.navigationMode) history.navigationMode = 'compatible';

            setInterval(poll, 50);
        }
    },

    go: function (newHash) {
        // Cancel if the new hash is the same as the current one, since there
        // is no cross-browser way to keep track of navigation to the exact
        // same hash multiple times in a row. A wrapper can handle this by
        // adding an incrementing counter to the end of the hash.
        if (newHash == hash) return;
        if (iframe) {
            setIframe(newHash);
        } else {
            location.hash = hash = newHash;
            callback(newHash, false);
        }
    }
};
})();


