var uagent=navigator.userAgent.toLowerCase();
var is_safari=((uagent.indexOf('safari')!=-1)||(navigator.vendor=="Apple Computer, Inc.")||(uagent.indexOf('konqueror')!=-1)||(uagent.indexOf('khtml')!=-1));var is_opera=(uagent.indexOf('opera')!=-1);
var is_webtv=(uagent.indexOf('webtv')!=-1);
var is_ie=((uagent.indexOf('msie')!=-1)&&(!is_opera)&&(!is_safari)&&(!is_webtv));
var is_ie4=((is_ie)&&(uagent.indexOf("msie 4.")!=-1));var is_ie7=((is_ie)&&(uagent.indexOf("msie 7.")!=-1));
var is_moz=(navigator.product=='Gecko');
var is_ns=((uagent.indexOf('compatible')==-1)&&(uagent.indexOf('mozilla')!=-1)&&(!is_opera)&&(!is_webtv)&&(!is_safari));
var is_ns4=((is_ns)&&(parseInt(navigator.appVersion)==4));var is_win=((uagent.indexOf("win")!=-1)||(uagent.indexOf("16bit")!=-1));
var is_mac=((uagent.indexOf("mac")!=-1)||(navigator.vendor=="Apple Computer, Inc."));
var ua_vers=parseInt(navigator.appVersion);

loaderIsShown = false;
divIsShown = false;
centerdiv     = false;
a=5;

/*
function $(el){
  return document.getElementById(el);
}
*/

function showActiveMenu(id){
   try{
         if($(id)){
           $(id).style.display="block";
         }
   }
   catch(e){}   
}



function expand(id,level){ try{
   var tree = $('tree');	
 
   if($(id).style.display=="block"){
      $(id).style.display = "none";
   }
   else{
   	  walkChildNodes(tree,level);
      $(id).style.display = "block";
   }  }catch(e){} 
}



function walkChildNodes(obj,level) { try{
  var i, group, txt;
  group = obj.childNodes;
  for (i = 0; i < group.length; i++) {
   
     if(group[i].nodeType ==1 && group[i].tagName=='DIV'){
        if(group[i].style.display=='block'&& group[i].attributes['level'].value>=level){
           group[i].style.display ='none';
        }
     }

     if (group[i].childNodes.length > 0) {
        walkChildNodes(group[i],level);
     }
  }}catch(e){} 
}



function showDiv(id){try{
  $(id).style.visibility="visible";}catch(e){} 
}

function hideDiv(id){try{
	$(id).style.visibility="hidden";}catch(e){} 
}

function bold(id){try{
   id = 'l'+id;
   if($(id)){
      $(id).style.fontWeight = 'bold';
   }}catch(e){} 
}
 
function setlang(lang){
   var form = $('langswitcher');
   form.lang.value = lang;
   form.loc.value  = encodeURIComponent(window.location.href); //alert(form.loc.value);
   form.submit();
   return false;
}

function lang(lang)
{
  var current=window.location.href;
  var new_loc;
  if(/lang=/.test(current))
    new_loc=current.replace(/lang=\w+/,"lang="+lang);
  else if(/\?/.test(current))
    new_loc=current+"&lang="+lang;
  else 
    new_loc=current+"?lang="+lang;  
  window.location.replace(new_loc);
}

function showPic(dir,img){
   var div   =  document.getElementById("fullImage");
   var m_img =  dir+"/medium_"+img;
   var img   = dir+"/"+img;
   div.innerHTML  = "<div style=\"margin:20px;font-size:18px;color:#CBCBCB\">Loading...</div>";
   div.innerHTML += "<div id=\"tempDiv\" style=\"display:none\"><img src=\"" +m_img+"\" onload=\"javascript:document.getElementById('fullImage').innerHTML='<a href="+img+" target=_blank><img src="+m_img+"  border=0></a>'\"></div>";
}

