// JavaScript Document
/*
function PreloadImages() {
	if (document.images) {
		var imgFiles = PreloadImages.arguments;
		var preloadArray = new Array();
		for (var i=0; i<imgFiles.length; i++) {
			preloadArray[i] = new Image;
			preloadArray[i].src = imgFiles[i];
			}
		}
	}

PreloadImages('/blog/wp-content/themes/pbsnew/img/m_sakums_on.gif');
PreloadImages('/blog/wp-content/themes/pbsnew/img/m_galerija_on.gif');
PreloadImages('/blog/wp-content/themes/pbsnew/img/m_faq_on.gif');
PreloadImages('/blog/wp-content/themes/pbsnew/img/m_kontakti_on.gif');

PreloadImages('/blog/wp-content/themes/pbsnew/img/m_sakums_off.gif');
PreloadImages('/blog/wp-content/themes/pbsnew/img/m_galerija_off.gif');
PreloadImages('/blog/wp-content/themes/pbsnew/img/m_faq_off.gif');
PreloadImages('/blog/wp-content/themes/pbsnew/img/m_kontakti_off.gif');

PreloadImages('/blog/wp-content/themes/pbsnew/img/formbg.jpg');
PreloadImages('/blog/wp-content/themes/pbsnew/img/formbg_blank.jpg');
*/

function showHideArhivs(){
	obj = document.getElementById('arhivs');
	arch = document.getElementById('sharch');
	currstyle = obj.style.display;
	
	if(currstyle==""){
		obj.style.display='none';
		arch.innerHTML="Parādīt arhīvu";
	}
	else{
		obj.style.display='';
		arch.innerHTML="Paslēpt arhīvu";
	}
}

function showHideCategories(){
	obj = document.getElementById('kategorijas');
	cat = document.getElementById('shcat');
	currstyle = obj.style.display;
	
	if(currstyle==""){
		obj.style.display='none';
		cat.innerHTML="Parādīt kategorijas";
	}
	else{
		obj.style.display='';
		cat.innerHTML="Paslēpt kategorijas";
	}
}


function raksturojums(id){
	window.open("/blog/wp-content/themes/pbs/raksturojums.php?r="+id+"","mywindow","menubar=0,resizable=1,width=450,height=250,scrollbars=1");
}

function launchAlgasCalc(){
	window.open('/blog/wp-content/themes/pbs/algas_kalkulators.php', 'acalc', 'height=180, width=360, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no');
}

function showContactForm(){
	cform = document.getElementById('contactform');
	cform.style.display='';
}
function hideContactForm(){
	cform = document.getElementById('contactform');
	cform.style.display='none';
}

/*
function checkContactForm(){
	if(document.contactFrom.pbsblog_name.value=="" || document.contactFrom.pbsblog_email.value=="" || document.contactFrom.pbsblog_text.value==""){
		alert("Visiem laukiem ir jābūt aizpildītiem!");
		return false;	
	}
	else {
		return true;	
	}
}

function showBlog(){
	document.getElementById('loading').style.display='none';
	document.getElementById('container').style.display='';
}

*/

/*
// Flash version detect
function isDefined(property) {
  return (typeof property != 'undefined');
}

var flashVersion = 0;
function getFlashVersion() {
	var latestFlashVersion = 8;
   var agent = navigator.userAgent.toLowerCase(); 
	
   // NS3 needs flashVersion to be a local variable
   if (agent.indexOf("mozilla/3") != -1 && agent.indexOf("msie") == -1) {
      flashVersion = 0;
   }
   
	// NS3+, Opera3+, IE5+ Mac (support plugin array):  check for Flash plugin in plugin array
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		var flashPlugin = navigator.plugins['Shockwave Flash'];
		if (typeof flashPlugin == 'object') { 
			for (var i = latestFlashVersion; i >= 3; i--) {
            if (flashPlugin.description.indexOf(i + '.') != -1) {
               flashVersion = i;
               break;
            }
         }
		}
	}

	// IE4+ Win32:  attempt to create an ActiveX object using VBScript
	else if (agent.indexOf("msie") != -1 && parseInt(navigator.appVersion) >= 4 && agent.indexOf("win")!=-1 && agent.indexOf("16bit")==-1) {
	   var doc = '<scr' + 'ipt language="VBScript"\> \n';
      doc += 'On Error Resume Next \n';
      doc += 'Dim obFlash \n';
      doc += 'For i = ' + latestFlashVersion + ' To 3 Step -1 \n';
      doc += '   Set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash." & i) \n';
      doc += '   If IsObject(obFlash) Then \n';
      doc += '      flashVersion = i \n';
      doc += '      Exit For \n';
      doc += '   End If \n';
      doc += 'Next \n';
      doc += '</scr' + 'ipt\> \n';
      document.write(doc);
   }
		
	// WebTV 2.5 supports flash 3
	else if (agent.indexOf("webtv/2.5") != -1) flashVersion = 3;

	// older WebTV supports flash 2
	else if (agent.indexOf("webtv") != -1) flashVersion = 2;

	// Can't detect in all other cases
	else {
		flashVersion = flashVersion_DONTKNOW;
	}

	return flashVersion;
}

flashVersion_DONTKNOW = -1;
*/

/********************/
/*
function postCommentAjax()
{
	var url = '/blog/wp-comments-post-ajax.php';
	//var pars = 'comment_post_ID='+$('comment_post_ID').value+'&author='+$("author").value+'&url='+$("url").value+'&email='+$("email").value;
	var pars = 'comment_post_ID='+$('comment_post_ID').value+'&author='+$("author").value+'&url='+$("url").value+'&comment='+$("comment").value;
	myAjax = new Ajax.Request(
		url,
		{
			method: 'post',
			parameters: pars,
			onComplete: commentOK
		}
	);		
}


function commentOK(comobj)
{		
	if(comobj.responseText=="")
	{		
		var authornode = document.createElement('div');
		authornode.className = 'allcomname';
		authornode.id = 'newcommentauthor';
		authornode.style.display = 'none';
		
		if($F('url')!="")
		{
			authornode.innerHTML = '<a href="'+$F('url')+'" rel="external nofollow">'+$F('author')+'</a>';			
		}
		else 
		{
			authornode.innerHTML = $F('author');
		}
		
		
		var commentnode = document.createElement('div');
		commentnode.className = 'allcomtext';
		commentnode.id = 'newcommentcontent';
		commentnode.style.display = 'none';
		commentnode.innerHTML = '<p>'+$F('comment')+'</p>';	

		document.getElementById('allusercomments').appendChild(authornode);
		document.getElementById('allusercomments').appendChild(commentnode);
		
		
		new Effect.Fade($('commentformdiv'), {duration:0.5});
		window.setTimeout("$('commentformdiv').innerHTML = '<p style=\"margin-bottom:20px;\"><strong>Paldies par komentāru!</strong></p>'", 600);
		window.setTimeout("new Effect.Appear($('commentformdiv'), {duration:0.4})", 2000);
		
		window.setTimeout("new Effect.Appear($('newcommentcontent'), {duration:2})", 600);
		window.setTimeout("new Effect.Appear($('newcommentauthor'), {duration:2})", 600);
				
	}
}
*/

function blinkUpdatedGallery()
{
	if(document.getElementById("gal_span").style.visibility=="hidden")
	{
		document.getElementById("gal_span").style.visibility = "visible";
	}
	else
	{
		document.getElementById("gal_span").style.visibility = "hidden";
	}

}