function chsong(exsong,newsong,lid){
//	alert(exsong+" "+newsong);
//	$('#'+exsong)
	if(document.getElementById(exsong)!=null){
		document.getElementById(exsong).style.color = "#64643c";
	}
	if(document.getElementById(newsong)!=null){
		document.getElementById(newsong).style.color = "#ff0000";
	}
	appear('bms','/phps/bms.php?asd='+newsong+'&cu='+lid);
}

function appear(where,what){
	$("#"+where).load(what);
}

function loadbm(where,what){
//	$("#cms").toggle("slow");
	var method="POST";
	var dataString = "";
	$.ajax({
		type: method,
		data: dataString,
		url: what,
		success: function(rsps){
		if(where.length>1){
			$("#"+where).html(rsps);
			setTimeout('loadbm("'+where+'","'+what+'")',10000);
		}
	}

	})
}

function dw(where,what,wheret){
	if(wheret.length>1){
		$("#"+wheret).hide();
		$("#"+where).show();
	}
//	loadbm(where,what);
}

function cw(where,what){
	var method="POST";
	var dataString = "";
	$.ajax({
		type: method,
		data: dataString,
		url: what,
		success: function(rsps){
		if(where.length>1){
			$("#"+where).html(rsps);
		}
	}

	})
}

function getInfoPre(divId,pageLink,method,fieldNames,fieldsIds){
	var idsArray = fieldsIds.split("|");
	var values = '';
	for(var i=0;i<idsArray.length;i++){
		values +=$('#'+idsArray[i]).val();
		if(i<idsArray,length-1){
			values +="|";
		}
	}
	getInfo(divId,pageLink,method,fieldNames,values)
}

function getInfo(divId,pageLink,method,fields,values){
	var dataString = "";
	if(fields.length>0){
		var fieldsArray = fields.split("|");
		var valuesArray = values.split("|");
		dataString = fieldsArray[0]+"="+valuesArray[0];
		for(i=1;i<fieldsArray.length;i++){
//			alert(fieldsArray[i]);
			dataString += "&"+fieldsArray[i]+"="+valuesArray[i];
		}
	}

	$.ajax({
		type: method,
		data: dataString,
		url: pageLink,
		success: function(rsps){
		if(divId.length>1){
			$("#"+divId).html(rsps);
		}
	}

	})
}

function docbmx(where,what,wheret){
	if(wheret.length>1){
		$("#"+wheret).toggle();
		$("#"+where).toggle();
	}
	var method="POST";
	var dataString = "";
	$.ajax({
		type: method,
		data: dataString,
		url: what,
		success: function(rsps){
		if(where.length>1){
			$("#"+where).html(rsps);
		}
	}

	})	
}

function chSt(what,total){
	for(var i=0;i<total;i++){
		var idcl = "cl_"+i;
		if(document.getElementById(idcl)!=null){
			document.getElementById(idcl).style.backgroundColor = "";
		}
		var idtl = "tx_"+i;
		if(document.getElementById(idtl)!=null){
			document.getElementById(idtl).style.color = "#6B6B5E";
		}
	}
	idwh = "cl_"+what;
	document.getElementById(idwh).style.backgroundColor = "#6b6b5e";
	var idtl = "tx_"+what;
	if(document.getElementById(idtl)!=null){
		document.getElementById(idtl).style.color = "#dadad7";
	}
}

function changeMenu(divu,divd,divt,selclass,selcolor,neselclass,neselcolor){
	
	var udiv = document.getElementById(divu);
	var ddiv = document.getElementById(divd);
	var tdiv = document.getElementById(divt);
	
	udiv.className = selclass;
	udiv.style.backgroundColor = selcolor;
	
	ddiv.className = neselclass;
	ddiv.style.backgroundColor = neselcolor;
	
	tdiv.className = neselclass;
	tdiv.style.backgroundColor = neselcolor;
}

function showhide (divtoshow, divtohide)
{
var divs=document.getElementById(divtoshow);
var divh=document.getElementById(divtohide);
divs.style.display="";
divh.style.display="none";
}

function showhidet(divtoshow, divtohideu, divtohided)
{
var divs=document.getElementById(divtoshow);
var divh=document.getElementById(divtohideu);
var divhd=document.getElementById(divtohided);
divs.style.display="";
divh.style.display="none";
divhd.style.display="none";
}

function showsmenu(smenuTs){
	var all = new Array();
	all[1] = 'posturi_tematice';
	all[2] = 'bloguri';
	all[3] = 'shorturi';
	
	for(var i=1;i<=all.length;i++){
		if(document.getElementById(all[i])!=null){
			document.getElementById(all[i]).style.display = "none";
		}
	}
	document.getElementById(smenuTs).style.display = "";
}

function  sayIt(what)
{
	alert(what);
}

