
function toggle(objid){
  cb = document.getElementById(objid);
  if(cb.style.visibility=='visible'){
    cb.style.visibility='hidden';
    cb.style.display='none';
  }
  else{
    cb.style.visibility='visible';
    cb.style.display='block';
  }
}

function show(objid){
  cb = document.getElementById(objid);
  cb.style.visibility='visible';
  cb.style.display='block';
}

function hide(objid){
  cb = document.getElementById(objid);
  cb.style.visibility='hidden';
  cb.style.display='none';
}

function class_hide(theClass){
 var allTags = document.getElementsByTagName('*');
 for(i=0; i<allTags.length; i++){
  if(allTags[i].className == theClass) allTags[i].style.display = 'none';
 }
}

function class_show(theClass){
 var allTags = document.getElementsByTagName('*');
 for(i=0; i<allTags.length; i++){
  if(allTags[i].className == theClass) allTags[i].style.display = '';
 }
}

function set_var(s,v){
  if(v==true) v=1;
  if(v==false) v=0;
  if(document.images){
    (new Image).src="setvar.php?s="+s+"&v="+v+""+"&"+Math.floor(Math.random()*1000000);
  }
}

function change_class_id(id, newClass){
  identity=document.getElementById(id);
  identity.className=newClass;
}

var voted = new Array();

function answer(qtnno,opt){
  if (voted[qtnno] == 1){
  alert("No cheating!");
  return false;
  }
  voted[qtnno] = 1;
  document.getElementById("ans"+qtnno).style.fontWeight = "Bold";
  if(opt.value == 1){
    document.getElementById("ans"+qtnno).style.color = "green";
  }
  else{
    document.getElementById("ans"+qtnno).style.color = "red";
  }
}

function delay(sec){
	var date = new Date();
	var curDate = null;

	do { curDate = new Date(); }
	while(curDate-date < sec*1000);
} 

function change_font_size(element,step){
	step = parseInt(step,10);
	var el = document.getElementById(element);
	var el_size = document.getElementById(element).style.fontSize;
	var el_size = el_size.substring(0, el_size.length-2);
	var curFont = parseInt(el.style.fontSize,10);
	if(curFont<11){curFont = 11;}
	if(curFont>16){curFont = 16;}
	el.style.fontSize = (curFont+step) + 'px';
	set_cookie("ts",curFont+step,"30")
}

function set_cookie(name,value,expires){
  var exdate=new Date();
  exdate.setDate(exdate.getDate()+expires);
  document.cookie=name+ "=" +escape(value)+((expires==null) ? "" : ";expires="+exdate.toGMTString());
}

function get_cookie(name){
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(name + "=");
  if (c_start!=-1)
    { 
    c_start=c_start + name.length+1; 
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
  return "";
}

function bookmark_page(){
	title = document.title;
	url = window.location.href;
	if (window.sidebar){ // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	}
	//else if(window.external){ // IE Favorite
	else if(document.all){ // IE Favorite
		window.external.AddFavorite(url, title);
	}else if(window.opera && window.print){ // Opera Hotlist
		//var elem = document.createElement('a');
		//elem.setAttribute('href',url);
		//elem.setAttribute('title',title);
		//elem.setAttribute('rel','sidebar');
		//elem.click();
		alert("Press 'Ctrl+D' to bookmark this page");
	}else{
		alert("Press 'Ctrl+D' to bookmark this page");
	}
}

function scroll_to_element(id){
    if((obj = document.getElementById(id)) && obj != null){
        window.scrollTo(0, obj.offsetTop);
    }
}

/*###########################################*/

function show_div(divid){
  cb = document.getElementById(divid);
  if(cb.style.visibility=='visible'){
    cb.style.visibility='hidden';
    cb.style.display='none';
  }
  else{
    cb.style.visibility='visible';
    cb.style.display='block';
  }
}

function div_show(divid){
  cb = document.getElementById(divid);
  cb.style.visibility='visible';
  cb.style.display='block';
}

function div_hide(divid){
  cb = document.getElementById(divid);
  cb.style.visibility='hidden';
  cb.style.display='none';
}

function set_var(s,v){
  if(v==true) v=1;
  if(v==false) v=0;
  if(document.images){
    (new Image).src="setvar.php?s="+s+"&v="+v+""+"&"+Math.floor(Math.random()*1000000);
  }
}

function popup(w,h,u,n){
  popup=window.open(u,n,"width="+w+",height="+h+",toolbar=no,menubar=no,status=no,location=no,directories=no,scrollbars=no,resizable=yes");
  popup.moveTo(200,200);
}

function  emailArticle(NewsID,CatID){
  str_Newsid=NewsID
  str_Category=CatID
  str_URL="/emailthisarticle910.php?newsid="+str_Newsid+"&catid="+str_Category
  if (screen.width > 800)
  {
    w1 = window.open(str_URL,"test","Top=5,left=0,height=600,width=800, scrollbars=yes")
  }
  else {
    w1 = window.open(str_URL,"test","Top=5,left=0,height=500,width=600,scrollbars=yes")
  }
}

