 function show(x) {
	document.getElementById(x).style.display='block';
}

function hide(x) {
	document.getElementById(x).style.display='none';
}

function swapbg(x,y) {
	document.getElementById(x).style.backgroundImage = "url(../design/images/servicii/"+y+")";
}

function setbold(x){
		document.getElementById(x).style.fontWeight = 'bold';
}

function unbold(x){
		document.getElementById(x).style.fontWeight = 'normal';
}

function confirmDelete(){
	if (confirm('You cannot undo this operation. Are you sure?')) { return true; }
	return false;
}

function selectImg(x,list){
	str=document.getElementById(list).value;
	pos=str.indexOf(";"+x.alt);
	if(pos==-1){
		document.getElementById(list).value = document.getElementById(list).value + x.alt + ';';
		x.style.borderColor="#ff0000";
	} else {
		x.style.borderColor="#ffffff";
		var k = str.replace(";"+x.alt+";",";");
		document.getElementById(list).value = k;
		}
}

		
	
function addTA(id){
		//tinyMCE.idCounter=0;
		tinyMCE.execCommand('mceAddControl',true,id);
}
		
		
function remTA(id){
		//tinyMCE.idCounter=0;
		tinyMCE.execCommand('mceRemoveControl',true,id);
}





//begin jquery


//SETTING UP OUR POPUP
//0 means disabled; 1 means enabled;
var popupStatus = 0;

//loading popup with jQuery magic!
function loadPopup(){
	createCookie('support','no',1);
	centerPopup();
	//loads popup only if it is disabled
	if(popupStatus==0){
		$("#backgroundPopup").css({
			"opacity": "0.7"
		});
		$("#backgroundPopup").fadeIn("normal");
		$("#popupWindow").fadeIn("normal");
		popupStatus = 1;
	}
}

//disabling popup with jQuery magic!
function disablePopup(){
	createCookie('support','no',1)
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("normal");
		$("#popupWindow").fadeOut("normal");
		popupStatus = 0;
	}
}

//centering popup
function centerPopup(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popupWindow").height();
	var popupWidth = $("#popupWindow").width();
	//centering
	$("#popupWindow").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	
	$("#backgroundPopup").css({
		"height": windowHeight
	});
	
}


//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){
	
	checkSupport();	
	
	//LOADING POPUP
	//Click the button event!
	$("#support").click(function(){
		//centerPopup();
		loadPopup();
	});
			
		
	//CLOSING POPUP
	//Click the x event!
	$("#popupClose").click(function(){
		disablePopup();
	});
	$("#supportNo").click(function(){
		disablePopup();
	});
	//Click out event!
	$("#backgroundPopup").click(function(){
		disablePopup();
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus==1){
			disablePopup();
		}
	});

});


function loadContent(elementSelector, sourceUrl) {
	$(""+elementSelector+"").load(""+sourceUrl+"");
}
//end jquery




//begin cookie
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}
//end cookie


function checkSupport(){
	var x = readCookie('support');
	var t;
	if (x == 'no') {  }
	else{
		//t = setTimeout("loadPopup()",30000); 
	}	
}
