var browserUserAgent = navigator.userAgent.toLowerCase();
var operaBrowser = (browserUserAgent.indexOf("opera") != -1);
var ieBrowser = (browserUserAgent.indexOf("msie") != -1) && (document.all) && (!operaBrowser);
var ieBrowser5 = (ieBrowser) && (browserUserAgent.indexOf("msie 5") != -1);
var ieBrowser6 = (ieBrowser) && (browserUserAgent.indexOf("msie 6") != -1);
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function eraseCookie(name) {
	createCookie(name,"",-1);
}
function get_element(id) {  
	if (document.getElementById)
		return document.getElementById(id);
	else if (document.all)
		return document.all[id];
	else if (document.layers)
		return document.layers[id];
}
function add_event (elm, evType, fn, useCapture) {	
	if (elm.addEventListener) {
		elm.addEventListener(evType, fn, useCapture);
		return true;
	} else if (elm.attachEvent) {
		var r = elm.attachEvent('on' + evType, fn);
		return r;		
	} else {
		elm ['on' + evType] = fn;
	}	
}
function getSuffix(obj) {
	if (obj) 
		return _getSuffix(obj.id);
	return "";
}
function _getSuffix(suffix) {
	var pos = suffix.lastIndexOf('_');
	if (pos != -1)
		return suffix.substring(pos+1);
	return suffix;
}
function plus_id_click(e) {
	var target = e.currentTarget ? e.currentTarget : e.srcElement;
	var suffix = getSuffix(target);
	var plus_id = get_element("plus_"+parseInt(suffix));
	if (plus_id)
		plus_id.style.display = "none";
	var minus_id = get_element("minus_"+parseInt(suffix));
	if (minus_id)
		minus_id.style.display = "";
	var summary_id = get_element("summary_"+parseInt(suffix));
	if (summary_id)
		summary_id.style.display = "none";
	var content_id = get_element("content_"+parseInt(suffix));
	if (content_id)
		content_id.style.display = "";
}
function minus_id_click(e) {
	var target = e.currentTarget ? e.currentTarget : e.srcElement;
	var suffix = getSuffix(target);
	var plus_id = get_element("plus_"+parseInt(suffix));
	if (plus_id)
		plus_id.style.display = "";
	var minus_id = get_element("minus_"+parseInt(suffix));
	if (minus_id)
		minus_id.style.display = "none";
	var summary_id = get_element("summary_"+parseInt(suffix));
	if (summary_id)
		summary_id.style.display = "";
	var content_id = get_element("content_"+parseInt(suffix));
	if (content_id)
		content_id.style.display = "none";
}
function readmore(suffix) {
	var plus_id = get_element("plus_"+parseInt(suffix));
	if (plus_id)
		plus_id.style.display = "none";
	var minus_id = get_element("minus_"+parseInt(suffix));
	if (minus_id)
		minus_id.style.display = "";
	var summary_id = get_element("summary_"+parseInt(suffix));
	if (summary_id)
		summary_id.style.display = "none";
	var content_id = get_element("content_"+parseInt(suffix));
	if (content_id)
		content_id.style.display = "";
}
function plus(suffix) {
	var plus_id = get_element("plus_"+parseInt(suffix));
	if (plus_id) {
		add_event (plus_id, 'click', plus_id_click, false);
		plus_id.style.cursor="pointer";
	}
	var _text = readCookie("_text");
	var header = get_element("h3_"+parseInt(suffix));
	if (header)
		header.style.cursor = "pointer";
}
function minus(suffix) {
	var minus_id = get_element("minus_"+parseInt(suffix));
	if (minus_id) {
		add_event (minus_id, 'click', minus_id_click, false);
		minus_id.style.cursor="pointer";
	} 
}
function favourite(title) {
	if (ieBrowser) 
		window.external.AddFavorite(window.location,title);
}
function signup() {
	var signuploginform = get_element("signuploginform");
	if (signuploginform) {
		signuploginform.action="/mysynd/subscribe";
		signuploginform.submit();
	}
}
function login() {
	var signuploginform = get_element("signuploginform");
	if (signuploginform) {
		signuploginform.action="/mysynd/_home";
		signuploginform.submit();
	}
}
function openPowerViewer(url) {
	var width = screen.availWidth - 60;
	var height = screen.availHeight - 80;
	var left = parseInt((screen.availWidth/2) - (width/2));
	var top = parseInt((screen.availHeight/2) - (height/2));
	var windowFeatures = 'width='+width+',height='+height+',scrollbars=yes,status=yes,toolbar=yes,location=1,resizable,left=' + left + ',top=' + top;
	if (ieBrowser)
		var newwin = window.open(url,'power_viewer',windowFeatures,false);
	else
		var newwin = window.open(url,'power_viewer',windowFeatures);
	newwin.focus();
}
function openMiniReader(url,title) {
	var width = 306;
	var height = screen.availHeight - 280;
	var left = parseInt(screen.availWidth/15);
	var top = parseInt(screen.availHeight/12);
	var windowFeatures = 'width='+width+',height='+height+',scrollbars=yes,resizable=no,left=' + left + ',top=' + top;
	if (ieBrowser)
		var newwin = window.open(url,'minireader',windowFeatures,false);
	else
		var newwin = window.open(url,'minireader',windowFeatures);
	newwin.document.bgColor="#73a0c5";
	newwin.focus();
}
function openMiniTicker(url,title) {
	var width = 306;
	var height = screen.availHeight - 280;
	var left = parseInt(screen.availWidth/15);
	var top = parseInt(screen.availHeight/12);
	var windowFeatures = 'width='+width+',height='+height+',scrollbars=yes,resizable=no,left=' + left + ',top=' + top;
	if (ieBrowser)
		var newwin = window.open(url,'miniticker',windowFeatures,false);
	else
		var newwin = window.open(url,'miniticker',windowFeatures);
	newwin.document.bgColor="#73a0c5";
	newwin.focus();
}
function openMiniScroll(url,title) {
	var width = 306;
	var height = screen.availHeight - 280;
	var left = parseInt(screen.availWidth/15);
	var top = parseInt(screen.availHeight/12);
	var windowFeatures = 'width='+width+',height='+height+',scrollbars=yes,resizable=no,left=' + left + ',top=' + top;
	if (ieBrowser)
		var newwin = window.open(url,'miniscroll',windowFeatures,false);
	else
		var newwin = window.open(url,'miniscroll',windowFeatures);
	newwin.document.bgColor="#73a0c5";
	newwin.focus();
}
function openMobileReader(url,title) {
	var width = screen.availWidth - 100;
	var height = screen.availHeight - 100;
	var left = 50;
	var top = 50;
	var windowFeatures = 'width='+width+',height='+height+',scrollbars=yes,resizable=yes,toolbar=yes,location=yes,menubar=yes,left=' + left + ',top=' + top;
	if (ieBrowser)
		var newwin = window.open(url,'mobile',windowFeatures,false);
	else
		var newwin = window.open(url,'mobile',windowFeatures);
	newwin.focus();
}