function ann_showPic(dir, img, preffix){
	var div   = document.getElementById("fullImage");
	var m_img = dir + '/' + img;
	var img   = dir + '/original_' + img;
	div.innerHTML  = "<div style=\"margin:20px;font-size:18px;color:#CBCBCB\">Loading...</div>";
	div.innerHTML += "<div id=\"tempDiv\" style=\"display:none\"><img src=\"" +m_img+"\" onload=\"javascript:document.getElementById('fullImage').innerHTML='<a href="+img+" target=_blank><img src="+m_img+"  border=0></a>'\"></div>";
}

function showWindow(pic,width,height){ 
  sDesrc = "width=" + width + ", height=" + height +
  		", status=no, toolbar=no, menubar=no, scrollbars=no";
  win=window.open("Gallery", "displayWindow", sDesrc);
  win.document.write("<html><style>body{padding:0px;margin:0px;}</style><body>");
  win.document.write("<img src='"+pic+"' width='"+width+"' height='"+height+"'><br>");
  win.document.write("</body></html>");
} 



function print_innerHTML(parseFrom,iframeTo,css_src) {
	document.getElementById(iframeTo).contentWindow.document.body.innerHTML = document.getElementById(parseFrom).innerHTML;
	if (CheckIsIE()==true) {
		iframe = eval ('document.'+iframeTo);
		iframe.close();
		importCSS(get_DOC(document.getElementById(iframeTo)),css_src);
		iframe.focus();
		iframe.print();
	}
	else {
		importCSS(get_DOC(document.getElementById(iframeTo)),css_src);
		document.getElementById(iframeTo).contentWindow.print();
	}
}

function importCSS(doc, css) {
	var css_ary = css.replace(/\s+/, '').split(',');
	var csslen, elm, headArr, x, css_file;
	for (x = 0, csslen = css_ary.length; x<csslen; x++) {
		css_file = css_ary[x];
		if (css_file != null && css_file != 'null' && css_file.length > 0) {
			// Is relative, make absolute
			if (css_file.indexOf('://') == -1 && css_file.charAt(0) != '/')
				css_file = this.documentBasePath + "/" + css_file;

			if (typeof(doc.createStyleSheet) == "undefined") {
				elm = doc.createElement("link");
				elm.rel = "stylesheet";
				elm.href = css_file;
				if ((headArr = doc.getElementsByTagName("head")) != null && headArr.length > 0)
					headArr[0].appendChild(elm);
			} else
				doc.createStyleSheet(css_file);
		}
	}
}


function debugElement(id){
  var html;
  var elem = document.getElementById(id);
  try{
           ddiv = document.createElement("DIV");
           ddiv.setAttribute('id','__debug_div');
           ddiv.style.width    = "1000";
           ddiv.style.height   = "400";
           ddiv.style.background = "#fff";
           ddiv.style.border   = "1px solid #000";
          // ddiv.style.overflow = 'auto;'
           ddiv.style.position = 'absolute';
		   ddiv.style.top      = '20px';
		   ddiv.style.left     = '20px';	  
           document.body.appendChild(ddiv); 

  }
  catch(e){   
     alert("Debug failed :( !!! -"+ e.message);    
     return false;  
  }
   
  html += '<table style="width:980px" cellspacing="0" cellpadding="3" border="1" style="margin: 5px;border-collapse: collapse">';
  for(var property in elem){
     html +=  '<tr><td>'+property + '</td><td>' + elem[property] + "</td></tr>"; 
  }
  html += '</table>';
  
  document.getElementById('__debug_div').innerHTML = html;
}


function Rate(t,id,rate){
  var ref = encodeURIComponent(window.location.href);
  window.location.href='/rate.php?t='+t+'&id='+id+'&r='+rate+'&ref='+ref;
}


function hiliteRate(id,r){
    for(i=1;i<=r;i++){
      t_id = id+i; 
      document.getElementById(t_id).style.backgroundImage = 'url(/images/stars/sblue.gif)';
    }
}

