function moreInfo(id) {
	var element = new getObj(id+"_days");
	var element2 = new getObj(id+"_month");
	var element3 = new getObj(id+"_year");
	var selval = element.obj.options[element.obj.selectedIndex].value;
	var selval2 = element2.obj.options[element2.obj.selectedIndex].value;
	var selval3 = element3.obj.options[element3.obj.selectedIndex].value;
	if (isNaN(Number(selval)) && isNaN(Number(selval2)) && isNaN(Number(selval3))) {
		hideRow(id+"_more_info_row");
	} else {
		showRow(id+"_more_info_row");
	}
}

function hideRow(whichRow) {
	var element = new getObj(whichRow);
	element.style.display = "none";
}

function showRow(whichRow) {
	var element = new getObj(whichRow);
	element.style.display = "";
}

function toggleLayer(whichLayer) {
	var element = new getObj(whichLayer);
	element.style.display = element.style.display? "":"none";
}

function getTarget(element_id) {
	if(document.getElementById(element_id))
		return document.getElementById(element_id);
	else return false; //alert(\'Selle ID-ga element puudub: \'+element_id);
}

/**********************************************************/
/*Show hide content*/
function showHide(id, id2){
	var target = getTarget(id);			
	var disp = target.style.display;
	var new_disp;

	if(disp == "none") new_disp = "block";
	else new_disp = "none";

	target.style.display=new_disp;
	
	if (id2 != "") var tar2 = getTarget(id2);
	if (id2 != "") disp2 = "none";
	else disp2 = "block";			
	if (id2 != "") tar2.style.display=disp2;
}
/*Switch between contents*/
function switchContent(id1, id2){
      
	var target1 = getTarget(id1);
	var target2 = getTarget(id2);
	
	
	var sisu1 = target1.innerHTML;
	var sisu2 = target2.innerHTML;
	
	target2.innerHTML = sisu1;
	target1.innerHTML = sisu2;
}
/*Confirmation*/
function confirmSubmit(msg) {	
	var answer = confirm(msg);
	if (answer){
		return true;
	} else {
		return false;
	}

}


function twitter(link, id)
{
	//link = 'http://band.musaveeb.net/logged_in.php?page=twitter&'+url+"&sid="+Math.random();
	//content = document.getElementById(id);
//alert(link);
	var xmlHttp
	 //action - task name / "none" if not present
	 //box_name - content id to change content
	 //item_id - product_id

	 xmlHttp=GetXmlHttpObject()
	 if (xmlHttp==null)
	 {
		 alert ("Browser does not support HTTP Request")
		 return
	 }

	 var url;
	 url= "logged_in.php";
	 url= url+"/?page=twitter&="+link+"&sid="+Math.random();
alert(url);
	 xmlHttp.onreadystatechange=function()
	 {
		 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		 {
			if(xmlHttp.responseText) alert(xmlHttp.responseText);
		 }
		 else alert(xmlHttp.readyState);
	 }

	 xmlHttp.open("GET",url,true)
	 xmlHttp.send(null)
}


