var querywindow = '';


function authordetail(postID) {
document.getElementById('user_detail_'+postID).style.display= document.getElementById('user_detail_'+postID).style.display =="block"?"none":"block";
}

function goTo(targeturl, target) {
    //alert('goto');
    if ( target == 'main' ) {
        target = window.frame_content;
    } else if ( target == 'query' ) {
        target = querywindow;
        //return open_querywindow( targeturl );
    } else if ( ! target ) {
        target = window.frame_navigation;
    }
	target.location.href = targeturl;
/*
    if ( target ) {
        if ( target.location.href == targeturl ) {
            return true;
        } else if ( target.location.href == pma_absolute_uri + targeturl ) {
            return true;
        }

        if ( safari_browser ) {
            target.location.href = targeturl;
        } else {
            target.location.replace(targeturl);
        }
    }
*/
    return true;
}

function fe_edit_post(url, params) {
//alert(url+params);
//	processing(1);
querywindow_width = '900px';
querywindow_height = '500px';

/*    if ( ! url ) {
        url = 'querywindow.php?' + common_query + '&db=' + encodeURIComponent(db) + '&table=' + encodeURIComponent(table);
    }*/

    if (!querywindow.closed && querywindow.location) {
        goTo( url+params, 'query' );
        querywindow.focus();
    } else {
        querywindow=window.open( url+params, '',
            'toolbar=0,location=0,directories=0,status=1,menubar=0,' +
            'scrollbars=yes,resizable=yes,' +
            'width=' + querywindow_width + ',' +
            'height=' + querywindow_height );
    }

    if ( ! querywindow.opener ) {
       querywindow.opener = window.window;
    }

    if ( window.focus ) {
        querywindow.focus();
    }

    return true;


/*	if (! document.getElementById("feeditpost")) {

		document.body.innerHTML += '<iframe id="feeditpost" name="feedit" style="position:relative; top:40px; left:40px; width:900px; height:800px; background-image:url(wp-content/plugins/loading.gif); background-repeat:no-repeat; background-position:center center; display:none;" ></iframe><iframe id="feeditTMP" style="display:none"> </iframe>';
	}
	if (!params) params = "";
	document.getElementById("feeditpost").src=url+params; //"wp-admin/post-new.php?feEdit=1";*/
}

function searchSubmit (form) {
	if (form.where[2].checked) {
		window.open('http://www.google.com/search?q='+escape(form.s.value));
		return false;
	}
}

function enlargeChat() {
	chat = document.getElementById('wordspew');
	if( chat.style.position) {
		chat.style.position = "";
		chat.style.top = "";
		chat.style.left = "";
		chat.style.width = "";
		chat.style.background = "";
		document.getElementById('chatoutput').style.height="";
		document.getElementById('enlargeButt').innerHTML = 'Enlarge';
		document.getElementById('chatbarText').style.width="120px";
		document.getElementById('submitchat').style.display="block";
		document.getElementById('chatbarText').style.display="block";
		document.getElementById('chatForm').style.padding="0px";
		document.getElementById('chatbarText').style.margin="0pt auto";
		document.getElementById('submitchat').style.margin="10px auto";
		document.getElementById('chatoutput').style.margin="10px 0px 0px 0px";
	}
	else
	{
		var myWidth = 0, myHeight = 0;
		if( typeof( window.innerWidth ) == 'number' )
		{
			//Non-IE
			myWidth = window.innerWidth;
			myHeight = window.innerHeight;
		}
		else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
		{
			//IE 6+ in 'standards compliant mode'
			myWidth = document.documentElement.clientWidth;
			myHeight = document.documentElement.clientHeight;
		}
		else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
		{
			//IE 4 compatible
			myWidth = document.body.clientWidth;
			myHeight = document.body.clientHeight;
			window.alert( 'Width = ' + myWidth );
			window.alert( 'Height = ' + myHeight );
		}
		chat_old_style = chat.style;
		chat.style.position='fixed';
		chat.style.top='20px';
		chat.style.left=(myWidth-800)/2+'px';
//		chat.style.margin-right='auto';
		chat.style.background = "#dddddd";
		chat.style.width="800px";
		document.getElementById('chatoutput').style.height="400px";
		document.getElementById('chatoutput').style.margin="0px";
		document.getElementById('enlargeButt').innerHTML="Zmenši";
		document.getElementById('chatbarText').style.width="700px";
		document.getElementById('submitchat').style.display="inline";
		document.getElementById('chatbarText').style.display="inline";
		document.getElementById('chatbarText').style.margin="0px";
		document.getElementById('submitchat').style.margin="0px";
		document.getElementById('chatForm').style.padding="5px 0px 0px 10px";
	}	
}
//document.back = alert("ss");
function getImage(shifter) {
	
	//alert(document.location.hash.substr(1));
//	attachmentId = 1;
//document.location.hash.substr(1);
	//alert(attachmentId +" |" + shifter+ " |"+document.location.hash.substr(1));
	//attachmentId = document.location.hash.substr(1);

	if (shifter == 0 && document.location.hash.substr(1)) {
		attachmentId = document.location.hash.substr(1);
		attachmentId = eval(attachmentId);
		if (attachmentId > attachments.length-1) attachmentId = attachments.length-1;
	} else if (shifter != 0 && document.location.hash.substr(1)) {
		attachmentId = document.location.hash.substr(1);
		attachmentId = eval(attachmentId);
		attachmentId = attachmentId + shifter;
	}
//alert(attachmentId +" |" + shifter+ " |"+document.location.hash.substr(1)+"|"+attachments.length);
//	else 

//alert(attachmentId);

	if (attachmentId == 0) {
		document.getElementById('previousImage').style.display="none";
	//	if (shifter == -1) return;
	}
	else
		document.getElementById('previousImage').style.display="inline";

	if (attachmentId == attachments.length-1) {
		document.getElementById('nextImage').style.display="none";
	//	if (shifter == 1) return;
	}
	else
		document.getElementById('nextImage').style.display="inline";
	
	document.location.hash = attachmentId;
	currenturl = document.location.href;
		processing(1);
		document.getElementById('attachmentImg').src=attachments[attachmentId];
		document.getElementById('attachmentImg').alt=attachmentsTitle[attachmentId];
		document.getElementById('attachmentImg').parentNode.href=attachments[attachmentId];
		document.getElementById('m_imagePermalink').title="Permanent Link: "+attachmentsTitle[attachmentId];
		document.getElementById('m_imagePermalink').href=attachmentsPerma[attachmentId];
		document.getElementById('m_imagePermalink').innerHTML=attachmentsTitle[attachmentId];	
	var t=setTimeout("checkurlchange()",100);
}
var currenturl = '';
function checkurlchange(url)
{
	if (currenturl != document.location.href)
	{
		location.reload(true);
	}
	else
	{
		var t=setTimeout("checkurlchange(document.location.href)",100);
	}
}
function processing (status){
	document.getElementById('processing').style.display = (status?'block':'none');
	
	
}

var onLoadArray = new Array();
function runOnLoad() {
	
	eval(onLoadArray[0]);
	//eval(onLoadArray[1]);
}

function myWindowOnload(f)
{
  var prev=window.onload;
  window.onload=function(){ if(prev)prev(); eval(f); }
}

function googlesearch()
{
	if (document.getElementById('googlesearchwhere').checked)
	{
		var search = document.getElementById('s').value;
		var google = window.open('http://www.google.com/search?q='+search,'google','');
		google.focus();
		return false;
	}
	else
	{
		
		return true;
	}
}


