function popup(code,w,h)
	{ window.open('plug.php?o='+code,'','toolbar=0,location=0,directories=0,menuBar=0,resizable=0,scrollbars=yes,width='+w+',height='+h+',left=32,top=16'); }

function pfs(id,c1,c2)
	{ window.open('pfs.php?userid='+id+'&c1='+c1+'&c2='+c2,'PFS','status=1, toolbar=0,location=0,directories=0,menuBar=0,resizable=1,scrollbars=yes,width=754,height=512,left=32,top=16'); }

function help(rcode,c1,c2)
	{ window.open('plug.php?h='+rcode+'&c1='+c1+'&c2='+c2,'Help','toolbar=0,location=0,directories=0,menuBar=0,resizable=0,scrollbars=yes,width=480,height=512,left=32,top=16'); }

function comments(rcode)
	{ window.open('comments.php?id='+rcode,'Comments','toolbar=0,location=0,directories=0,menuBar=0,resizable=0,scrollbars=yes,width=480,height=512,left=16,top=16'); }

function ratings(rcode)
	{ window.open('ratings.php?id='+rcode,'Ratings','toolbar=0,location=0,directories=0,menuBar=0,resizable=0,scrollbars=yes,width=480,height=512,left=16,top=16'); }

function polls(rcode)
	{ window.open('polls.php?id='+rcode,'Polls','toolbar=0,location=0,directories=0,menuBar=0,resizable=0,scrollbars=yes,width=608,height=448,left=16,top=16'); }

function pollvote(rcode,rvote)
	{ window.open('polls.php?a=send&id='+rcode+'&vote='+rvote,'Polls','toolbar=0,location=0,directories=0,menuBar=0,resizable=0,scrollbars=yes,width=608,height=448,left=16,top=16'); }

function picture(url,sx,sy)
	{
  var ptop=(window.screen.height-200)/2;
  var pleft=(window.screen.width-200)/2;
  window.open(url,'Picture','toolbar=0,location=0,status=0, directories=0,menubar=0,resizable=1,scrollbars=yes,width='+sx+',height='+sy+',left='+pleft+',top='+ptop+'');
  }

function redirect(url)
	{ location.href = url.options[url.selectedIndex].value; }

function toggleblock(id)
	{
	var bl = document.getElementById(id);
	if(bl.style.display == 'none')
		{ bl.style.display = ''; }
	else
		{ bl.style.display = 'none'; }
	}


// Inserts text into textarea at cursor position
function insertText(docObj, formName, fieldName, value) {
	var field = null;
	if(!docObj)
		docObj = document;
	// Find the field in the docObj
	for(var i = 0; i < docObj.forms.length; i++) {
		if(docObj.forms[i].name == formName) {
			for(var j = 0; j < docObj.forms[i].elements.length; j++) {
				if(docObj.forms[i].elements[j].name == fieldName) {
					field = docObj.forms[i].elements[j];
					break;
				}
			}
			break;
		}
	}
	if(!field)
		return false;
	// Insert the text
	if (docObj.selection) {
		// MSIE and Opera
		field.focus();
		var sel = docObj.selection.createRange();
		sel.text = value;
	} else if (field.selectionStart || field.selectionStart == 0) {
		// Mozilla
		var startPos = field.selectionStart;
		var endPos = field.selectionEnd;
		field.value = field.value.substring(0, startPos) + value + field.value.substring(endPos, field.value.length);
	} else {
		field.value += value;
	}
	return true;
}

function ajaxSend(settings) {
	var method = settings.method || 'GET';
	var data = settings.data || '';
	var url = settings.url || $('#' + settings.formId).attr('action');
	if(method == 'POST') {
		data += '&' + $('#' + settings.formId).serialize();
	}
	$.ajax({
		type: method,
		url: url,
		data: data,
		beforeSend: function() {
			$('#' + settings.divId).append('<span style="position:relative;left:' + ($('#' + settings.divId).width()/2 - 16) + 'px;top:-' + ($('#' + settings.divId).height()/2 - 16) + 'px;" class="loading" id="loading"><img src="js/spinner_bigger.gif" alt="loading"/></span>');
		},
		success: function(msg) {
			$('#loading').remove();
			$('#' + settings.divId).hide().html(msg).fadeIn(500);
		},
		error: function(msg) {
			$('#loading').remove();
			alert(settings.errMsg);
		}
	});
	return false;
}

$(document).ready(function() {
	if (location.hash == '#comments' || location.hash.match(/#c\d+/)) {
		$('.comments').css('display', '');
	}
	$('.comments_link').click(function() {
		if($('.comments').css('display') == 'none') {
			$('.comments').css('display', '');
		} else {
			$('.comments').css('display', 'none');
		}
	});

	if(location.href.match(/#comments/)) {
		$('.comments').css('display', '');
	}
});





window.name = 'main';


function sed_ajax_getxmlhttp()
	{
  	var xmlhttp = false;
  	if (window.XMLHttpRequest)
  		{ xmlhttp = new XMLHttpRequest() }
	else if (window.ActiveXObject)
		{
		try
    		{ xmlhttp = new ActiveXObject("Msxml2.XMLHTTP") }
		catch (e)
			{
			try
				{ xmlhttp = new ActiveXObject("Microsoft.XMLHTTP") }
			catch (E)
				{ xmlhttp=false }
			}
		}
	return xmlhttp;
	}

function sed_ajax_pass(url, callbackFunction, params)
	{
	var xmlhttp = new sed_ajax_getxmlhttp();

	if (xmlhttp)
		{
		xmlhttp.onreadystatechange =
		function ()
           	{
           	if (xmlhttp && xmlhttp.readyState==4)
           		{
				if (xmlhttp.status==200)
					{
               		var response = xmlhttp.responseText;
               		var functionToCall = callbackFunction + '(response,'+params+')';
					eval(functionToCall);
					}
				}
			}
    	xmlhttp.open("GET",url,true);
    	xmlhttp.send(null);
		}
	}

function sed_ajax_set(url, obj_id)
	{
	var xmlhttp = new sed_ajax_getxmlhttp();

	if (xmlhttp)
		{
    	xmlhttp.onreadystatechange =
		function ()
			{
			if (xmlhttp && xmlhttp.readyState==4)
				{
                if (xmlhttp.status==200)
	                {
                  	if(typeof obj_id == 'object')
                  		{ obj_id.innerHTML = xmlhttp.responseText; }
                  	else
                  		{ document.getElementById(obj_id).innerHTML = xmlhttp.responseText; }
                	}
                }
            }
    	xmlhttp.open("GET",url,true);
		xmlhttp.send(null);
		}
	}




