	
	if (screen.width && screen.height) {
	var set_h = screen.width / 5;
	} else {
	var set_h = 215;
	}
	var set_v = 150;

function goTo(where) {
   	
   	document.location.replace(where);
   	return false; 

}

function popup_win(id) {

	if (screen.width && screen.height) {
	var set_h = screen.width / 4;
	} else {
	var set_h = 275;
	}
	var set_v = 100;

	var wblock = window.open(id,'popup','location=0,status=0,scrollbars,resizable=1,top='+set_v+',left='+set_h+',width=580,height=450');
	wblock.focus();

}

function image(picName, avatar) {
	
	if(avatar == 1) {
	window.open("image_zoom?avatar=1&n="+picName, "", "width=1, height=1, scrollbars=0, left=250, top=25");
	}
	
}


function set_win_width() {
	
	var set_width = 0;
	var verify_width = 0;
	var screen_width = window.screen.width;
        var verify_width = document.body.clientWidth;
    	
	
	if(verify_width && verify_width > 1006) {
	set_width =  verify_width - 298;
	document.getElementById('content').style.width = set_width + 'px';
	document.getElementById('set_width').style.width = screen_width - 100 + 'px';
	} else {
	document.getElementById('content').style.width = '715px';
	document.getElementById('set_width').style.width = '1003px';
	}


}


function resizeBox(){
	var evt = (evt) ? evt : ((window.event));
	var sObj = document.getElementById("body").style;
	
	sObj.width = "100%";
	
	if(evt.clientX < 900) {
	 sObj.width = "900px"; 
	 } else {
	 sObj.width = "100%";
	 }
} 



function close_block(name){
	
	if(name == 'general') {
	document.getElementById('general_block').style.display='none';
	document.getElementById('menu_block').style.display='block';
	}

	if(name == 'menu') {
	document.getElementById('general_block').style.display='block';
	document.getElementById('menu_block').style.display='none';
	}

}

function arrow_show(name){	
	
	document.getElementById(name).src='/img/'+name+'_2.png'; 

}

function arrow_hide(name){	
	
	document.getElementById(name).src='/img/'+name+'_1.png'; 

}

function btgr(){	
	
	document.getElementById('sbmbt').style.background='#FF0000'; 
	document.getElementById('sbmbt').style.color='#FFFFFF';

}

function btrd(){	
	
	document.getElementById('sbmbt').style.background='#00E600'; 
	document.getElementById('sbmbt').style.color='#41464B';

}

function btgr_or(){	
	
	document.getElementById('sbmbt_or').style.background='#FF0000'; 
	document.getElementById('sbmbt_or').style.color='#FFFFFF';

}

function btrd_or(){	
	
	document.getElementById('sbmbt_or').style.background='#FFCC00'; 
	document.getElementById('sbmbt_or').style.color='#41464B';

}


function display(){
	rtime = etime-ctime;
	if (rtime > 60)
	m=parseInt(rtime / 60);
	else { m=0; }
	s=parseInt(rtime-m*60);
	if(s<10)
	s="0"+s;
	window.status="Time Remaining: "+m+":"+s;
	window.setTimeout("checktime()", 1000);
}

function please_wait(){

	document.getElementById('form_block').style.display='none';
	document.getElementById('please_wait_block').style.display='block';
	location.hash = 'top';

	var time = new Date();
	hours = time.getHours();
	mins = time.getMinutes();
	secs = time.getSeconds();
	etime = hours*3600+mins*60+secs;
	etime += 600;
	checktime();

}

function checktime(){

	var time = new Date();
	hours = time.getHours();
	mins = time.getMinutes();
	secs = time.getSeconds();
	ctime = hours*3600+mins*60+secs;
	if(ctime>=etime){
	expired();
	} else {
	display();
	}
}

function expired(){

	// location.href="timeout";

}



function checkAll(oForm, cbName, checked) {
	oForm[cbName].checked = checked;
	if(oForm[cbName] && oForm[cbName].length > 0) {
		
		for (var i=0; i < oForm[cbName].length; i++)  {
		oForm[cbName][i].checked = checked;
		}
	
	}

}

function status_value(sel) {
	
	if(document.getElementById(sel).value == 1) {
	document.getElementById(sel).value = "0";
	} else {
	document.getElementById(sel).value = "1";
	}

}

function show_url_block(no_code) {
	
	document.submit_form.reset();
  	document.getElementById('upload_photo_url').style.display = 'block';
  	document.getElementById('upload_photo').style.display = 'none';
  	document.submit_form['td1'].checked = false;
  	document.submit_form['td2'].checked = true;

  	if(!no_code) {
  	document.getElementById('upload_photo_code').style.display = 'none';
  	}
  	
}

function show_browse_block(no_code) {
	
	document.submit_form.reset();
  	document.getElementById('upload_photo_url').style.display = 'none';
  	document.getElementById('upload_photo').style.display = 'block';
  	document.submit_form['td1'].checked = true;
  	document.submit_form['td2'].checked = false;

  	if(!no_code) {
  	document.getElementById('upload_photo_code').style.display = 'none';
  	}

}


