/*******************Extension Check for Chrome****************************/
setTimeout('checkExtension()',5500);

function checkExtension()
{
	if((navigator.userAgent.toLowerCase().indexOf('chrome') > -1)) {
		if(document.getElementsByClassName("notifier_active").length<=0)
		{
			//$('body').append('<div id="ext_toolbar"></div>');
			document.getElementById('ext_toolbar').style.display='block';
			loadScript("http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js",showToolbar);
		}
	}
}


function showToolbar() {
	$('#ext_toolbar').css({backgroundImage: "url('http://www.sify.com/images/gradient.png')", fontFamily: 'Tahoma, sans-serif', fontSize: '14px', color: '#333', borderBottom: '1px solid #CCC', height: "37px"});	
	$('#ext_toolbar').append("<div id=\"ext_toolbar_close\"><span style=\"display:none;\">Close</span></div>");
	$('#ext_toolbar').append("<div id=\"ext_toolbar_install\"><span style=\"display:none;\">Install</span></div>");
	$('#ext_toolbar').append("<div id=\"ext_toolbar_text\">Sify now has a <span id=\"ext_toolbar_link\">Google Chrome Extension</span>. Get the latest news on the topics you like, direct to your browser.</div>");
	$('#ext_toolbar_link').css({textDecoration:"underline", color: "#4B689C", cursor:"pointer"});
	$('#ext_toolbar_text').css({padding: "11px 10px 10px 38px", background: "url('http://www.sify.com/images/icon.png') no-repeat 5px 5px", overflow:"hidden", whiteSpace:"nowrap", "-webkit-user-select":"none", cursor: "default", zindex:"100000", position:"absolute"});
	$('#ext_toolbar_install').css({float:"right", background: "url('http://www.sify.com/images/install.png') no-repeat", width:"87px", height:"26px", margin: "6px 10px 0 0", cursor:"pointer",position:"absolute", left:"80%", float:"right"});
	$('#ext_toolbar_close').css({float:"right", background: "url('http://www.sify.com/images/close.png') no-repeat", width:"10px", height:"10px", margin: "14px 10px 0 0", cursor:"pointer",position:"absolute", left:"93%", float:"right"});
	
	
	//if(toolbarConfig.slide) {
		$('#ext_toolbar').hide().slideDown('fast');
	//}
	$('#ext_toolbar_close').click(closeToolbar);
	$('#ext_toolbar_install').click(installExtension); // currently set to open directory not direct download
	$('#ext_toolbar_link').click(openExtension); // currently set to open directory not direct download
	
	$("embed").attr("wmode", "opaque");
	$(window).resize(flow); 
	$(window).scroll(move);
	move();
}

function closeToolbar() {
	$('#ext_toolbar').slideUp('fast'); 
	//localStorage[toolbarConfig.hide] = true;
}

function openExtension() {
	closeToolbar();
	window.open("https://chrome.google.com/webstore/detail/defcclddohmcolbjeojblocoebckhaam");
}
function installExtension() {
	closeToolbar();
	window.open("https://clients2.google.com/service/update2/crx?response=redirect&x=id%3Ddefcclddohmcolbjeojblocoebckhaam%26uc");
}
function flow() {
	//$('#ext_toolbar_text').width($(window).width() - 170);
	$("#ext_toolbar").css({width:$(window).width()});
}

function move() {
	if($(window).scrollTop() <= 1) {
		$("#ext_toolbar").css({position:"relative", top: 0});
	}
	else {
		$("#ext_toolbar").css({position:"absolute", top: $(window).scrollTop()+"px", width:$(window).width(), zIndex:"9900000"});
	}
	flow();
}

function loadScript(url, callback){
	// include remote list
    var script = document.createElement("script")
    script.type = "text/javascript";
	script.onload = function(){
		loaded = true;
		callback();
	};
    script.src = url;
    document.getElementsByTagName("head")[0].appendChild(script);
}
/*******************End Of Extension Check****************************/
