function maximizare_fereastra() {
	window.moveTo(0,0)
	window.resizeTo(screen.width,screen.height)
}

function myalert(x) {
	x	=	x.replace( /&acirc;/g, String.fromCharCode( 226 ) );
	x	=	x.replace( /&Acirc;/g, String.fromCharCode( 194 ) );
	x	=	x.replace( /&icirc;/g, String.fromCharCode( 238 ) );
	x	=	x.replace( /&Icirc;/g, String.fromCharCode( 206 ) );
	x	=	x.replace( /&#259;/g, String.fromCharCode( 259 ) );
	x	=	x.replace( /&#258;/g, String.fromCharCode( 258 ) );
	x	=	x.replace( /&#238;/g, String.fromCharCode( 238 ) );
	x	=	x.replace( /&#237;/g, String.fromCharCode( 237 ) );
	x	=	x.replace( /&#351;/g, String.fromCharCode( 351 ) );
	x	=	x.replace( /&#350;/g, String.fromCharCode( 350 ) );
	x	=	x.replace( /&#355;/g, String.fromCharCode( 355 ) );
	x	=	x.replace( /&#354;/g, String.fromCharCode( 354 ) );
	alert( x );
}

function myconfirm(x) {
	x	=	x.replace( /&acirc;/g, String.fromCharCode( 226 ) );
	x	=	x.replace( /&Acirc;/g, String.fromCharCode( 194 ) );
	x	=	x.replace( /&icirc;/g, String.fromCharCode( 238 ) );
	x	=	x.replace( /&Icirc;/g, String.fromCharCode( 206 ) );
	x	=	x.replace( /&#259;/g, String.fromCharCode( 259 ) );
	x	=	x.replace( /&#258;/g, String.fromCharCode( 258 ) );
	x	=	x.replace( /&#238;/g, String.fromCharCode( 238 ) );
	x	=	x.replace( /&#237;/g, String.fromCharCode( 237 ) );
	x	=	x.replace( /&#351;/g, String.fromCharCode( 351 ) );
	x	=	x.replace( /&#350;/g, String.fromCharCode( 350 ) );
	x	=	x.replace( /&#355;/g, String.fromCharCode( 355 ) );
	x	=	x.replace( /&#354;/g, String.fromCharCode( 354 ) );
	r = confirm (x) ;
	return r ;
}

function checkemail(id) {
	var testresults ;
	var str = $(id).value ;
	var filter=/^.+@.+\..{2,3}$/ ;
	
	if (filter.test(str))
		return true ;
	else		
		return false ;	
}

function findPosX(obj) {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) {
          	curleft += obj.offsetLeft;
          	if(!obj.offsetParent)
            	break;
          	obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
}

function findPosY(obj) {
    var curtop = 0;
    if(obj.offsetParent)
        while(1) {
          	curtop += obj.offsetTop;
          	if(!obj.offsetParent)
            	break;
          	obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
}

function move_To(id, x, y) {
	//alert (id) ;
	//alert (x) ;
	//alert (y) ;
	$(id).style.top = parseInt(y) + "px" ;
	$(id).style.left = parseInt(x) + "px" ;
}

//	sterge spatiile de la inceput
function LTrim(value) {
	var re = /\s*((\S+\s*)*)/ ;
	return value.replace(re, "$1") ;
}

//	sterge spatiile de la sfarsit
function RTrim(value) {
	var re = /((\s*\S+)*)\s*/ ;
	return value.replace(re, "$1") ;
}

//	sterge spatiile de la inceput si de la sfarsit
function trim(value) {
	return LTrim(RTrim(value)) ;	
}

function rest(x, y) {//restul impartirii lui x la y
	if (y == 0)
		myalert("Valoarea &icirc;mp&#259;r&#355;itorului trebuie s&#259; fie diferit&#259; de 0 !!!")
	else
		restul = x/y - Math.floor(x/y) 
	return restul
}

// Crearea unui cookie si atribuirea acesteia unei valori
function setCookie(c_name,value,expiredays) {
	var exdate = new Date();
	exdate.setDate(exdate.getDate() + expiredays);
	var string = "" ;
	string += c_name ;
	string += "=" ;
	string += escape(value) ;
	string += (expiredays==null) ? "" : ";expires=" ;
	string += exdate.toGMTString() ;
	document.cookie = string ; 
}

// Stergerea unui cookie
function unsetCookie(c_name) {
	//var x = getCookie(c_name) ;
	//if (x) 
		setCookie(c_name,'',-1) ;
}



// Verifica daca a fost creata o anumita variabila cookie si returneaza valoarea acesteia
function getCookie(c_name) {
	if (document.cookie.length > 0) {
		c_start = document.cookie.indexOf(c_name + "=");
		if (c_start != -1) { 
			c_start = c_start + c_name.length + 1; 
			c_end = document.cookie.indexOf(";",c_start);
			if (c_end == -1)
				c_end = document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
		} 
	}
	return "";
}

///////////////////////////////////////////////////////////////////////////////////////////////////
//	USED FOR GETTING THE COMPUTED WIDTH OF AN ELEMENT IN PIXELS
//	el - Object
//	includePadding - boolean
//	includeBorder - boolean
///////////////////////////////////////////////////////////////////////////////////////////////////
function getWidth(el, includePadding, includeBorder) {
    var width;
    el = (typeof(el) === "string") ? document.getElementById(el) : el;	
    
    if (window.getComputedStyle) { // FF, Safari, Opera
        var style = document.defaultView.getComputedStyle(el, null);
        if (style.getPropertyValue("display") === "none")
            return 0;
        width = parseInt(style.getPropertyValue("width"));
        
        if (/opera/i.test(navigator.userAgent)) {
            // opera includes the padding and border when reporting the width/height - subtract that out
            width -= parseInt(style.getPropertyValue("padding-left"));
            width -= parseInt(style.getPropertyValue("padding-right"));
            width -= parseInt(style.getPropertyValue("border-left-width"));
            width -= parseInt(style.getPropertyValue("border-right-width"));
        }
        
        if (includePadding) {
            width += parseInt(style.getPropertyValue("padding-left"));
            width += parseInt(style.getPropertyValue("padding-right"));
        }
        
        if (includeBorder) {
            width += parseInt(style.getPropertyValue("border-left-width"));
            width += parseInt(style.getPropertyValue("border-right-width"));
        }
    } else { // IE
        if (el.currentStyle["display"] === "none")
            return 0;
        var bRegex = /thin|medium|thick/; // regex for css border width keywords
        width = el.offsetWidth; // currently the width including padding + border
        
        if (!includeBorder) {
            var borderLeftCSS = el.currentStyle["borderLeftWidth"];
            var borderRightCSS = el.currentStyle["borderRightWidth"];
            var temp = document.createElement("DIV");
            if (el.offsetWidth > el.clientWidth && el.currentStyle["borderLeftStyle"] !== "none") {
                if (!bRegex.test(borderLeftCSS)) {
                    temp.style.width = borderLeftCSS;
                    el.parentNode.appendChild(temp);
                    width -= Math.round(temp.offsetWidth);
                    el.parentNode.removeChild(temp);
                } else if (bRegex.test(borderLeftCSS)) {
                    temp.style.width = "10px";
                    temp.style.border = borderLeftCSS + " " + el.currentStyle["borderLeftStyle"] + " #000000";
                    el.parentNode.appendChild(temp);
                    width -= Math.round((temp.offsetWidth-10)/2);
                    el.parentNode.removeChild(temp);
                }
            }
            if (el.offsetWidth > el.clientWidth && el.currentStyle["borderRightStyle"] !== "none") {
                if (!bRegex.test(borderRightCSS)) {
                    temp.style.width = borderRightCSS;
                    el.parentNode.appendChild(temp);
                    width -= Math.round(temp.offsetWidth);
                    el.parentNode.removeChild(temp);
                } else if (bRegex.test(borderRightCSS)) {
                    temp.style.width = "10px";
                    temp.style.border = borderRightCSS + " " + el.currentStyle["borderRightStyle"] + " #000000";
                    el.parentNode.appendChild(temp);
                    width -= Math.round((temp.offsetWidth-10)/2);
                    el.parentNode.removeChild(temp);
                }
            }
        }
        
        if (!includePadding) {
            var paddingLeftCSS = el.currentStyle["paddingLeft"];
            var paddingRightCSS = el.currentStyle["paddingRight"];
            var temp = document.createElement("DIV");
            temp.style.width = paddingLeftCSS;
            el.parentNode.appendChild(temp);
            width -= Math.round(temp.offsetWidth);
            temp.style.width = paddingRightCSS;
            width -= Math.round(temp.offsetWidth);
            el.parentNode.removeChild(temp);
        }
    }
    
    return width;
}

///////////////////////////////////////////////////////////////////////////////////////////////////
// 	USED FOR GETTING THE COMPUTED HEIGHT OF AN ELEMENT IN PIXELS
//	el - Object
//	includePadding - boolean
//	includeBorder - boolean
///////////////////////////////////////////////////////////////////////////////////////////////////
function getHeight(el, includePadding, includeBorder) {
    var height;
    el = (typeof(el) === "string") ? document.getElementById(el) : el;
    
    if (window.getComputedStyle) { // FF, Safari, Opera
        var style = document.defaultView.getComputedStyle(el, null);
        if (style.getPropertyValue("display") === "none")
            return 0;
        height = parseInt(style.getPropertyValue("height"));
        
        if (/opera/i.test(navigator.userAgent)) {
            // opera includes the padding and border when reporting the width/height - subtract that out
            height -= parseInt(style.getPropertyValue("padding-top"));
            height -= parseInt(style.getPropertyValue("padding-bottom"));
            height -= parseInt(style.getPropertyValue("border-top-width"));
            height -= parseInt(style.getPropertyValue("border-bottom-width"));
        }
        
        if (includePadding) {
            height += parseInt(style.getPropertyValue("padding-top"));
            height += parseInt(style.getPropertyValue("padding-bottom"));
        }
        
        if (includeBorder) {
            height += parseInt(style.getPropertyValue("border-top-width"));
            height += parseInt(style.getPropertyValue("border-bottom-width"));
        }
    } else { // IE
        if (el.currentStyle["display"] === "none")
            return 0;
        var bRegex = /thin|medium|thick/; // regex for css border width keywords
        height = el.offsetHeight; // currently the height including padding + border
    
        if (!includeBorder) {
            var borderTopCSS = el.currentStyle["borderTopWidth"];
            var borderBottomCSS = el.currentStyle["borderBottomWidth"];
            var temp = document.createElement("DIV");
            if (el.offsetHeight > el.clientHeight && el.currentStyle["borderTopStyle"] !== "none") {
                if (!bRegex.test(borderTopCSS)) {
                    temp.style.width = borderTopCSS;
                    el.parentNode.appendChild(temp);
                    height -= Math.round(temp.offsetWidth);
                    el.parentNode.removeChild(temp);
                } else if (bRegex.test(borderTopCSS)) {
                    temp.style.width = "10px";
                    temp.style.border = borderTopCSS + " " + el.currentStyle["borderTopStyle"] + " #000000";
                    el.parentNode.appendChild(temp);
                    height -= Math.round((temp.offsetWidth-10)/2);
                    el.parentNode.removeChild(temp);
                }
            }
            if (el.offsetHeight > el.clientHeight && el.currentStyle["borderBottomStyle"] !== "none") {
                if (!bRegex.test(borderBottomCSS)) {
                    temp.style.width = borderBottomCSS;
                    el.parentNode.appendChild(temp);
                    height -= Math.round(temp.offsetWidth);
                    el.parentNode.removeChild(temp);
                } else if (bRegex.test(borderBottomCSS)) {
                    temp.style.width = "10px";
                    temp.style.border = borderBottomCSS + " " + el.currentStyle["borderBottomStyle"] + " #000000";
                    el.parentNode.appendChild(temp);
                    height -= Math.round((temp.offsetWidth-10)/2);
                    el.parentNode.removeChild(temp);
                }
            }
        }
    
        if (!includePadding) {
            var paddingTopCSS = el.currentStyle["paddingTop"];
            var paddingBottomCSS = el.currentStyle["paddingBottom"];
            var temp = document.createElement("DIV");
            temp.style.width = paddingTopCSS;
            el.parentNode.appendChild(temp);
            height -= Math.round(temp.offsetWidth);
            temp.style.width = paddingBottomCSS;
            height -= Math.round(temp.offsetWidth);
            el.parentNode.removeChild(temp);
        }
    }
    
    return height;
}

function select_current_date(zi, luna, an) {
	
	var current_date = new Date() ;
	
	var year = current_date.getYear() ;	    
	var month = current_date.getMonth() ;    
	var today = current_date.getDate() ;    
	
	$(zi).selectedIndex = today - 1 ;	
	$(luna).selectedIndex = month ;
	
	j = 0 ;
	for (i = 2006; i < 2037; i++) {
		if (i == year)
			break
		else
			j++ 
	}
	
	
	$(an).selectedIndex = j;
}

function pageWidth() {
	return window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;
}

function pageHeight() {
	return  window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body != null ? document.body.clientHeight : null;
} 

function pausecomp(millis) {
	var date = new Date();
	var curDate = null;
	
	do { 
		curDate = new Date(); 
	} while(curDate-date < millis);
}

function timedBack(time_ms) {
	var t = setTimeout("window.history.back()", time_ms);
}

function getWindowInnerWidth() {
  	var myWidth = 0 ;
  	if( typeof( window.innerWidth ) == 'number' ) {
    	//Non-IE
    	myWidth = window.innerWidth;
  	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    	//IE 6+ in 'standards compliant mode'
    	myWidth = document.documentElement.clientWidth;
  	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    	//IE 4 compatible
    	myWidth = document.body.clientWidth;
  	}
  	//window.alert( 'Width = ' + myWidth );
  	
	return myWidth ;
}

function getWindowInnerHeight() {
  	var myHeight = 0 ;
  	if( typeof( window.innerWidth ) == 'number' ) {
    	//Non-IE
    	myHeight = window.innerHeight;
  	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    	//IE 6+ in 'standards compliant mode'
    	myHeight = document.documentElement.clientHeight;
  	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    	//IE 4 compatible
    	myHeight = document.body.clientHeight;
  	}
  	//window.alert( 'Height = ' + myHeight );
	
	return myHeight ;
}

function getScrollX() {
  	var scrOfX = 0 ;
  	if( typeof( window.pageYOffset ) == 'number' ) {
    	//Netscape compliant
    	scrOfX = window.pageXOffset;
  	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    	//DOM compliant
    	scrOfX = document.body.scrollLeft;
 	} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    	//IE6 standards compliant mode
    	scrOfX = document.documentElement.scrollLeft;
  	}
  	//window.alert('Horizontal scrolling = ' + scrOfX);
  	return scrOfX ;
}

function getScrollY() {
  	var scrOfY = 0 ;
  	if( typeof( window.pageYOffset ) == 'number' ) {
    	//Netscape compliant
    	scrOfY = window.pageYOffset;
  	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    	//DOM compliant
    	scrOfY = document.body.scrollTop;
 	} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    	//IE6 standards compliant mode
    	scrOfY = document.documentElement.scrollTop;
  	}
  	//window.alert('Vertical scrolling = ' + scrOfY);
  	return scrOfY ;
}

//	returneaza variabilele get din url
function url_get_vars(name) {
	var q = unescape(location.search.substring(1)).split(/[=&]/);
	for (var j = 0; j < q.length; j += 2) {
		if (q[j] == name) {
			return q[j+1];
		}
	}
	return null;
}

function getURLParam(url, strParamName) {
	var strReturn = "";
	if (!url)
		var strHref = window.location.href;
	else
		var strHref = url;
	if ( strHref.indexOf("?") > -1 ){
		var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
		var aQueryString = strQueryString.split("&");
		for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
			if (aQueryString[iParam].indexOf(strParamName + "=") > -1 ){
				var aParam = aQueryString[iParam].split("=");
				strReturn = aParam[1];
				break;
			}
		}
	}
	return strReturn;
}

function pushURLParam(url, strParamName, ParamValue) {
	var strReturn = "";
	if (!url)
		var strHref = window.location.href;
	else
		var strHref = url;
	if ( strHref.indexOf("?") > -1 ) {
		var url_principale = strHref.substr(0, strHref.indexOf("?")) ;
		strReturn += url_principale ;
		var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
		var aQueryString = strQueryString.split("&");
		for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
			if (aQueryString[iParam].indexOf(strParamName + "=") > -1 ){	//	daca suntem la parametrul caruia vrem sa-i schimbam valoarea
				var aParam = aQueryString[iParam].split("=");
				if (iParam == 0)
					strReturn += aParam[0] + "=" + ParamValue;
				else
					strReturn += "&" + aParam[0] + "=" + ParamValue;
			} else {	//	daca nu suntem la parametrul caruia vrem sa-i schimbam valoarea
				if (iParam == 0)
					strReturn += aQueryString[iParam] ;
				else
					strReturn += "&" + aQueryString[iParam] ;
			}
		}
	}
	return strReturn;
}

function deleteURLParam(url, strParamName) {
	var strReturn = "";
	if (!url)
		var strHref = window.location.href;
	else
		var strHref = url;
	//alert (strHref) ;
	if ( strHref.indexOf("?") > -1 ) {
		var url_principale = strHref.substr(0, strHref.indexOf("?")) ;
		strReturn += url_principale ;
		//alert (strReturn) ;
		var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
		var aQueryString = strQueryString.split("&");
		for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
			if (aQueryString[iParam].indexOf(strParamName + "=") > -1 ){	//	daca suntem la parametrul pe care vrem sa-l stergem
			} else {	//	daca nu suntem la parametrul pe care vrem sa-l stergem
				if (iParam == 0)
					strReturn += aQueryString[iParam] ;
				else
					strReturn += "&" + aQueryString[iParam] ;
			}
		}
	} else {
		strReturn = strHref ;	
	}
	return strReturn;
}

function modif_createURLParam(url, strParamName, ParamValue) {
	var strReturn = "";
	if (!url)
		var strHref = window.location.href;
	else
		var strHref = url;
	
	var new_url = deleteURLParam(url, strParamName) ;	
	
	if ( new_url.indexOf("?") > -1 )
		strReturn += new_url + "&" + strParamName + "=" + ParamValue ;
	else
		strReturn += new_url + "?" + strParamName + "=" + ParamValue ;
	
	return strReturn ;
}

function isAlphaNumeric (str) {
	if (/[^a-zA-Z0-9.\_\- ]/g.test(str))
	{
		return false; 	
	}
	else
		return true ;
}

function isAlphaNumeric_email (str) {
	if (/[^a-zA-Z0-9.\_\-\@]/g.test(str))
	{
		return false; 	
	}
	else
		return true ;
}

function isFloat (str) {
	if (/[^0-9.]/g.test(str))
	{
		return false; 	
	}
	else
		return true ;
}

function checkCheckBox(id) {
	if ($(id).checked)
		$(id).checked = false ;
	else if (!$(id).checked)
		$(id).checked = true ;
	else
		$(id).checked = false ;
}

function mob_window_open(url) {
	window.open(url, '_blank', 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width=900, height=520');
}