function show_info_block(name) {

  	document.getElementById(name).style.display = 'block';
  	
}

function hide_info_block(name) {
  	
  	document.getElementById(name).style.display = 'none';
 
}

function load_ajax_script(addr){
	
	var ajax_cat = "/ajax/";
	
	document.getElementById('_ajax').innerHTML="AJAX <script></"+"script>";  

	setTimeout(function(){   
	scr = document.getElementById('_ajax').getElementsByTagName("script")[0];
	scr.type="text/javascript"; 
	if(scr.setAttribute)scr.setAttribute("src",ajax_cat + addr); else scr.src= ajax_cat + addr;   
	},50);  

}   

function show_block(name) {

	if (document.getElementById(name).style.display == 'none') {
	document.getElementById(name).style.display = 'block';
	} else {
	document.getElementById(name).style.display = 'none';
	}

}


function getElementsByClassName(className, tag, elm)  {
    var testClass = new RegExp("(^|\\\\s)" + className + "(\\\\s|$)");
    var tag = tag || "*";
    var elm = elm || document;
    var elements = (tag == "*" && elm.all)? elm.all : elm.getElementsByTagName(tag);
    var returnElements = [];
    var current;
    var length = elements.length;
    for(var i=0; i<length; i++){
        current = elements[i];
        if(testClass.test(current.className)){
            returnElements.push(current);
        }
    }
    return returnElements;

}

function showhint(e,evt,pos) {
	
	var evt = (evt) ? evt : ((window.event) ? event : null);
	var obj = e.childNodes[1];
	obj.style.display= "block";
	if(pos == 1) {
	obj.style.left = ((1024 - window.screen.width) / 2) + evt.clientX  + 240 + 'px';
	} else if(pos == 2) {
	obj.style.left = ((1024 - window.screen.width) / 2) + evt.clientX  - 40 + 'px';
	} else {
	obj.style.left = ((1024 - window.screen.width) / 2) + evt.clientX  + 'px';
	}
	
}

function hidehint(e) {
	
	e.childNodes[1].style.display= "none";

}

function row_constructor(str) {
	
	var text = '';
	var nodes = str.childNodes;
	
	for (var i = 0; i < nodes.length; i++) {
	var node = nodes.item(i);
	switch (node.nodeType) {
	case 1:
	text += row_constructor(node);
	break;
	case 3:
	case 4:
	text += node.data;
	break;
	}
	}
	return text;
}

function citation() {
	
	var uagent = navigator.userAgent.toLowerCase();
	var message = '';
	var write_message = document.getElementById('write_message');
	
    	if (document.getElementById('view_message')) {
        var split_to_rows = document.getElementById('view_message');
		
		if (split_to_rows.innerText && (uagent.indexOf('opera') == -1)){
		message = split_to_rows.innerText;
		} else if (split_to_rows.childNodes){
		message = row_constructor(split_to_rows);}
		var quote = "\r\n> ";
		message = quote + message.split(/[\r\n]{1}/).join(quote);
    		}
	
	write_message.value = message + "\r\n\r\n" + write_message.value;
	document.getElementById('citation').style.display = 'none';
	write_message.focus();
	
}


function show_write_message() {

	document.getElementById('reply_message').style.display = 'block';
	document.getElementById('write_subject').style.display = 'block';
	document.getElementById('show_write_link').style.display = 'none';
	document.getElementById('view_subject').style.display = 'none';

}

function add_comment(text,url,id,cid,level,mode,div,to,author) {
	
	if(document.getElementById("adcbl")) {
	document.getElementById("adcbl").parentNode.removeChild(document.getElementById("adcbl"));
	}
	
	if(!cid) {
	var cid = "0";
	}
	
	if(!level) {
	var level = "0";
	}

	if(!mode) {
	var mode = "1";
	}
	
	if(!div) {
	var div = cid;
	}

	var comment_form = '<div id="adcbl" style="position: relative; display: block;"><form action="/{3}" method="post" onSubmit="please_wait()" ><input type="hidden" name="insert_comment" value="1" /><input type="hidden" name="id" value="{1}" /><input type="hidden" name="cid" value="{2}" /><input type="hidden" name="level" value="{4}" /><input type="hidden" name="orig" value="{5}" /><input type="hidden" name="to" value="{6}" /><div style="border: 1px solid; padding: 15px; background-color: #FFF471;"><div style="margin-bottom: 5px;"><b>{8}:</b></div><textarea id="adcbl_com" name="comment" cols="30" rows="13" wrap="virtual" style="position: relative; width: 695px;" onkeypress="return textarea_length(this, 75000);"></textarea></div><div class="bl20" onMouseOver="btgr();" onMouseOut="btrd();" id="sbmtd"><input id="sbmbt" type="submit" value="{7}" class="button_gr" onClick="goTo(\'#top\'); " /></div><div class="bl_space"></div></form></div>';

	comment_form = comment_form.replace("{1}", id);
	comment_form = comment_form.replace("{2}", cid);
	comment_form = comment_form.replace("{3}", url);
	comment_form = comment_form.replace("{4}", level);
	comment_form = comment_form.replace("{5}", mode);
	comment_form = comment_form.replace("{6}", to);
	comment_form = comment_form.replace("{7}", text);
	comment_form = comment_form.replace("{8}", author);
	
	document.getElementById("add_comment_" + div).innerHTML += comment_form;
	
	if(document.getElementById("adcbl")) {
	setTimeout(function () { 
	document.getElementById("adcbl_com").focus();
	},250);
	}
}

