// JavaScript Document
function el(ObjID) {
	return document.getElementById(ObjID);
}

function ajaxRequest() {
	var ajaxRequest;
		try {
			ajaxRequest = new XMLHttpRequest();
		} catch (e){
			try{
				ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try{
					ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e){
					alert("Your browser broke!");
					return false;
				}
			}
		}
	return ajaxRequest;
}

function setView(siteID){
	var aR=ajaxRequest();
	aR.open("GET","/Resources/Php/setView.php?SiteID="+siteID+"&rand="+parseInt(Math.random()*99999999),true); 	
	aR.send(null);
}

function changeDivContent(div,page) {
	var aR=ajaxRequest();
	aR.onreadystatechange=function() {
		var div_container=el(div);
		if(aR.readyState==4) {
			div_container.innerHTML=aR.responseText;
		}
	}
	aR.open("GET",page+"&rand="+parseInt(Math.random()*99999999),true); 	
	aR.send(null);
}

function submitForm(form) {
	var sum=parseInt(el('firstNumber').value)+parseInt(el('secondNumber').value);
	if(el('resultNumber').value != sum) {
		alert('Verificarea Anti-Spam a esuat !');
		changeDivContent('anti-spam','/Resources/Php/anti-spam.php?id=0');
	} else {
		el(form).submit();
	}
}

function limitTextarea(limitNumber,Parent,Child) {
	var parentLength=el(Parent).value.length;
	if(parentLength <= limitNumber) {
		el(Child).value=limitNumber-el(Parent).value.length;	
	} else {
		el(Parent).value=el(Parent).value.substr(0,limitNumber);	
	}
}

function open_popup(file,width,height) {
	if(width!=0 && height!=0)
		var wh = ",width="+width+",height="+height;
	else
		var wh = "";
	 window.open (file,"mywindow","menubar=0,resizable=0,scrollbars=1"+wh);
}

$(document).ready(function(){
	jQuery('.rounded').corner();						   
});