// JavaScript Document

////////////////
function tout(q){
document.getElementById(q).style.backgroundColor = 'transparent';
}
function tover(q)
{
document.getElementById(q).style.backgroundColor='#E4E4E4';
document.getElementById(q).style.cursor='pointer';
}


function LmUp(path) {location.href = path;}


///ОрлокшჟჰჯკჰрРолОЛролролЖШж
var http = false;
if(navigator.appName == "Microsoft Internet Explorer")
{
http = new ActiveXObject("Microsoft.XMLHTTP");
}
else
{
http = new XMLHttpRequest();
}
//////////////////////// axali gverdis gamokvanaa
function axali_con(url,obi)
{
http.abort();
http.open("GET", url, true);
http.onreadystatechange=function()
{
if(http.readyState == 4)
{
document.getElementById(obi).innerHTML = http.responseText;
}
}
http.send(null);
}
/////////////////////////////// axali gverdis bebismier shuashu gamokvana
///reklamissss daicko
function gachena(id)
{
document.getElementById(id).style.display="block";
}
function gakroba(id)
{
document.getElementById(id).style.display="none";
}
///rekalmis morcha
function shecvla(a,b)
{ 
document.getElementById(a).style.display="none";
document.getElementById(b).style.display="block";

}





function damatebis_dacva()
{
if(document.addnews.main_cat_id.value ==0 || document.addnews.sub_cat_id.value == 0){
document.addnews.main_cat_id.style.backgroundColor = '#A40000';
document.addnews.sub_cat_id_add.style.backgroundColor = '#A40000';

return false;
}else{
   if(document.addnews.titl.value == ''){
     document.addnews.titl.style.backgroundColor = '#3cf';
     document.addnews.titl.focus();
     return false;
      }else{
		  if(document.addnews.text.value=='')
		  {document.addnews.text.style.backgroundColor = '#3cf';
           document.addnews.text.focus();
           return false;
		   }else{
			if((document.addnews.email.value.indexOf('@') == -1) || (document.addnews.email.value.indexOf('.') == -1))
          {
        document.addnews.email.style.backgroundColor="#3cf";
        document.addnews.email.focus();
        return false; 
		}else{    
		        if((document.addnews.mnishvneliaa.value!=document.addnews.mnishvneli.value)){
        document.addnews.mnishvneli.style.backgroundColor="#3cf";
        document.addnews.mnishvneli.focus();
		document.addnews.mnishvneli.value = '';
		return false;
		}
		}
			   }
		    
		  }
    
}
}
// damtavrda gancxadbeis damatebis foriis dacva
function user_valid(id,l)
{
http.abort();
http.open("GET", "ajax/registracia.php?user="+id+"&leng="+l, true);
http.onreadystatechange=function()
{
if(http.readyState == 4)
{
document.getElementById('eror_div').innerHTML = http.responseText;
}
}
http.send(null);
}
//useris shemocmeba morcha


// gare banerebis gageba clickze 
function banner_click(cxrili,baner_id,pozicia,raodenoba)
{
http.abort();
http.open("GET", "ajax/baner_click.php?cxr="+cxrili+"&ban_id="+baner_id+"&pozicia="+pozicia+"&raodenoba="+raodenoba, true);
http.onreadystatechange=function()
{
if(http.readyState == 4)
{
adgili = cxrili+raodenoba;
document.getElementById(adgili).innerHTML = http.responseText;
}
}
http.send(null);
}
// gare banerebis gageba clickze morcha

function favorite(id,ena) { 
http.abort();
http.open("GET", "favorite.php?news_id="+id+"&leng="+ena, true);
http.onreadystatechange=function()
{
if(http.readyState == 4)
{
document.getElementById(id).innerHTML = http.responseText;
}
}
http.send(null);	
}
//useris validavia morcha
//////////////////////// axali gverdis gamokvanaa
function axali_con(url,obi)
{
http.abort();
http.open("GET", url, true);
http.onreadystatechange=function()
{
if(http.readyState == 4)
{
document.getElementById(obi).innerHTML = http.responseText;
}
}
http.send(null);
}
/////////////////////////////// axali gverdis bebismier shuashu gamokvana
///////////////////////////////////////////////////
// diebis formis dacva 
function search_sdacva(q){
n = q.sadzebni.value;
sss=n.length;
if(sss<3){
q.sadzebni.style.backgroundColor = '#A40000';
q.sadzebni.focus();
//document.add_news_f.main_cat_id.user.focus();
return false;
}
}
/// damtavrda dziebis formis dacva
function mnishvnelis_shecvla(ieqt,mnish)
{ 
if(ieqt=="regitraciis"){
	document.registr.mnishvneli.value='';
	document.registr.mnishvneliaa.value=mnish;
	}
if(ieqt=="gancaxdadd"){
	document.addnews.mnishvneli.value='';
	document.addnews.mnishvneliaa.value=mnish;
	}
if(ieqt=="updatenews"){
	document.updatenews.mnishvneli.value='';
	document.updatenews.mnishvneliaa.value=mnish;
	}
}
//////////////////////////////////////////////////////
/////////////////////////////////////////////////////
/* dzveli ajaqci daicko */
var xmlHttp
function shemdegi_icons(objec,formis,l)
{ 
if(formis=="addnews"){ var sub_cattt=document.addnews.sub_cat_id.value; }
if(formis=="updatenews"){ var sub_cattt=document.updatenews.sub_cat_id.value;}	
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
alert ("Browser does not subport HTTP Request")
 return false;
 }
var url="ajax/news_icon.php"
url=url+"?sub_id="+sub_cattt;
url=url+"&icon_ob="+objec;
url=url+"&leng="+l;
url=url+"&icon_form="+formis;
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 document.getElementById(objec).innerHTML=xmlHttp.responseText;
 } 
}
}
/* qveda yvelas ertad exeba */
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 enaing1()
{ if(document.addnews.georgiankb.checked == true)
{ document.addnews.georgiankb.checked = false;}
}
function enaing()
{ if(document.updatenews.georgiankb.checked == true)
{ document.updatenews.georgiankb.checked = false;}
}



function mainc(a,b,l){  
if(b=="sub_cat_id_add"){
	document.addnews.sub_cat_id.value=a;
	document.addnews.main_cat_id.style.backgroundColor = '#CCC';
	return shemdegi_icons('shemdegiadd','addnews',l);
	}
if(b=="sub_cat_id_update"){
	document.updatenews.sub_cat_id.value=a;
	document.updatenews.main_cat_id.style.backgroundColor = '#CCC';
	return shemdegi_icons('shemdegiup','updatenews',l);
	}
}


function moinishna_ikoni(b,c){
if(c=="addnews"){document.addnews.icona.value=b;  }
if(c=="updatenews"){document.updatenews.icona.value=b;  }

	}