function add_error_message(text,url,message) {

	if(document.getElementById("adcbl")) {
	document.getElementById("adcbl").parentNode.removeChild(document.getElementById("adcbl"));
	}
	
	var comment_form = '<div id="adcbl" style="position: relative; display: block;"><form action="/{4}" method="post" onSubmit="please_wait()" ><input type="hidden" name="error_url" value="{1}" /><input type="hidden" name="insert_error_message" value="1" /><div style="border: 1px solid; padding: 15px; background-color: #FFF471;">{3}<br /><br /><textarea id="adcbl_com" name="error_message" cols="30" rows="13" wrap="virtual" style="position: relative; width: 695px;" onkeypress="return textarea_length(this, 75000);"></textarea></div><div class="bl20" onMouseOver="btgr();" onMouseOut="btrd();" id="sbmtd"><input id="sbmbt" type="submit" value="{2}" class="button_gr" onClick="goTo(\'#top\'); " /></div><div class="bl_space"></div></form></div>';

	comment_form = comment_form.replace("{1}", url);
	comment_form = comment_form.replace("{2}", text);
	comment_form = comment_form.replace("{3}", message);
	comment_form = comment_form.replace("{4}", url);
	
	document.getElementById("add_comment_0").innerHTML += comment_form;
	
	if(document.getElementById("adcbl")) {
	setTimeout(function () { 
	document.getElementById("adcbl_com").focus();
	},250);
	}
}

function add_recomendation(name,title,url,button,div) {
	
	if(document.getElementById("adrbl")) {
	document.getElementById("adrbl").parentNode.removeChild(document.getElementById("adrbl"));
	}
	
	var recomendation_form = '<div id="adrbl" style="position: absolute; margin-top: -45px; padding: 15px; background-color: #F6F6E0; border: 1px solid #C0C0C0;"><form action="recommendation" method="post"><b class="grey">{1}</b>:<br /><input type="hidden" name="shortcut_title" value="{2}"><input type="hidden" name="shortcut" value="{3}">{5}<div style="margin-top: 10px;">Email: <input type="text" style="width: 210px;" name="to_email"> <input type="submit" value="{4}" style="width: 150px;"></div></form></div>';
	
	recomendation_form = recomendation_form.replace("{1}", name);
	recomendation_form = recomendation_form.replace("{2}", title);
	recomendation_form = recomendation_form.replace("{3}", url);
	recomendation_form = recomendation_form.replace("{4}", button);
	recomendation_form = recomendation_form.replace("{5}", url);
	
	document.getElementById("view_shortcut" + div).innerHTML += recomendation_form;
	
	if(document.getElementById("adrbl")) {
	setTimeout(function () { 
	document.getElementById("adrbl").focus();
	},250);
	}
}

function add_no_comment(text,div) {
	
	if(document.getElementById("adcbl")) {
	document.getElementById("adcbl").parentNode.removeChild(document.getElementById("adcbl"));
	}
	
	if(!div) {
	var div = "0";
	}	
	
	var comment_form = '<div id="adcbl" style="position: relative; margin-bottom: 15px; padding: 15px; background-color: #FFF471; display: block;">'+text+'</div>';

	document.getElementById("add_comment_" + div).innerHTML += comment_form;
	
	if(document.getElementById("adcbl")) {
	setTimeout(function () { 
	document.getElementById("adcbl").focus();
	},250);
	}
}

function textarea_length(Object, MaxLen, show_dig) {

	text = Object.value;
	text_num = text.length;

	if(text_num >= MaxLen) {
	Object.value = text.substring(0, MaxLen);
	}  	  	
	
	if(show_dig) {
	if(MaxLen - text_num > 0) {
	document.getElementById('show_dig').innerHTML = MaxLen - text_num; 
	} else {
	document.getElementById('show_dig').innerHTML = 0; 
	}
	}
	
}

function startclock() {
	
	setTimeout('startclock()',1000);
	showtime();
	seconds++;
	if(seconds>59)
	{minutes++;
	seconds=0;
	if(minutes>59)
	{hours++;
	minutes=0;
	if(hours>23){hours=0;
	}
	}
	}

}
	
function zerodraw(strin) {
	
	if(strin<10)
	{zz='0'+strin}
	else{zz=strin};

}

function showtime() {
	
	var mm='';
	zerodraw(hours);
	mm=mm+zz+':';
	zerodraw(minutes);
	mm=mm+zz+':';
	zerodraw(seconds);
	mm=mm+zz;
	Clck.innerHTML=mm;
}

function delete_set_hotnews() {

	document.getElementById("insert_hotnews").innerHTML = "";
	
}