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)
	{
		if (document.getElementById(id))
			document.getElementById(id).style.display = "block";
		return true;
	}//end showDiv()	
	
function hideDiv(id)
	{
		if (document.getElementById(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()
	

	
/**
 * startOnLoadEvent()
 * @version 1.1 (19/01/2012)
 */	
function startOnLoadEvent(homePageUrl,idContentType,userId)
	{
		//pentru toate paginile	
		//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
		*/
				
		//setez pozitia div-ului de la search suggest results
		setSearchSuggestDivPosition();
				
		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")
									{
										tmpDate=Date();
										makerequestRefreshLatestProducts(homePageUrl+'app/plugins/store/latest-products-box.php?date='+tmpDate,'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 4
				case 5:
					{
						break;
					}//end case 5
				case 6:
					{
						break;
					}//end case 6
				case 7:
					{
						break;
					}//end case 7
				case 8:
					{
						break;
					}//end case 8
				case 9:
					{
						break;
					}//end case 9
				case 10:
					{
						break;
					}//end case 10
				case 11:
					{
						break;
					}//end case 11
				case 20:
					{
						//pagina cu detalii produs - pagina produsului
						//afisez clipurile video youtube
						if( (document) && (document.getElementById('youTubeVideoBox')) && (document.getElementById('productId')) )
							{
								showYouTubeVideo(homePageUrl);
							}//end if
						break;
					}//end case 20
				case 22:
					{
						break;
					}//end case 2
				default:
					{
						break;
					}//end default
			}//end switch
			
		//update v1.1 - 08.03.2011 - show left sidebar ads
		setTimeout("loadLeftSidebarAds(\""+homePageUrl+"\");", 1000);				
	}//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()
	
	
function trim(stringToTrim) 
	{
		return stringToTrim.replace(/^\s+|\s+$/g,"");
	}//end trim
	

function GetWidth()
{
        var x = 0;
        if (self.innerHeight)
        {
                x = self.innerWidth;
        }
        else if (document.documentElement && document.documentElement.clientHeight)
        {
                x = document.documentElement.clientWidth;
        }
        else if (document.body)
        {
                x = document.body.clientWidth;
        }
        return x;
}


function GetHeight()
{
        var y = 0;
        if (self.innerHeight)
        {
                y = self.innerHeight;
        }
        else if (document.documentElement && document.documentElement.clientHeight)
        {
                y = document.documentElement.clientHeight;
        }
        else if (document.body)
        {
                y = document.body.clientHeight;
        }
        return y;
}

function setSearchSuggestDivPosition()
	{
		var D = document;
		//alert(D.body.clientWidth+' '+GetWidth());
		
		
		if (isIE())
			{
				document.getElementById('searchSuggest').style['margin']= '-1px 0px 0px '+parseInt(((D.body.clientWidth-950)/2)+5)+'px';
				//document.getElementById('setSearchSuggestDivPosition').innerHTML='<style type="text/css">#searchSuggest {margin: -1px 0px 0px '+(parseInt(((D.body.clientWidth-950)/2)+5))+'px; }</style>';
			}//end if
			else
				{
					document.getElementById('setSearchSuggestDivPosition').innerHTML='<style type="text/css">#searchSuggest {margin: 0px 0px 0px '+(parseInt(((D.body.clientWidth-950)/2)+5))+'px; }</style>';
				}//end else
	}//end setSearchSuggestDivPosition()
	
	
function isIE()
{
  return /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent);
}

var loadingImage = false;
function loadImage(imageName,imageFile)
	{
  	if ((!document.images) || loadingImage) return;
  	loadingImage = true;
  	if (document.images[imageName].src.indexOf(imageFile)<0)
  		{
    		document.images[imageName].src = imageFile;
  		}//end if
  	loadingImage = false;
	}//end loadImage()
	

	
/**
 * loadLeftSidebarAds()
 * @version 1.1 (19/01/2012)
 */		
function loadLeftSidebarAds(homePageUrl)
	{
		if( (document) && (document.getElementById('adsBanner')) )
			{	
				document.getElementById('adsBanner').innerHTML='<a rel="nofollow" href="http://creativhobby.blogspot.com" class="link-right-content-sidebar" target="_blank"><div>Blogul magazinului Creativ Hobby din Timisoara</div><img name="imgAdsCrH" /></a>';
				loadImage('imgAdsCrH',homePageUrl+'app/img/images/background-blog-box-crativ-hobby.jpg');
			}//end if
			
		if( (document) && (document.getElementById('adsBanner2')) )
			{	
				document.getElementById('adsBanner2').innerHTML='<a rel="nofollow" href="'+homePageUrl+'cum-cumpar/" class="link-right-content-sidebar"><div>Livrare prin Curierat rapid GLS<br />comanda minima 50 lei</div><img name="imgAds2" width="180" height="81" /></a>';
				loadImage('imgAds2',homePageUrl+'app/img/images/logo-gls.png');
			}//end if
	}//end loadLeftSidebarAds()	
	

	
	