function updateValue(aid,m_name,m_value)
{
	var what = document.getElementById(aid);
	if(what!=null)
	{
		whatValue = what.value+","+m_value;
		what.value = whatValue;
	} else
		{
			document.write('<input type="hidden" name="'+m_name+'" id="'+aid+'" value="'+m_value+'">');	
		}
}

function appearp(where){
	if(where=='haf'){
		document.getElementById('sis').src = '/images/sis_nesel.jpg';
		document.getElementById('cin').src = '/images/cin_nesel.jpg';
		document.getElementById('haf').src = '/images/hf_sel.jpg';
	}
	
	if(where=='sis'){
		document.getElementById('sis').src = '/images/sis_sel.jpg';
		document.getElementById('cin').src = '/images/cin_nesel.jpg';
		document.getElementById('haf').src = '/images/hf_nesel.jpg';
	}
	
	if(where=='cin'){
		document.getElementById('sis').src = '/images/sis_nesel.jpg';
		document.getElementById('cin').src = '/images/cin_sel.jpg';
		document.getElementById('haf').src = '/images/hf_nesel.jpg';
	}
}

function cclasspr(where,classToC,classFromC,classToT,classFromT){
	
	var all = new Array();
	
	all[1] = 'luni';
	all[2] = 'marti';
	all[3] = 'miercuri';
	all[4] = 'joi';
	all[5] = 'vineri';
	all[6] = 'sambata';
	all[7] = 'duminica';
	
	for(var i=1;i<=7;i++){
		var whDiv = all[i]+"c";
		$("#"+whDiv).removeClass(classToC);
		$("#"+whDiv).addClass(classFromC);
		var whDivT = all[i]+"t";
		$("#"+whDivT).removeClass(classToT);
		$("#"+whDivT).addClass(classFromT);
	}
	
	var wherec = where+"c";
	var wheret = where+"t";
	
	$("#"+wherec).removeClass(classFromC);
	$("#"+wherec).addClass(classToC);
	
	$("#"+wheret).removeClass(classFromT);
	$("#"+wheret).addClass(classToT);
	
}

function openls(sati){
	window.open("/openls.php?sati="+sati+"&cmd=s","Sateliti","width=460,height=350,toolbars=0,scrollbars=0,location=0,status=0,resizable=0,menubar=0");
}

function openlm(){
	window.open("/openls.php?cmd=m","Sateliti","width=460,height=350,toolbars=0,scrollbars=0,location=0,status=0,resizable=0,menubar=0");
}

function load_pic(div_id){
	var curdiv='cam_'+div_id;
	var futdivid=(div_id%2)+1;
	var futdiv='cam_'+futdivid;
	var randomplm = Math.floor(Math.random()*11)+""+Math.floor(Math.random()*9)+""+Math.floor(Math.random()*11);
	document.getElementById(futdiv).innerHTML='';
	document.getElementById(futdiv).innerHTML='<img src="http://webcam.greenfm.ro/studio/capturi/webcam.jpg?'+randomplm+'" style="width:300px; height:225px;"/>';
	document.getElementById(futdiv).style.display='block';
	setTimeout("hide_it_hard('"+curdiv+"')",900);
	setTimeout("load_pic('"+futdivid+"')",2300);
}

function hide_it_hard(div_to_hide)
{
		var hide_it = document.getElementById(div_to_hide);
		hide_it.style.display = "none";
		hide_it.innerHTML = '';
}
function aload_pic(divid)
{
	setTimeout("load_pic('"+divid+"')",1000)
	setTimeout("load_new_pic('cam_al')",1000)
}

function chpic(responseDiv){
	var rand_no = 15*Math.random();
	var ajaxDisplay = document.getElementById(responseDiv);
	ajaxDisplay.src = 'http://webcam.greenfm.ro/sisters/DCS-910.jpg?'+rand_no;
	setTimeout("chpic('"+responseDiv+"')",5000);
}

function load_new_pic(responseDiv)
{
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			var ajaxDisplay = document.getElementById(responseDiv);
//			ajaxDisplay.innerHTML = "<img src='http://webcam.greenfm.ro/studio/"+ajaxRequest.responseText+"'>";
			ajaxDisplay.src = 'http://webcam.greenfm.ro/studio/'+ajaxRequest.responseText;
			setTimeout("load_new_pic('"+responseDiv+"')",5000);
			return true;
		} 
	}
//	var reg_tel =  eval('document.reg_toSite.reg_tel' + '.value'); 
//		var queryString = "?new_pic=" + new_pic + "&id=" + id + "&id_pic=" + id_pic + "&watermark=" + watermark + "&old_pic=" + old_pic + "&titlu=" + titlu + "&type=" + type;
		ajaxRequest.open("GET", "/phps/transport2.php?method=post&url=webcam.greenfm.ro/captura_2.php", true);
		ajaxRequest.send(null); 	
} 