/* vajalik teistes func.-des */
function GetXmlHttpObject()
{
   var xmlHttp=null;
   try
   {
	 // Firefox, Opera 8.0+, Safari
	 xmlHttp=new XMLHttpRequest();
   }
   catch (E)
   {
	  // Internet Explorer
	   try
	   {
		  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	   }

	   catch (E)
	   {
		  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	   }
   }
   return xmlHttp;
 }


 function pagination(type, page, user_id, linkID)
 {
	content = document.getElementById('pagination');
	document.getElementById(linkID).innerHTML = 'Loading..';
		
	var xmlHttp
	 //action - task name / "none" if not present
	 //box_name - content id to change content
	 //item_id - product_id

	 xmlHttp=GetXmlHttpObject()
	 if (xmlHttp==null)
	 {
		 alert ("Browser does not support HTTP Request")
		 return
	 }

	 var url;
	 page++;
	 url= "twitter_pagination.php?user_id="+user_id+"&"+type+"_page="+page+"&type="+type;
	
	 xmlHttp.onreadystatechange=function()
	 {
		 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		 {
			if(xmlHttp.responseText) content.innerHTML += xmlHttp.responseText;
			document.getElementById(linkID).style.display='none';
		 }
	 }

	 xmlHttp.open("GET",url,true);
	 xmlHttp.send(null);
 
	 
 }

 /*retweeted users*/
 function retweet_pagination(type, user_id, linkID, tweetID)
 {
	var content;
	content = document.getElementById('retweet_pagination_'+tweetID);
	document.getElementById('users_'+tweetID).innerHTML = 'Loading..';

	var xmlHttp
	 //action - task name / "none" if not present
	 //box_name - content id to change content
	 //item_id - product_id

	 xmlHttp=GetXmlHttpObject()
	 if (xmlHttp==null)
	 {
		 alert ("Browser does not support HTTP Request")
		 return
	 }

	 var url;	
	 url= "twitter_pagination.php?user_id="+user_id+"&type="+type+"&tweet_id="+tweetID;

	 xmlHttp.onreadystatechange=function()
	 {
		 if(xmlHttp.readyState==3) document.getElementById('users_'+tweetID).innerHTML='<a href="#" style="font-size:10px; color:gray;" onClick="hide_retweet_users(\''+tweetID+'\', \''+user_id+'\');">Hide</a>';
		 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		 {
			if(xmlHttp.responseText) content.innerHTML += xmlHttp.responseText;
			document.getElementById('users_'+tweetID).innerHTML='<a href="#" style="font-size:10px; color:gray;" onClick="hide_retweet_users(\''+tweetID+'\', \''+user_id+'\');">Hide</a>';
		 }
	 }
	 
	 xmlHttp.open("GET",url,true);
	 xmlHttp.send(null);	
 	 
 }

 /*hide retweeted users*/
 function hide_retweet_users(tweetID, userID)
 {
	new_link = '<A style="font-size:10px; color:gray;" HREF="#pagination_'+tweetID+'" id="tweet_'+tweetID+'" onClick="retweet_pagination(\'retweetuser\',\''+userID+'\', this.id, '+tweetID+');">Show retweeting user(s)</A>';
	document.getElementById('users_'+tweetID).innerHTML = new_link;
	document.getElementById('retweet_pagination_'+tweetID).innerHTML='';
 }

 /*checkbox check*/
 function check(catID, fanID, autom)
 {
	var l= document.getElementsByName('filter').length, filter_url ='', filter_row = document.getElementById('filters'), new_url=ex=exp='';

	if(l)
	{   document.getElementById('loading').innerHTML = 'Loading..';
		/*filter row*/
		n =0;
		for(i=0; i<l; i++)
		{
		  if(document.getElementsByName('filter').item(i).checked == true)
		  {
			  filter_url += '&f'+n+++'='+encodeURI(document.getElementsByName('filter').item(i).value);			  
		  }
		}

		if(autom)
		{ filter_url = '';
		  current_url = window.location.href;
		  n=0;
		  ex = current_url.split('#');
		  if(ex[1])
		  {
			exp = ex[1].split('&');
			for(i=1; i < exp.length; i++)
			{
				filter_url += '&'+exp[i];
			}
		  }
		}

		window.location.href = filter_url ? '#'+filter_url : '#';
		var xmlHttp
		 //action - task name / "none" if not present
		 //box_name - content id to change content
		 //item_id - product_id

		 xmlHttp=GetXmlHttpObject()
		 if (xmlHttp==null)
		 {
			 alert ("Browser does not support HTTP Request")
			 return
		 }

		 var url;	
		 url= "/?page=160&filter_row=1&fanID="+fanID+"&catID="+catID+filter_url;
		 
		 xmlHttp.onreadystatechange=function()
		 {
			 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			 {
				if(xmlHttp.responseText) filter_row.innerHTML = xmlHttp.responseText;
				document.getElementById('loading').innerHTML = '';
			 }
		 }
		 
		 xmlHttp.open("GET",url,true);
		 xmlHttp.send(null);
		 /*filter row*/

		 item_content(fanID, catID, filter_url);
	
		
	}
	

  }

	/*filter content*/
	function item_content(fanID, catID, filter_url)
	{
		/*content*/
		 var content;
		 content = document.getElementById('item_content');
		 var xmlHttp
		 //action - task name / "none" if not present
		 //box_name - content id to change content
		 //item_id - product_id

		 xmlHttp=GetXmlHttpObject()
		 if (xmlHttp==null)
		 {
			 alert ("Browser does not support HTTP Request");
			 return;
		 }

		 var url;	
		 url= "/?page=160&content=1&fanID="+fanID+"&catID="+catID+filter_url;

		 xmlHttp.onreadystatechange=function()
		 {
			 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			 {
				if(xmlHttp.responseText) content.innerHTML = xmlHttp.responseText;
				if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
				 {
					if(xmlHttp.responseText) content.innerHTML = xmlHttp.responseText;
					tb_init('a.thickbox, area.thickbox, input.thickbox');
				 }
			 }
		 }		 
		 xmlHttp.open("GET",url,true);
		 xmlHttp.send(null);
		 /*content*/

		 
	}
	
function clear_filter() {
	for(i=0; i<document.getElementsByName('filter').length; i++)
	{
	  document.getElementsByName('filter').item(i).checked = false;
	}
}
