function change (id,clasa) {
	//var element1 = document.getElementById(id);
  document.getElementById(id).className=clasa;
}

function ShowHideDivBoxesDetails(boxID) 
	{
		var box = document.getElementById("div"+boxID);
		//var boxbtn = document.getElementById("btn"+boxID);
		/* If the selected box is currently invisible, show it */
		if(box.style.display == "none" || box.style.display=="") {
			box.style.display = "block";
	 		//boxbtn.src = "images/collapse.png";
		}
		/* otherwise hide it */
		else {
			box.style.display = "none";
			//boxbtn.src = "images/expand.png";
		}
	}//end ShowHideDivBoxesDetails()
	
	
function showDiv(id)
	{
		document.getElementById(id).style.display = "block";
		return true;
	}//end showDiv()	
	
function hideDiv(id)
	{
		document.getElementById(id).style.display = "none";
		return true;
	}//end hideDiv()
	
	
function setCookie(cookieName,cookieValue,expiredays)
	{
		var exdate=new Date();
		exdate.setDate(exdate.getDate()+expiredays);
		document.cookie=cookieName+ "=" +escape(cookieValue)+
		((expiredays==null) ? "" : ";expires="+exdate.toUTCString());
	}//end setCookie()
	
	
function getCookie(cookieName)
	{
		if (document.cookie.length>0)
		  {
		  c_start=document.cookie.indexOf(cookieName + "=");
		  if (c_start!=-1)
		    {
		    c_start=c_start + cookieName.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 "";
	}//end getCookie()
	

function checkIe6Cookie(cookieName)
	{
		ie6Cookie=getCookie(cookieName);
		if ( (ie6Cookie == null) || (ie6Cookie == "" ) )
			{
				document.write('<div class="d2" id="ie6"><div style="position: absolute; display: block; float: right; right: 0; margin-right: 15px; FONT-WEIGHT: bolder; FONT-SIZE: 12px; font-family: Arial, Tahoma, Verdana, sans-serif; color: #222222; cursor: pointer;" onclick="setCookie(\'ie6\',true); document.getElementById(\'ie6\').style.display=\'none\';">x</div><b>Important:</b> Va recomandam ca pentru o buna functionalitate a website-ului să folositi Mozilla Firefox, Google Chrome, Opera sau Internet Explorer 8+ !</div>');
			}//end if
	}//end checkIe6Cookie()
	
	
function showPopUpNotificationBar(cookieName,notificationMessage)
	{
		popUpNotificationBar=getCookie(cookieName);
		if ( (popUpNotificationBar == null) || (popUpNotificationBar == "" ) )
			{
				document.write('<div class="d2" id="popUpNotificationBar"><div style="position: absolute; display: block; float: right; right: 0; margin-right: 15px; FONT-WEIGHT: bolder; FONT-SIZE: 12px; font-family: Arial, Tahoma, Verdana, sans-serif; color: #222222; cursor: pointer;" onclick="setCookie(\''+cookieName+'\',true); fadeOut(\'popUpNotificationBar\');">x</div>'+notificationMessage+'</div>');
			}//end if
	}//end showPopUpNotificationBar()
		
	
function changeImageSrc(imageName,imageSrc,optionalDivId)
	{
		//optionalDivId reprezinta id-ul div-ului care s-a descdhis/inchis in urma click-ului pe imagine
		//daca optionalDivId exista ca parametru, atunci doar daca display = none, schimb imaginea 
		
		if ( (optionalDivId != '') && (optionalDivId != null) )
			{
				if(document.getElementById(optionalDivId).style.display == "none") 
					document[imageName].src = imageSrc;
			}//end if
			else
				{
					document[imageName].src = imageSrc;
				}//end else
	}//end changeImageSrc()
	
	
function changeWithCondition (id,clasa,optionalDivId) {
	//var element1 = document.getElementById(id);
	
	//optionalDivId reprezinta id-ul div-ului care s-a descdhis/inchis in urma click-ului pe imagine
	//daca optionalDivId exista ca parametru, atunci doar daca display = none, schimb imaginea 

	if ( (optionalDivId != '') && (optionalDivId != null) )
		{
			if(document.getElementById(optionalDivId).style.display == "none")
				document.getElementById(id).className=clasa;
		}//end if
		else
			{
				document.getElementById(id).className=clasa;
			}//end else
}//end changeWithCondition()
	
	
function ShowHideDivs(boxID) 
	{
		var box = document.getElementById(boxID);
		//var boxbtn = document.getElementById("btn"+boxID);
		/* If the selected box is currently invisible, show it */
		if(box.style.display == "none" || box.style.display=="") {
			box.style.display = "block";
	 		//boxbtn.src = "images/collapse.png";
		}
		/* otherwise hide it */
		else {
			box.style.display = "none";
			//boxbtn.src = "images/expand.png";
		}
	}//end ShowHideDivs()
	
	
function startOnLoadEvent(homePageUrl,idContentType,userId)
	{
		//pentru toate paginile
		
		//afisez ultimele 3 articole din miniblog , pe toate paginile
		makeShowLatestNewsSidebarRequest(homePageUrl+'app/plugins/miniblog/show-latest-posts-sidebar.php','div-latest-news-sidebar',homePageUrl); 
		
		//afisez scriptul bizoo.ro, din footer-ul paginii, pe toate paginile
		setInterval("document.getElementById('script-footer-bizo.ro').innerHTML='<a rel=\"nofollow\" target=\"_blank\" title=\"Afaceri\" href=\"http://www.bizoo.ro\"><img border=\"0\" src=\"http://jobs.bizoo.ro/serveBanner.php?banner=special.gif\"></a>';",3000);
		
		//afisez notification pop-up-ul, daca utilizatorul are vre-un mesaj scris de administrator
		//doar daca utilizatorul este autentificat
		if ( (userId != "") && (userId != "0"))
			{
				setInterval("makeUserNotificationRequest(\""+homePageUrl+"\",\""+userId+"\");", 2000);
				//makeUserNotificationRequest(homePageUrl+'app/plugins/users/show-user-notification-box.php?id='+userId,'notification-little-box',homePageUrl);
			}//end if
			else
				{
					//nimic
				}//end else
				
				
		switch(idContentType)
			{
				case 1:
					{
						//prima pagina
						startChangeBanner();
						break;	
					}//end case 1
				case 2:
					{
						break;
					}//end case 2
				case 3:
					{
						//meniul "produse"
						//afisez ultimele 6 produse, doar daca am afisat in prealabil div-ul, casuta
						//asta inseamna ca utilizatorul a activat afisarea casutei cu ultimele 6 produse
						if( (document) && (document.getElementById('latest-products-box')) )
							{
								if (document.getElementById('latest-products-box').style.display == "block")
									{
										
										makerequest(homePageUrl+'app/plugins/store/latest-products-box.php','latest-products-box',homePageUrl,"fadeIn"); 
								
										//citesc id-ul ultimului produs adaugat in baza de date
										setInterval("checkNewProdForLatestProdBox(\""+homePageUrl+"\");", 5000);
									}//end if
							}//end if
							
						//afisez 6 produse aleatoare, doar daca am afisat in prealabil div-ul, casuta
						//asta inseamna ca utilizatorul a activat afisarea casutei cu 6 produse aleatoare
						if( (document) && (document.getElementById('random-products-box')) )
							{
								if (document.getElementById('random-products-box').style.display == "block")
									{	
										showRandomProductsBox(homePageUrl);
										setInterval("showRandomProductsBox(\""+homePageUrl+"\");", 10000);
									}//end if
							}//end if
							
						break;
					}//end case 3
				case 4:
					{
						break;
					}//end case 2
				case 5:
					{
						break;
					}//end case 2
				case 6:
					{
						break;
					}//end case 2
				case 7:
					{
						break;
					}//end case 2
				case 8:
					{
						break;
					}//end case 2
				case 9:
					{
						break;
					}//end case 2
				case 10:
					{
						break;
					}//end case 2
				case 11:
					{
						break;
					}//end case 2
				default:
					{
						break;
					}//end default
			}//end switch
			
	
	}//end startOnLoadEvent()
	
	
//inlocuieste newline-urile, adica enter-urile cu <br />  
 function nl2br(text){
   
      text = escape(text);
      re_nlchar=null;
   
      if(text.indexOf('%0D%0A') > -1)
      	{
      		re_nlchar = /%0D%0A/g ;
      	}
      	else 
      		if(text.indexOf('%0A') > -1)
      			{
      				re_nlchar = /%0A/g ;
      			}
      			else 
      				if(text.indexOf('%0D') > -1)
      					{ 
      						re_nlchar = /%0D/g ;
      					}//end if
  
      return unescape( text.replace(re_nlchar,'<br />') );
  
      }//end nl2br()
      
      
//<![CDATA[
function getElm(eID) {
	return document.getElementById(eID);
}
function show(eID) {
	getElm(eID).style.display='block';
}
function hide(eID) {
	getElm(eID).style.display='none';
}
function setOpacity(eID, opacityLevel) {
	var eStyle = getElm(eID).style;
	eStyle.opacity = opacityLevel / 100;
	eStyle.filter = 'alpha(opacity='+opacityLevel+')';
}
function fade(eID, startOpacity, stopOpacity, duration) {
	var speed = Math.round(duration / 100);
	var timer = 0;
	if (startOpacity < stopOpacity){
		for (var i=startOpacity; i<=stopOpacity; i++) {
			setTimeout("setOpacity('"+eID+"',"+i+")", timer * speed);
			timer++;
		} return;
	}
	for (var i=startOpacity; i>=stopOpacity; i--) {
		setTimeout("setOpacity('"+eID+"',"+i+")", timer * speed);
		timer++;
	}
}
function fadeIn(eID) {
	setOpacity(eID, 0); show(eID); var timer = 0;
	for (var i=1; i<=100; i++) {
		setTimeout("setOpacity('"+eID+"',"+i+")", timer * 5);
		timer++;
	}
}
function fadeOut(eID) {
	var timer = 0;
	for (var i=100; i>=1; i--) {
		setTimeout("setOpacity('"+eID+"',"+i+")", timer * 3);
		timer++;
	}
	setTimeout("hide('"+eID+"')", 310);
}
//]]>


function passwordMeter(password,inactiveClass,activeClass)
	{
		passwd=document.getElementById(password).value;
		//verific daca lungimea este mai mare de 1 caracter, adica am reusit sa tastez ceva, nu doar tab
		if (passwd.length > 1)
			{
				//schimb clasa dupa care modific background-ul
				change(password,inactiveClass);
				
				//incep algoritmul
				var intScore   = 0;
				
				// password length
				if (passwd.length<5) 
					{
						intScore = (intScore+3);
					}//end if
					else
						if (passwd.length>4 && passwd.length<8)
							{
								intScore = (intScore+6);
							}//end if
							else
								if (passwd.length>7 && passwd.length<16)
									{
										intScore = (intScore+12);
									}//end if
									else
										if (passwd.length>15)
											{
												intScore = (intScore+18);
											}//end if
				
				//letters
				if (passwd.match(/[a-z]/)) 
					{
						intScore = (intScore+1);
					}//end if
				if (passwd.match(/[A-Z]/)) 
					{
						intScore = (intScore+5);
					}//end if
					
				//numbers
				if (passwd.match(/\d+/))
					{
						intScore = (intScore+5);
					}//end if
				if (passwd.match(/(.*[0-9].*[0-9].*[0-9])/)) 
					{
						intScore = (intScore+5);
					}//end if
					
				//cpecial char
				if (passwd.match(/.[!,@,#,$,%,^,&,*,?,_,~]/))
					{
						intScore = (intScore+5);
					}//end if
				if (passwd.match(/(.*[!,@,#,$,%,^,&,*,?,_,~].*[!,@,#,$,%,^,&,*,?,_,~])/))
					{
						intScore = (intScore+5);
					}//end if
				
				// COMBOS
				if (passwd.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/))
					{
						intScore = (intScore+2);
					}//end if
				if (passwd.match(/([a-zA-Z])/) && passwd.match(/([0-9])/))
					{
						intScore = (intScore+2);
					}//end if
				if (passwd.match(/([a-zA-Z0-9].*[!,@,#,$,%,^,&,*,?,_,~])|([!,@,#,$,%,^,&,*,?,_,~].*[a-zA-Z0-9])/))
					{
						intScore = (intScore+2);
					}//end if
					
				if(intScore < 11)
					document.getElementById(password).style.backgroundColor="#cc0000";
					else
						if (intScore > 10 && intScore < 16)
							document.getElementById(password).style.backgroundColor="#ff2d00";
							else
								if (intScore > 15 && intScore < 21)
									document.getElementById(password).style.backgroundColor="#ffc600";
									else
										if (intScore > 20 && intScore < 24)
											document.getElementById(password).style.backgroundColor="#a1ff03";
											else
												document.getElementById(password).style.backgroundColor="#00ee00";

					
				
			}//end if
			else
				{
					//schimb inapoi cum era
					change(password,activeClass);
					document.getElementById(password).style.backgroundColor="#fcfcfc";
				}//end else
	}//end passwordMeter()
	
	
