var sanomaPopup;

function OpenWindow(wUrl,wName,wOptions) {
	sanomaPopup = window.open(wUrl, wName, wOptions);
	//history.back();
}

function getStyleObject(objectId)
{
	if(document.getElementById && document.getElementById(objectId)) {
		return document.getElementById(objectId).style;
	} else if (document.all && document.all(objectId)) {
		return document.all(objectId).style;
	} else if (document.layers && document.layers[objectId]) {
		return document.layers[objectId];
	} else {
		return false;
	}
}

function changeObjectVisibility(objectId, newVisibility)
{
	var styleObject = getStyleObject(objectId);
	if(styleObject) {
		styleObject.display = newVisibility;
		return true;
	} else {
		alert("Er is een fout opgetreden. Uw browser ondersteund deze functie niet. Download een nieuwe versie!");
		return false;
	}
}

function getObjectById(objectId)
{
	if(document.getElementById && document.getElementById(objectId)) {
		return document.getElementById(objectId);
	} else if (document.all && document.all(objectId)) {
		return document.all(objectId);
	} else if (document.layers && document.layers[objectId]) {
		return document.layers[objectId];
	} else {
		return false;
	}
}

function changeTab(tabId)
{

    for ( i = 0; i <= 26; i++ )
    {
        tab = document.getElementById('tab' + i);
        inhoud = document.getElementById('inhoud' + i);
        if ( i == tabId ) {
            tab.className = "selected";
            inhoud.style.display='block';
        } else {
            tab.className = "tab";
            inhoud.style.display='none';
        }
    }
}

/**
 * Count webring clicks with arnostat, urchintracker and stir
 * (make sure the needed JS functions are included)
 *
 * @param 	string	string containing the identifier that will be counted
 */
function countWebring(id)
{
	// arnostat
	if (typeof lc_visit != 'undefined') {
		lc_visit('grazia','webring','',id,'');
		lc_visit('glossy-sites','grazia','','','');
	}

	// urchintracker
	if (typeof urchinTracker != 'undefined') {
		urchinTracker('/webring/' + id);
	}

	// stir
	if (typeof sitestat != 'undefined' && document.cookie.indexOf('ns_Cfilter') != -1) {
		sitestat("http://nl.sitestat.com/sanoma/grazia/s?teller&amp;ns_webdir=webring");
	}
	return true;
}

poll_vote_url = base_url + '/wp-includes/im_shared/vote_poll_handle.php';

var poll_vote_id = 0;

function poll_vote(id) {
	poll_vote_id = id;
	var id_poll = "frm_single_poll_" + id;
	var id_choice = "poll_choice";
	alert(id_poll);
	var p = document[id_poll];
	var c = p[id_choice];

    for (i=0;i< c.length;i++) {
        if (c[i].checked) {
            user_input = c[i].value;
        }
    }

	var params = 'poll_choice=' + user_input + '&poll_id=' + id;

    new Ajax.Request(
		poll_vote_url,
		{
			method: 'post',
			parameters: params,
			onComplete: voteResponse
		}
	);
}

function voteResponse(request) {
   if (request.responseText != '') {
        var myObject = document.getElementById("pollgeheel_" + poll_vote_id);

        myObject.innerHTML = request.responseText;
    }
}

/**
 * Iframe resize function
 * @param string id, the id of the layers
 * @param int    extra, extra space in pixels at the bottom of the iframe
 */
function iresize(id, extra) {
    var newheight;
    if(document.getElementById) {
        newheight = document.getElementById(id).contentWindow.document.body.scrollHeight;
    }
    document.getElementById(id).height = (newheight) + extra + "px";
}


function commentform_validate()
{
	if ($('comment').value == '') {
		alert('Schrijf je bericht en druk dan op versturen...');
		return false;
	}
	return true;
}

function forumregistration()
{
	document.location = base_url + '/aanmelden/';
}

function forumlogin()
{
	document.location = base_url + '/login/';
}

function forumloginsuccess()
{
	document.location = base_url + '/forum/';
}
