if (location.host=="go2web20.net"){
	//location.href = "http://www.go2web20.net";
}



function fixObjects(){
	theObjects = document.getElementsByTagName("object");
	for (var i = 0; i < theObjects.length; i++) {
		theObjects[i].outerHTML = theObjects[i].outerHTML;
	}

}

function InsertLogosFlash(url) {
	var id="mainFlash";
	var width="100%";
	var height="100%";
	var wmode="window";

	var html=[];
	html.push('<object id="'+id+'Obj" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" height="'+height+'" width="'+width+'">');
	html.push('<param name="movie" value="'+url+'">');
	html.push('<param name="quality" value="high">');
	html.push('<param name="wmode" value="'+wmode+'">');
	html.push('<param name="menu" value="false">');
	html.push('<embed src="'+url+'" id="'+id+'Emb" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" wmode="'+wmode+'" menu="false" height="'+height+'" width="'+width+'">');
	html.push('</object>');
	document.write(html.join(""));
	if(navigator.userAgent.indexOf("MSIE")>-1){
		flashObj = $(id+'Obj');
	}else{
		flashObj = $(id+'Emb');
	}

};

function reorderLayout(){

	var pageWidth = document.body.offsetWidth;
	var pageHeight = document.body.offsetHeight;
	var infoPanelHeight = $('appFrameHolder').offsetHeight;
	var adsPanelWidth = $('ads').offsetWidth;
	var footerHeight = $('footer').offsetHeight;


	Element.setStyle('flashHolder', {width:(pageWidth-adsPanelWidth)+'px'} );
	Element.setStyle('flashHolder', {height:(pageHeight-footerHeight-infoPanelHeight)+'px'} );
	Element.setStyle('ads', {height:(pageHeight-footerHeight-infoPanelHeight)+'px'} );

}

function showAdsPanel(){
	$('ads').style.visibility="visible"
}


function showAppFrame(appIdOrName) {
	if (appIdOrName==-1){
		hideAppFrame();
		return;
	}
	var fullPanelHeight = 200;
	Element.setStyle('appFrameHolder', {height:fullPanelHeight+'px'} );
	reorderLayout();
	urchinTracker('/Open Info Panel/'+appIdOrName);
	loadAppData(appIdOrName);
}
function hideAppFrame(){
	$('appData').innerHTML = "";
	Element.setStyle('appFrameHolder', {height:'0px'} );
	reorderLayout();

}



function loadAppData(appIdOrName){
	$('appData').innerHTML = "<span class='loading'><img src='images/loading.gif' /> Loading...</span>";
	var appDataAjax = new Ajax.Updater('appData','infoPanel.aspx', {method:'get', parameters:'appName='+appIdOrName});
	appDataAjax.onComplete = function(){
		if ($('appData').innerHTML.indexOf('status=ok')>-1){
			//loadBlogsphere(appIdOrName);
		}
	};
}








function loadBlogsphere(appIdOrName){
alert('gg');
	var technoratiAjax = new Ajax.Updater(
							{success:'blogSphere'},
							'blogsphere.aspx',
							{
								method:'get',
								parameters:'appName='+appIdOrName,
								onFailure:function(){
									$('blogSphere').innerHTML="Sorry, Could not load blogsphere links...<br/><a href=\"javascript:loadBlogsphere('"+appIdOrName+"')\">Try again</a>";

								}
							});
}



function init(){
	fixObjects();

	if(navigator.userAgent.indexOf("MSIE")>-1){
		flashObj = $('mainFlashObj');
	}else{
		flashObj = $('mainFlashEmb');
	}

	reorderLayout();
	checkQuery();
	//loadAds("");
}



function loadAds(tag){
	$('ads').innerHTML = "<span class='loading'><img src='images/loading.gif' /> Loading...</span>";
	var adsAjax = new Ajax.Updater(
							{success:'ads'},
							'ads.aspx',
							{
								method:'get',
								parameters:'tag='+tag,
								onFailure:function(){
									loadAds(tag)
								}
							});

}

function checkQuery() {
	if (autoApp.length>0){
		showAppFrame(autoApp);
		return;
	}

	if (location.search.length<1)return;
	var queryString = location.search.toString().replace("?","");
	var searchType = queryString.split("/")[0].toLowerCase();
	if (queryString.indexOf("/")>0){
		var searchValue = queryString.split("/")[1].toLowerCase();
	}else{
		var searchValue = "";
	}
	if (searchType=="app"){
		showAppFrame(searchValue);
	}
	if (searchType=="tag"){
		$('flashObj').filterByTagName(searchValue);
	}
}

function exchangeDivs(hideDiv,showDiv){
	$(hideDiv).style.display="none";
	$(showDiv).style.display="block";
}


function showTools(toShow){
	var targetBottom = (toShow)?0:-130;
	var currentBottom = Element.getStyle('tools', 'bottom');
	//var t = new Tween(object,property,easing,start,end,duration,suffixe);
	toolsTween = new Tween($("tools").style,'bottom',Tween.strongEaseOut,-100,targetBottom,0.3,'px');
	toolsTween.start();
	if (toShow){
		exchangeDivs('openTools','closeTools');
	}else{
		exchangeDivs('closeTools','openTools')
	}
	//$("toolsPanel").style.bottom=targetBottom+"px";
}