function removeHilite(id,r){
    for(i=1;i<=5;i++){
      t_id = id+i; 
      document.getElementById(t_id).style.backgroundImage = 'none';
    }
}

function showHide(elmID,param) {
	var obj = document.getElementById(elmID);
	if (param == 'show' || param == 'block') {
		obj.style.display = 'block';
	}
	else if (param == 'hide' || param == 'none') {
		obj.style.display = 'none';
	}
	else {
		obj.style.display = (obj.style.display == 'none')?'block':'none';
	}
}

function center_div(){this.divname='';this.divobj='';this.shimobj='';}
center_div.prototype.move_div=function(){try{if(parent.document.getElementById(this.divname)){this._document=parent.document;this._window=parent.window;}}catch(e){return;}this.divobj=this._document.getElementById(this.divname);var my_width=0;var my_height=0;if(typeof(this._window.innerWidth)=='number'){my_width=this._window.innerWidth;my_height=this._window.innerHeight;}else if(this._document.documentElement&&(this._document.documentElement.clientWidth||this._document.documentElement.clientHeight)){my_width=this._document.documentElement.clientWidth;my_height=this._document.documentElement.clientHeight;}else if(this._document.body&&(this._document.body.clientWidth||this._document.body.clientHeight)){my_width=this._document.body.clientWidth;my_height=this._document.body.clientHeight;}this.divobj.style.position='absolute';this.divobj.style.display='block';this.divobj.style.zIndex=-1;if(is_ie){var layer_html=this.divobj.innerHTML;var full_html="<iframe id='"+this.divname+"-shim' src='images/iframe.html' class='iframshim' scrolling='no' frameborder='0' style='position:absolute; top:0px; left:0px; right:0px; display: none;'></iframe>"+layer_html;this.divobj.innerHTML=full_html;}if(is_ie){this.shimobj=this._document.getElementById(this.divname+"-shim");this.shimobj.style.width=(parseInt(this.divobj.offsetWidth)-5)+"px";this.shimobj.style.height=this.divobj.offsetHeight;this.shimobj.style.zIndex=this.divobj.style.zIndex-1;this.shimobj.style.top=this.divobj.style.top;this.shimobj.style.left=this.divobj.style.left;this.shimobj.style.display="block";}var divheight=parseInt(this.divobj.style.height)?parseInt(this.divobj.style.height):parseInt(this.divobj.offsetHeight);var divwidth=parseInt(this.divobj.style.width)?parseInt(this.divobj.style.width):parseInt(this.divobj.offsetWidth);divheight=divheight?divheight:200;divwidth=divwidth?divwidth:400;var scrolly=this.getYscroll();var setX=(my_width-divwidth)/2;var setY=(my_height-divheight)/2+scrolly;setX=(setX<0)?0:setX;setY=(setY<0)?0:setY;this.divobj.style.left=setX+"px";this.divobj.style.top=setY+"px";this.divobj.style.zIndex=99;};
center_div.prototype.hide_div=function(){try{if(!this.divobj){return;}else{this.divobj.style.display='none';}}catch(e){return;}};
center_div.prototype.getYscroll=function(){var scrollY=0;if(this._document.documentElement&&this._document.documentElement.scrollTop){scrollY=this._document.documentElement.scrollTop;}else if(this._document.body&&this._document.body.scrollTop){scrollY=this._document.body.scrollTop;}else if(this._window.pageYOffset){scrollY=this._window.pageYOffset;}else if(this._window.scrollY){scrollY=this._window.scrollY;}return scrollY;};
function add_shadow(wrapname,divname){var divobj=document.getElementById(divname);var wrapobj=document.getElementById(wrapname);if(is_ie){wrapobj.className='shadow-ie';wrapobj.style.width=divobj.offsetWidth+1+'px';wrapobj.style.height=divobj.offsetHeight+1+'px';}else{wrapobj.className='shadow-moz';wrapobj.style.width=divobj.offsetWidth+0+'px';wrapobj.style.height=divobj.offsetHeight+0+'px';}}

