if(window.location.hostname == 'webserver'){
	var myFolder = 'http://webserver/diamond_e-directory/';
}else{
	var myFolder = 'http://diamondedirectory.com/';
}

jQuery.extend( jQuery.easing, {
	easeInOutQuint: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
		return c/2*((t-=2)*t*t*t*t + 2) + b;
	},
	easeInQuint: function (x, t, b, c, d) { return c*(t/=d)*t*t*t*t + b; },
	easeOutQuint: function (x, t, b, c, d) { return c*((t=t/d-1)*t*t*t*t + 1) + b; }
});

function css_load(file){
	css = $('<link></link>');
	$('head').append(css);
	$(css).attr({type:'text/css',rel:'stylesheet',href:file});
}

function addslashes(str) {
	str=str.replace(/\\/g,'\\\\');
	str=str.replace(/\'/g,'\\\'');
	str=str.replace(/\"/g,'\\"');
	str=str.replace(/\0/g,'\\0');
return str;
}
function stripslashes(str) {
	str=str.replace(/\\'/g,'\'');
	str=str.replace(/\\"/g,'"');
	str=str.replace(/\\0/g,'\0');
	str=str.replace(/\\\\/g,'\\');
return str;
}

function set_wmode(){
	objs = document.getElementsByTagName('object');
	for(i=0;i<objs.length;i++)
	{
		for(n=0;n<objs[i].getElementsByTagName('param').length;n++)
		{
			if(objs[i].getElementsByTagName('param')[n].getAttribute('name') != 'wmode' && objs[i].getElementsByTagName('param')[n].getAttribute('value') != 'transparent')
			{
				new_node = objs[i].cloneNode(true);
				param = document.createElement('param');
				param.setAttribute('name','wmode');
				param.setAttribute('value','transparent');
				new_node.appendChild(param);
				if(new_node.getElementsByTagName('embed')[0])
				{
					new_node.getElementsByTagName('embed')[0].setAttribute('wmode','transparent');
				}
				objs[i].parentNode.replaceChild(new_node, objs[i]);
				break;
			}
		}
	}
}

function getVariables(id) // Gets the aff_id from the javascript script src
{
	query_string = document.getElementById(id).src.split('?')[1];
	vars = Object();
	if(query_string.search != -1)
	{
		variables = query_string.split('&');
		for(z=0;z<variables.length;z++)
		{
			vars[variables[z].split('=')[0]] = variables[z].split('=')[1];
		}
	}	
	hash = vars['hash'];
}

/*function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}*/

/////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////
// CODE STARTS HERE ALL ABOVE ARE LIBS
/////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////

/*
function content_in(){
	$('#hd_dock').css({width:"100%",height:"100%"});
	offset = $('#hd_menu').offset();
	$('#hd_shade').animate({ opacity: 0 }, 800, 'easeInOutQuint');
	$('#hd_content').animate({ opacity: 1 }, 800, 'easeInOutQuint');
	$('#hd_menu').animate({ right: offset.left-8 }, 800, 'easeInOutQuint', function(){
		$(this).css({ left: 18 });
	});
	
	//hiddeniframe = '<iframe';
	//hiddeniframe += ' id="iframe_behind" name="iframe_behind"';
	//hiddeniframe += ' src="'+myFolder+'transparent.php" allowTransparency="true" frameborder="0"';
	//hiddeniframe += ' style="';
		//hiddeniframe += 'width:'+$('#hd_dock').width()+'px;height:'+$('#hd_dock').height()+'px;';
		//hiddeniframe += 'position:absolute;top:0px;left:0px;z-index:10000000;';
	//hiddeniframe += '"></iframe>';
	
	//if($('#iframe_behind').attr('id') == null)
	//{
		//$(hiddeniframe).prependTo('#hd_dock');
	//}
}*/
function content_in()
{
	$('#hd_dock').css({width:"100%",height:"100%"});
	$('#hd_content').animate({ opacity: 1 }, 800, 'easeInOutQuint');
	$('#hd_menu').animate({ opacity: 1 }, 800, 'easeInOutQuint');
}

/*
function content_out(){
	//offset = $('#hd_menu').offset();
	$('#hd_shade').animate({ opacity: 0 }, 800, 'easeInOutQuint');
	$('#hd_content').animate({ opacity: 0 }, 800, 'easeInOutQuint');
	$('#hd_dock').css({width:"0px",height:"0px"});
	$('#hd_menu').css({ left: 'auto' }).animate({ right: 20 }, 800, 'easeInOutQuint', function(){
		$(this).css({ right: 20 });
	});
	
	$('#iframe_behind').remove();
}
*/

function content_out(){
	$('#hd_content').animate({ opacity: 0 }, 800, 'easeInOutQuint');
	$('#hd_dock').css({width:"0px",height:"0px"});
	$('#iframe_behind').remove();
	$('#hd_dock').css('visibility', 'hidden');
}

function menu_out(dockTitle){
	
	$('#hd_dock').css('visibility', 'visible');
	///$('#hd_dock').animate({ opacity: 1 }, 400, 'easeInOutQuint');
	
	$('#oc_btn').fadeOut(250, function(){
		$('#oc_btn').children('img').attr('src',myFolder+'i/oc_close.gif');	
		$('#oc_btn').fadeIn(250);
	});
	
	//$('#hd_menu').animate({ height: 31 }, 400, 'easeInOutQuint', function(){
		//$('#oc_vert_title').hide();
		//$('#hd_menu').animate({ width: 169, height: $('#hd_nav_con').height() + 50 }, 800, 'easeOutQuint', function(){
			$('#hd_menu').animate({ width: 169, height: 464 }, 400, 'easeOutQuint', function(){	
				$('#hd_nav_con').fadeIn(250);
			});
		//});
	//});
	
	hd_menu_head = '<div id="hd_title">'+dockTitle+'</div>';
	$(hd_menu_head).appendTo('#hd_menu_head');
	
	mHeight = $('#hd_nav_con').height() + 50;
	mWidth = $('#hd_nav_con').width() + 20;
}

function menu_out_timed(dockTitle)
{
	menu_out(dockTitle);
	timeoutID = setTimeout("menu_in()",5000);
	$('#hd_dock').mouseover(function(){
		clearTimeout(timeoutID);
	});
}

function menu_in(){
	$('#oc_btn').fadeOut(250, function(){
		$('#oc_btn').children('img').attr('src',myFolder + 'i/oc_open.gif');
		$('#oc_btn').fadeIn(250);
	});
	$('#hd_nav_con').fadeOut(250, function(){
		$('#hd_menu').animate({ width: 31, height: 31 }, 800, 'easeInOutQuint', function(){
			//$('#oc_vert_title').show();
			//$('#hd_menu').animate({ height: 200 }, 400, 'easeOutQuint');
			$('#hd_title').remove();
			
			$('#iframe_behind_menu').css({width: 30, height: 200});
			
			if($('#hd_content').css('opacity') == 0)
			{
				$('#hd_dock').css('visibility', 'hidden');
			}
		});
	});
}

function init_menu_toggle(dockTitle){
	$('#oc_btn').click(function(){
		if($('#oc_btn').children('img').attr('src') == myFolder+'i/oc_open.gif')
		{
			menu_out(dockTitle);
		}
		else
		{
			menu_in();
		}
	});
}

function init_dock(dockTitle){
	$('<div id="hd_dock"></div>').prependTo('body');
	$('<div id="hd_shade"></div>').css({ opacity:0 }).appendTo('#hd_dock');
	$('<div id="hd_content"></div>').css({ opacity:0 }).prependTo('#hd_dock');
	
	$('#hd_dock').css({'width':'0px','height':'0px'});
	
	hd_con_bar = '<div id="hd_con_bar">';
		hd_con_bar += '<a id="hd_bar_close" href="javascript:void(0);"></a>';
		hd_con_bar += '<div style="clear:both;"></div>';
	hd_con_bar += '</div>';
	$(hd_con_bar).appendTo('#hd_content');
	$('#hd_bar_close').click(function(){ content_out() });
	
	hd_con_frame = '';
	hd_con_frame += '<div id="hd_con_frame">';
		hd_con_frame += '<div id="hd_con_frame_con"></div>';
		hd_con_frame += '<div style="clear:both;"></div>';
	hd_con_frame += '</div>';
	$(hd_con_frame).appendTo('#hd_content');
	
	offset = $('#hd_con_frame').offset();
// FIND ME
//	$('#hd_con_frame, #hd_con_frame_con').height($(window).height()-(offset.top+50));
	
	hd_menu = $('<div id="hd_menu"></div>');
	$(hd_menu).appendTo('#hd_dock');
	
	hd_menu_head = '<div id="hd_menu_head">';
		hd_menu_head += '<div id="oc_btn">';
			hd_menu_head += '<img src="'+myFolder+'i/oc_open.gif" />';
		hd_menu_head += '</div>';
	hd_menu_head += '</div>';
	$(hd_menu_head).appendTo('#hd_menu');
	
	oc_vert_title = '<div id="oc_vert_title"><img src="'+myFolder+'name.image.php?txt='+dockTitle+'" /></div>';
	$(oc_vert_title).appendTo('#hd_menu');
	
	//menu_out(dockTitle);
}

function init_menu(strUrl,strHash,myTitle){
	//hd_menu_head = '<div id="hd_title">My Schools Tools</div>';
	//$(hd_menu_head).appendTo('#hd_menu_head');
	
	$.getJSON(myFolder+'feeds/partner.feed.php?callback=?&url='+strUrl+'&hash='+strHash, function(data)
	{
		hd_nav_con = '';
		hd_nav_con += '<div id="hd_nav_con">';
			hd_nav_con += '<div id="hd_special">';
			hd_nav_con += '</div>';
			hd_nav_con += '<div id="hd_nav">';
				hd_nav_con += '<div>';
				hd_nav_con += '</div>';
			hd_nav_con += '</div>';
			hd_nav_con += '<a target="_blank" class="bug_link" href="http://diamondedirectory.com/support.php">Found a Bug? Click to Report</a>';
		hd_nav_con += '</div>';
		$(hd_nav_con).appendTo('#hd_menu');
		
		first = false;
		if(data.partner[0] != undefined)
		{
			for(v in data.partner)
			{
				hd_nav_con = '';
				if(first === true){hd_nav_con += '<div style="height:10px"></div>';}
				hd_nav_con += '<a class="hd_nav_site" target="hd_hiddenframe"';
					hd_nav_con += ' href="javascript:void(0);" onclick="init_website(\''+data.partner[v].url+'\',\'I\');">';
						hd_nav_con += '<img src="'+myFolder+data.partner[v].image+'" border="0" />';
				hd_nav_con += '</a>';
				$(hd_nav_con).appendTo('#hd_special');
				first = true;
			}
		}
		init_menu_categories(strUrl,strHash,myTitle);
	});
}

function init_menu_categories(strUrl,strHash,myTitle){
	hd_nav_con = '';
	$.getJSON(myFolder+'feeds/categories.feed.php?callback=?&url='+strUrl+'&hash='+strHash, function(data)
	{
		for(v in data.menu)
		{
			hd_nav_con += '<a class="hd_nav_cat" href="javascript:void(0);">'+data.menu[v].name+'</a>';
			hd_nav_con += '<div class="hd_nav_sub">';
			for(z in data.menu[v].sub)
			{
				hd_nav_con += '<a';
					hd_nav_con += ' class="hd_nav_link"';
//					hd_nav_con += ' cat_parent_name="' + data.menu[v].name + '"';
//					hd_nav_con += ' cat_parent="' + data.menu[v].id + '"';
//					hd_nav_con += ' cat="' + data.menu[v].sub[z].id + '"';
//					hd_nav_con += ' href="javascript:void(0);"';
					hd_nav_con += ' href="javascript:init_content_feed(\''+strUrl+'\',\''+strHash+'\',\''+data.menu[v].id+'\',\''+data.menu[v].sub[z].id+'\',\''+escape(data.menu[v].sub[z].name)+'\',\''+escape(data.menu[v].sub[z].disclaimer)+'\',\''+escape(data.menu[v].name)+'\')"';
//					hd_nav_con += ' cat_name="'+data.menu[v].sub[z].name+'"';
					hd_nav_con += '>'+data.menu[v].sub[z].name+'</a>';
			}
			hd_nav_con += '</div>';
		}
		$(hd_nav_con).appendTo('div#hd_nav > div');
		
		$.each($('.hd_nav_cat'), function(){
			$(this).next().hide();
			$(this).click(function(){
				$(this).next().siblings('div').slideUp();
				$(this).next().slideToggle();
			});
		});
		/*
		$.each($('.hd_nav_link'), function(){
			$(this).click(function(){
				t = $(this);
				//$('#hd_con_frame_con').fadeOut('slow', function(){
					content_in();
					//hd_con_frame = '<div id="hd_feed"></div>';
					//$('#hd_con_frame_con').html(hd_con_frame);
					$('#hd_bar_traceback').html(t.attr('cat_parent_name') + ' > ' + t.attr('cat_name'));
					init_content_feed(strUrl,strHash,t.attr('cat_parent'),t.attr('cat'),t.attr('cat_name'),t.attr('cat_parent_name'));
				//});
			});
		});
		*/
		//menu_out_timed(myTitle);
	});
	
	$('#hd_dock').css('visibility', 'hidden');
}

function html_entity_decode(str)
{
	ta = str.replace(/&#47;/,"/");
	return ta;
}

function init_content_feed(strUrl,strHash,cat_parent,cat,cat_name,cat_disclaimer,cat_parent_name){

	dock_data.history.strUrl = strUrl;
	dock_data.history.strHash = strHash;
	dock_data.history.cat_parent = cat_parent;
	dock_data.history.cat = cat;
	dock_data.history.cat_name = cat_name;
	dock_data.history.cat_disclaimer = cat_disclaimer;
	dock_data.history.cat_parent_name = cat_parent_name;
	
	site_count_val = 0;
	content_in();
	$('#hd_bar_traceback').html( cat_parent_name + ' > ' + cat_name);
	
	$.getJSON(myFolder+'feeds/site.feed.php?callback=?&cat_parent='+cat_parent+'&cat='+cat+'&url='+strUrl+'&hash='+strHash, function(data)
	{
		hd_con = '';
		hd_con += '<div id="hd_feed">';
		hd_con += '<div id="hd_content_site">';
			hd_con += '<div class="header">';
				hd_con += '<div style="font-family:arial;font-size:16px;color:#333;width:400px;padding:18px;float:left;">';
					hd_con += cat_parent_name + ' > ' + cat_name;
				hd_con += '</div>';
				hd_con += '<div style="padding: 5px; width:300px;float: right;color: #B0001B;">';
					hd_con += cat_disclaimer;
				hd_con += '</div>';
			hd_con += '</div>';
			for(v in data.site)
			{
				site_count_val++;
				hd_con += '<div class="site_link_con">';
					if(data.site[v].site_coupon_url != ''){
						// COUPON GOES HERE
						hd_con += '<a href="'+data.site[v].site_coupon_url+'" target="_blank" class="coup_link" site_id="'+data.site[v].site_id+'">';
							hd_con += '<img src="'+myFolder+'i/coup_icon.gif" border="0" /><span>Coupon</span>';
						hd_con += '</a>';
					}
					hd_con += '<a site_id="'+data.site[v].site_id+'" class="site_link" style="display:block;height:105px;width:140px;position:relative;"';
					site_open = data.site[v].site_open;
					if(site_open == 'I'){
						hd_con += ' target="hd_hiddenframe" href="javascript:void(0);"';
					}else{
						hd_con += ' target="_blank" href="'+data.site[v].site_url+'"';
					}
/*
// Did this in the site.feed.php file instead
					if(data.site[v].site_capture != 'http://' || data.site[v].site_capture != ''){
						site_url = data.site[v].site_capture;
					}else{
						site_url = data.site[v].site_url;
					}
*/					hd_con += ' onclick="init_website(\''+data.site[v].site_url+'\',\''+site_open+'\',\''+addslashes(data.site[v].site_disclaimer)+'\');"';
					hd_con += '>';
					
						if(data.site[v].site_image == '')
						{
							hd_con += '<table height="100%" width="100%" border="0" style="background:#fff;"><tr><td align="center" valign="middle" style="color:#333;font-size:14px;" class="tip" tip="' + data.site[v].site_description + '">'+ data.site[v].site_name +'</td></tr></table>';
						}
						else if(data.site[v].site_image != '' && data.site[v].site_image_selected == '1')
						{
							hd_con += '<img class="tip" tip="' + data.site[v].site_description + '" src="';
								hd_con += data.site[v].site_image;
							hd_con += '" border="0" />';
						}
						else
						{
							hd_con += '<img class="tip" tip="' + data.site[v].site_description + '" src="';
								hd_con += data.site[v].site_image;
							hd_con += '" border="0" />';
							hd_con += '<div class="site_link_name" style="padding:3px 5px;position:absolute;width:130px;top:81px;left:0;">'+ data.site[v].site_name +'</div>';
						}
						
						
					hd_con += '</a>';
				hd_con += '</div>';
			}
			hd_con += '<span style="display:block;clear:both;height:12px;"></span>';
		hd_con += '</div>';
		hd_con += '</div>';
		$('#hd_con_frame_con').html(hd_con);
		
		//console.log('site_count:'+site_count_val);
		//console.log('hd_content_site (size) W:'+$('#hd_content_site').width()+' H:'+$('#hd_content_site').height());
		//console.log('site_link_con (size) W:'+$('.site_link_con').width()+' H:'+$('.site_link_con').height());
		
		viewable_blocks = Math.ceil($('#hd_content_site').width() / $('.site_link_con').width());
		viewable_height = Math.ceil(site_count_val / viewable_blocks);
		
//		alert( $('#hd_content_site').height() );
		//$('#hd_content_site').attr('height',((viewable_height * $('.site_link_con').height()) + (viewable_height * 10) + 10));
		//$('#hd_feed').attr('height',((viewable_height * $('.site_link_con').height()) + (viewable_height * 10) + 200));
		//$('#hd_con_frame_con').attr('height',((viewable_height * $('.site_link_con').height()) + (viewable_height * 10) + 200));
		//$('#hd_con_frame').attr('height',((viewable_height * $('.site_link_con').height()) + (viewable_height * 10) + 200));
//		alert( $('#hd_feed').height() );
		
		// Code for coupons
		$(".coup_link").hover(
			function(){
				$(this).animate({ width: $(this).parent().width()-6 }, "normal", "easeInOutQuint");
			},
			function(){
				$(this).animate({ width: 26 }, "normal", "easeInOutQuint");
			}
		);
		
		init_banner(strUrl,strHash,cat_parent,cat);
		
		$('#hd_con_frame').fadeIn('slow');
		
		$.each($('.site_link'), function(){
			$(this).mouseup(function(){
//				content_in();
//				$('#hd_feed').hide();
//				$('#hd_iframe').show();
				$.getJSON(myFolder+'feeds/site.feed.php?callback=?&act=click&id='+$(this).attr('site_id')+'&url='+strUrl+'&hash='+strHash, function(data){ });
			});
		});
		
		$.each($('.coup_link'), function(){
			$(this).mouseup(function(){
//				content_in();
//				$('#hd_feed').hide();
//				$('#hd_iframe').show();
				$.getJSON(myFolder+'feeds/site.feed.php?callback=?&act=coupon&id='+$(this).attr('site_id')+'&url='+strUrl+'&hash='+strHash, function(data){ });
			});
		});
		
		$(".tip").each(function(){
			$(this).mouseover(function(){
				$tip = $('<div class="tip_box">'+$(this).attr("tip")+'</div>');
				$tip.css({position: "absolute","z-index":100000000});
				$tip.prependTo("body");	
				offset = $(this).offset();
				$tip.css({ left: (offset.left+($(this).outerWidth()/2)-($tip.outerWidth()/2)), top: offset.top-($tip.outerHeight()), opacity: 0 });
				$tip.animate({
					"top": offset.top-($tip.outerHeight()+10),
					"opacity": "1"
				}, 500);
			}).mouseout(function(){
				$tip.animate({
					"top": offset.top-($tip.outerHeight()+5),
					"opacity": "0"
				}, 500, function(){
					$(".tip_box:last").remove();
				});
			});
		});
	});
}

function init_website(url,openstate,disclaimer)
{
	if(disclaimer != '')
	{
		alert(stripslashes(disclaimer));
	}
	if(openstate == 'I')
	{
		content_in();
		iframe = '<div id="hd_con_frame_head" style="height:30px;background:#777;line-height:30px;padding-left:50px;color:#fff;">';
			iframe += '<a id="hd_con_frame_head_back" ';
			iframe += 'href="javascript:init_content_feed(\''+dock_data.history.strUrl+'\',\''+dock_data.history.strHash+'\',\''+dock_data.history.cat_parent+'\',\''+dock_data.history.cat+'\',\''+dock_data.history.cat_name+'\',\''+escape(dock_data.history.cat_disclaimer)+'\',\''+dock_data.history.cat_parent_name+'\');" onclick="menu_out(\''+dock_data.title+'\');"></a>&nbsp;&nbsp;&nbsp;'+url+'</div>';
		iframe += '<iframe id="hd_iframe" src="'+url+'" allowTransparency="true"';
		iframe += ' frameborder="0" style="width:100%;height:'+($(window).height()-100)+'px;background:#FFF;z-index:-10000000;"></iframe>';
		iframe += '<iframe id="hd_hiddenframe" name="hd_hiddenframe" style="width:0px;height:0px;"></iframe>';
		$('#hd_con_frame_con').html(iframe);
//	$('#hd_con_frame_con').show();
		$(".tip_box").remove();
		menu_in();
		$('#hd_feed').hide();
		$('#hd_iframe').show();
	}
}

function init_banner(strUrl,strHash,cat_parent,cat){
	$.getJSON(myFolder+'feeds/banner.feed.php?callback=?&cat_parent='+cat_parent+'&cat='+cat+'&url='+strUrl+'&hash='+strHash, function(data)
	{
		if(data.url)
		{
			if($('#hd_content_banner').html() == null)
			{
			hd_con = '';
			hd_con += '<div id="hd_content_banner">';
			hd_con += '<a target="_blank" href="' + data.url + '">';
				hd_con += '<img class="banner_click" src="' + myFolder + data.image + '" border="0" banner_id="'+data.id+'" />';
			hd_con += '</a>';
			hd_con += '</div>';
			$('#hd_feed').prepend(hd_con);
		}}
		
		$("img.banner_click").mousedown(function(){
			$.getJSON(myFolder+'feeds/banner.feed.php?callback=?&act=click&id='+$(this).attr('banner_id')+'&url='+strUrl+'&hash='+strHash, function(data){ });
		});
	});
}

$(document).ready(function(){
	//Set some globals to use throughout the js
	dock_data = new Object();
	dock_data.title;
	dock_data.history = new Object();
		dock_data.history.strUrl;
		dock_data.history.strHash;
		dock_data.history.cat_parent;
		dock_data.history.cat;
		dock_data.history.cat_name;
		dock_data.history.cat_parent_name;
	
	getVariables('diamondedirectory_dock'); // this gets hash
	
	strUrl = window.location.href;
	strQuery = strUrl.split('?')[1];
	strUrl = strUrl.split('/')[2].replace(/www./,"");
	
	gUrlVar = Object();
	if(strQuery)
	{
		strQueryVar = strQuery.split('&');
		for(z=0;z<strQueryVar.length;z++){ gUrlVar[strQueryVar[z].split('=')[0]] = strQueryVar[z].split('=')[1]; }
	}
	if(gUrlVar['preview'])
	{
		strUrl = gUrlVar['preview'];
		satellite_feed = myFolder+'feeds/satellite.feed.php?callback=?&url='+strUrl+'&hash=preview';
	}
	else
	{
		satellite_feed = myFolder+'feeds/satellite.feed.php?callback=?&url='+strUrl+'&hash='+hash;
	}
	
	$.getJSON(satellite_feed, function(data)
	{
		if(data.valid == 'true')
		{
//			console.log(data.valid + ' :: ' + data.title);
			set_wmode();
			css_load(myFolder+'c/dock.css');
			//Set global title variable
			dock_data.title = data.title;
			init_dock(dock_data.title);
			init_menu_toggle(data.title);
			if(data.hash){
				init_menu(strUrl,data.hash,data.title); // data.hash
			}else{
				init_menu(strUrl,hash,data.title);
			}
		}
	});
});
