function show_block(e) {
	document.getElementById(e).style.display="block";
}

function close_block(e) {
	document.getElementById(e).style.display="none";
}

function highlight_date(e) {
	document.getElementById(e).className="active";
}
function highlight_date2(e) {
	document.getElementById(e).className="active2";
}

function hide_date(e) {
	document.getElementById(e).className="";
}

function getUrlVars()
{
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}

function ReDrawLinkDiv(){
	var children = document.getElementById('gallery_panel').childNodes;
	next = 0;
	hval = '';
	for(i=0;i<children.length;i++){
	    if(next == 2){
		  hval = children[i].href;
		  next = 3;
		}
		if(next == 1){
		  next = 2;
		}
		if(typeof(children[i].innerHTML) != 'undefined'){
			if(children[i].innerHTML.search(/span/g)>0){
				next = 1;
			};
		}
	}
	add_str = '';
	if(hval.length > 0){
	  add_str='<a href="'+hval+'"><span>&gt; </span></a>';
	} else {
		add_str='<span>&gt; </span>';
	}
	document.getElementById('gallery_panel').innerHTML = add_str+document.getElementById('gallery_panel').innerHTML.replace(/<span>&gt; <\/span>/g, '');
	//<span>&gt; </span>
	
    
}

function ReDrawLinkDiv1(){
	var children = document.getElementById('forms_left').getElementsByTagName('a');	
	for(j=0;j<children.length;j++){
	var vars = [], hash;
	var hashes = children[j].href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
	 if(vars["CategoryId"] == getUrlVars()["CategoryId"]){
	   if (getUrlVars()["CategoryId"]) {
	     children[j].className="button"+getUrlVars()["CategoryId"]+"_active";
	   }
	 }
	}
}

var thisPhoto = 0;

function initLinks() {
	document.getElementById("previous").onclick = processPrevious;
	document.getElementById("next").onclick = processNext;
}


function processPrevious() {
	changeOpac(0)
	if (thisPhoto == 0) {
		thisPhoto = myPhoto.length;
	}
	thisPhoto--;
	document.getElementById("myPicture").src = myPhoto[thisPhoto];
	if (document.getElementById("myPicture").src.indexOf("v") != -1)
	{
		document.getElementById("myPicture").style.paddingTop = 0 + "px";
	}
	else {
		document.getElementById("myPicture").style.paddingTop = 5 + "px";
	}
	document.getElementById('pictureText').innerHTML = myText[thisPhoto];
	opacityShow()
	return false;
}

function processNext() {
	changeOpac(0)
	thisPhoto++;
	if (thisPhoto == myPhoto.length) {
		thisPhoto = 0;
	}
	document.getElementById("myPicture").src = myPhoto[thisPhoto];
	if (document.getElementById("myPicture").src.indexOf("v") != -1)
	{
		document.getElementById("myPicture").style.paddingTop = 0 + "px";
	}
	else {
		document.getElementById("myPicture").style.paddingTop = 5 + "px";
	}
	document.getElementById('pictureText').innerHTML = myText[thisPhoto];
	opacityShow()
	return false;
}


function opacityFade() {
	timer = 900;
	for(i = 100; i >= 0; i--) {
		setTimeout("changeOpac(" + i + ")",(timer));
		timer=timer+2;
	}
}
function opacityShow() {
	timer = 900;
	for(i = 0; i <= 100; i++) {
		setTimeout("changeOpac(" + i + ")",(timer));
	timer=timer+2;
	}
}

function changeOpac(opacity) {
	var object = document.getElementById('myPicture').style;
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}
