
addEvent(window, 'load', initCorners);

// corners  
function initCorners() {
var roundboxsmall = {
  tl: { radius: 6 },
  tr: { radius: 6 },
  bl: { radius: 6 },
  br: { radius: 6 },
  antiAlias: true,
  autoPad: true,
  validTags: ["div"]
}
var round_label = {
  tl: { radius: 4 },
  tr: { radius: 4 },
  bl: { radius: 4 },
  br: { radius: 4 },
  antiAlias: true,
  autoPad: true,
  validTags: ["span"]
}
var roundbox = {
  tl: { radius: 8 },
  tr: { radius: 8 },
  bl: { radius: 8 },
  br: { radius: 8 },
  antiAlias: true,
  autoPad: true,
  validTags: ["div"]
}
var roundboxtop = {
  tl: { radius: 8 },
  tr: { radius: 8 },
  bl: { radius: 0 },
  br: { radius: 0 },
  antiAlias: true,
  autoPad: true,
  validTags: ["div"]
}  
var midmenu = {
  tl: { radius: 6 },
  tr: { radius: 6 },
  bl: { radius: 6 },
  br: { radius: 6 },
  antiAlias: true,
  autoPad: true,
  validTags: ["div"]
}  
var menu = {
  tl: { radius: 6 },
  tr: { radius: 6 },
  bl: { radius: 6 },
  br: { radius: 6 },
  antiAlias: true,
  autoPad: true,
  validTags: ["a"]
}
var topmsg = {
  tl: { radius: 0 },
  tr: { radius: 0 },
  bl: { radius: 6 },
  br: { radius: 6 },
  antiAlias: true,
  autoPad: true,
  validTags: ["div"]
}

curvyCorners(topmsg, ".top-message-rounded"); 
curvyCorners(menu, ".active_page_item_a_2"); 
curvyCorners(midmenu, "#debate-wrap-active");
curvyCorners(midmenu, "#vesbar-wrap-active");
curvyCorners(roundbox, "#sub-pages-widget");
curvyCorners(roundbox, ".sub-round-widget");
curvyCorners(roundbox, ".post-attachment");
curvyCorners(roundboxtop, "#primary .content-box-widget-title");
curvyCorners(roundboxtop, "#primary .content-box-widget-title-black");
curvyCorners(roundboxtop, "#secondary .content-box-widget-title-black");
curvyCorners(roundboxtop, "#primary-home .content-box-widget-title-black");
curvyCorners(roundboxtop, "#secondary-home .content-box-widget-title-black");
curvyCorners(roundboxtop, "#below-left .content-box-widget-title-black");
curvyCorners(roundboxtop, "#below-right .content-box-widget-title-black");
curvyCorners(roundboxtop, "#above-content .content-box-widget-title-black");
curvyCorners(roundboxtop, "#below-content .content-box-widget-title-black");
curvyCorners(roundboxtop, "#below-content-bottom .content-box-widget-title-black");
curvyCorners(round_label, ".round_label");

}

function goToLink(id)  {	
	document.location.href = document.getElementById(id).href;	
}

// div functions
function clearDiv(id) {
	document.getElementById(id).innerHTML = "";
}

function inputFocus(id) {
	document.getElementById(id).style.background = "#FFFFD2";	
}

function inputBlur(id) {
	document.getElementById(id).style.background = "#FAFAFA";	
}
function hideDiv(id) {
	document.getElementById(id).style.display = "none";
}
function showDiv(id) {
	document.getElementById(id).style.display = "block";
}
function showHide(id) {
	if (document.getElementById(id).style.display != 'none') {
		hideDiv(id);	
	} else {
		showDiv(id);
	}
}



function submitForm(id) { 
	document.getElementById(id).submit();
}
function fullScreen(url) {
	window.open(url, '_blank', 'scrollbars=auto, toolbar=0, status=0, location=0, menubar=0, directories=0, resizable=1, titlebar=0', false);
}


// cookies
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 cName = name + "=";
	var cAttributes = document.cookie.split(';');
	for (var i=0; i < cAttributes.length; i++) {
		var c = cAttributes[i];
		while (c.charAt(0)==' ') c = c.substring(1, c.length);
		if (c.indexOf(cName) == 0) return c.substring(cName.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}
function loadComments(id_elem, id_link) {
	if (readCookie(id_elem)) {
		showDiv(id_elem);	
	}
}
function noComments(id_elem, id_link) {
	if (readCookie(id_elem)) {
		showDiv(id_elem);		
	}
}

function showHideComments(id_elem, id_link) {
	if (document.getElementById(id_elem).style.display != 'none') {
		eraseCookie(id_elem);
		hideDiv(id_elem);
	} else {
		createCookie(id_elem, "show", 365);
		showDiv(id_elem);
	}
}
function showComments(id_elem, id_link) {
		createCookie(id_elem, "show", 365);
		showDiv(id_elem);
		showDiv('comments-list');
		if(document.getElementById(id_link)){
			showDiv(id_link);
		}
}
function doComments(id_elem, id_link) {
		createCookie(id_elem, "show", 365);
		showDiv(id_elem);
		showDiv(id_link);
}
function hideCommentsSection(id_elem, id_section) {
		eraseCookie(id_elem);
		hideDiv(id_section);
}
function absTop(elementId){	
        var obj = document.getElementById(elementId);
		var offset = -4;
		while(obj.offsetParent) {
		offset += obj.offsetTop;
		obj = obj.offsetParent;
	}
	return(offset);
}
function scrollToDiv(id) {
		window.scrollTo(0, absTop(id));	
}
function restoreSections(id_section, id_elem) {
		createCookie(id_elem, "show", 365);
		showDiv(id_section);
}
function showSearchBox() {
	if (document.getElementById('search-dropdown').style.display != 'none') {
		hideDiv('search-dropdown');	
		document.getElementById('search-link-wrap').style.backgroundPosition = 'right';
	} else {
		showDiv('search-dropdown');
		document.getElementById('search-link-wrap').style.backgroundPosition = 'left';
	}
}


