$("document").ready(function(){
        // prepare scroll
        
	
	
	
        function moveScrollTo(index)
        {
            var newPos=index*scrollElementWidth*(-1);
            if(index==0)
                {
                    $(".scrollLeft").css("visibility","hidden");
                }
                else
                {
                    $(".scrollLeft").css("visibility","visible");
                }
                
            if(index>=(nbElements-perPage))
                {
                    $(".scrollRight").css("visibility","hidden");
                }
                else
                {
                    $(".scrollRight").css("visibility","visible");
                }
		
	    window.location.hash = index;
		
            scrollContent.animate({left:newPos}, 500, function() {});
            try
            {
                $(".prod-list a").removeClass("prod-list-bullet-on");
                $(".prod-list a[rel="+index+"]").addClass("prod-list-bullet-on");
            }catch(err){}
        }
        
        function imgmoveScrollTo(index)
        {
            var newPos=index*(imgscrollElementWidth)*(-1);
            if(index==0)
                {
                    $("#pd_imglist_left").css("visibility","hidden");
                }
                else
                {
                    $("#pd_imglist_left").css("visibility","visible");
                }
                
            if(index>=(imgnbElements-3))
                {
                    $("#pd_imglist_right").css("visibility","hidden");
                }
                else
                {
                    $("#pd_imglist_right").css("visibility","visible");
                }
            imgscrollContent.animate({left:newPos}, 500, function() {});
            try
            {
             //   $(".prod-list a").removeClass("prod-list-bullet-on");
             //   $(".prod-list a[rel="+index+"]").addClass("prod-list-bullet-on");
            }catch(err){}
        }
        
        $(".nav-prod-list").click(function(event){
            event.preventDefault();
	    
            moveScrollTo($(this).attr("rel"));
	    currentIndex = $(this).attr("rel");
            $(".prod-list a").removeClass("prod-list-bullet-on");
            $(this).addClass("prod-list-bullet-on");
        })
       
        
        try{
            
            var scroll = $("#scroll");
            var scrollContent = $("#scroll-content");
            var scrollElements = $(".scroll-element");            
            var scrollElementWidth = $(".scroll-element").width();
            
            var nbElements = scrollElements.length;            
            
                
            scrollContent.css('width',(nbElements*scrollElementWidth)+'px');
            
            $(".scrollLeft").bind('click',function(){
		currentIndex=parseInt(currentIndex);
                if(currentIndex<=0)
                    {
                        currentIndex = nbElements-perPage;
                    }
                    else
                        {
                            currentIndex-=1;
                        }
		
                moveScrollTo(currentIndex);
            });
            
            $(".scrollRight").bind('click',function(){
		
		currentIndex=parseInt(currentIndex);
                if(currentIndex>=(nbElements-perPage))
                    {
                        currentIndex = 0;
                    }
                    else
                        {
                            currentIndex+=1;
                        }
                moveScrollTo(currentIndex);
            });
            
        }catch(err){
            alert(err);
        }
	
	var currentIndex = 0;
	try
	{
	    currentIndex=window.location.hash.replace("#","");
	    
	    if(currentIndex=="")
		{
		    currentIndex=0;
		}
	}catch(err) {}
	
	
        moveScrollTo(currentIndex);
        
        $(".mnu_header").hover(
            function(){
                var rel=$(this).attr('rel');
                var pos=$(this).offset();
                var el = $("#"+rel);
                var height = 38; //parseInt($(this).css('height'));
                var width = parseInt($(this).css('width'));
                
                el.css('top',pos.top+height);
                el.css('left',pos.left);
                el.css('width',width-10);
                el.css('display','block');
            },function(event){
                var rel=$(this).attr('rel');
                var pos=$(this).offset();
                var el = $("#"+rel);
                var node=event.relatedTarget.nodeName;
                if(node!=='LI')
                    {
                        el.css('display','none');
                    }
            });
            $(".submenu").hover(
            function(){
               $(this).css('display','block');
            },function(){
               $(this).css('display','none');
            }
            );
                
            $("#search_top_input").click(function(){$(this).attr('value','');})
            $("#search_top_btn").click(function(){
               if($("#search_top_input").attr('value')=='Ce vrei sa personalizezi azi?')
                   {
                       return false;
                   }
                   
                   if($("#search_top_input").attr('value')=='')
                   {
                       return false;
                   }
                   
                   return true;
            });
            
            try{
                var mheight = $("#middle").css("height").replace("px","");
            }
            catch(err)
            {
                var mheight = 700;
            }
            if(mheight<900)
                {
                    $("#middle").css("height","870px");
                }
                
                $(".scroll-element").hover(function(){
                   try
                   {
                         $(".prod-bar").fadeIn('fast');
                   
                     //  $(".prod-bar").css('display','block');
                   }catch(err){
                       alert(err);
                   }
                },function(){
                   try
                   {
                        $(".prod-bar").fadeOut('fast');
                   
                     //  $(".prod-bar").css('display','none');
                   }catch(err){
                       alert(err);
                   }
                });
                
                var imgel = $(".pd_imglist_element").length;
                if(imgel>0)
                    {
                        var imgscroll = $("#pd_imglist_container");
                        var imgscrollContent = $("#pd_imglist_scroll");
                        var imgscrollElements = $(".pd_imglist_element");            
                        var imgscrollElementWidth = $(".pd_imglist_element").width() + 8;
                        var imgnbElements = imgscrollElements.length;            
                        var imgcurrentIndex = 0;
                        imgscrollContent.css('width',(imgnbElements*imgscrollElementWidth)+'px');
                        
                        $("#pd_imglist_left").bind('click',function(){
                            if(imgcurrentIndex<=0)
                                {
                                    imgcurrentIndex = imgnbElements-3;
                                }
                                else
                                    {
                                        imgcurrentIndex-=1;
                                    }
                            imgmoveScrollTo(imgcurrentIndex);
                        });

                        $("#pd_imglist_right").bind('click',function(){
                            if(imgcurrentIndex>=(imgnbElements-3))
                                {
                                    imgcurrentIndex = 0;
                                }
                                else
                                    {
                                        imgcurrentIndex+=1;
                                    }
                            imgmoveScrollTo(imgcurrentIndex);
                        });
                        imgmoveScrollTo(0);
                    }
                    
                    $("a.swapImage").click(function(event){
                        event.preventDefault();
                        $("img#imageSrc").attr('src',$(this).attr('href'));
                        $("a[rel=lightbox_galery]").attr('href',$(this).attr('href'));
                    });
                    
                    $(function() {
                            // Use this example, or...
                            $('a[rel=lightbox_galery]').lightBox(); // Select all links in the page
                            // ... The possibility are many. Use your creative or choose one in the examples above
                    });
                    
                    
     });   
     
     <!--
/****************************************************
     Author: Eric King
     Url: http://redrival.com/eak/index.shtml
     This script is free to use as long as this info is left in
     Featured on Dynamic Drive script library (http://www.dynamicdrive.com)
****************************************************/
var win=null;
function NewChatWindow(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
win=window.open(mypage,myname,settings);}
// -->

// prepare the form when the DOM is ready 
$(document).ready(function() { 
    
 
    // bind to the form's submit event 
    $('form[name=contact_us]').live('submit',function() { 
        
        var options = { 
        target:        '#middle-commons-container',   // target element(s) to be updated with server response 
        beforeSubmit:  showRequest,  // pre-submit callback 
        success:       showResponse  // post-submit callback 
 
        // other available options: 
        //url:       url         // override for form's 'action' attribute 
        //type:      type        // 'get' or 'post', override for form's 'method' attribute 
        //dataType:  null        // 'xml', 'script', or 'json' (expected server response type) 
        //clearForm: true        // clear all form fields after successful submit 
        //resetForm: true        // reset the form after successful submit 
 
        // $.ajax options can be used here too, for example: 
        //timeout:   3000 
    }; 
    
        // inside event callbacks 'this' is the DOM element so we first 
        // wrap it in a jQuery object and then invoke ajaxSubmit 
        $(this).ajaxSubmit(options); 
 
        // !!! Important !!! 
        // always return false to prevent standard browser submit and page navigation 
        return false; 
    }); 
    
    // bind to the form's submit event 
    $('form[name=solicita_oferta]').live('submit',function() { 
        
        var options = { 
        target:        '#confirm',   // target element(s) to be updated with server response 
        beforeSubmit:  showRequest,  // pre-submit callback 
        success:       showResponse  // post-submit callback 
 
        // other available options: 
        //url:       url         // override for form's 'action' attribute 
        //type:      type        // 'get' or 'post', override for form's 'method' attribute 
        //dataType:  null        // 'xml', 'script', or 'json' (expected server response type) 
        //clearForm: true        // clear all form fields after successful submit 
        //resetForm: true        // reset the form after successful submit 
 
        // $.ajax options can be used here too, for example: 
        //timeout:   3000 
    }; 
    
        // inside event callbacks 'this' is the DOM element so we first 
        // wrap it in a jQuery object and then invoke ajaxSubmit 
        $(this).ajaxSubmit(options); 
 
        // !!! Important !!! 
        // always return false to prevent standard browser submit and page navigation 
        return false; 
    }); 
    
}); 
 
// pre-submit callback 
function showRequest(formData, jqForm, options) { 
    
    
    // formData is an array; here we use $.param to convert it to a string to display it 
    // but the form plugin does this for you automatically when it submits the data 
    var queryString = $.param(formData); 
 
    // jqForm is a jQuery object encapsulating the form element.  To access the 
    // DOM element for the form do this: 
    // var formElement = jqForm[0]; 
 
    // alert('About to submit: \n\n' + queryString); 
 
    // here we could return false to prevent the form from being submitted; 
    // returning anything other than false will allow the form submit to continue 
    return true; 
} 
 
// post-submit callback 
function showResponse(responseText, statusText, xhr, $form)  { 
    // for normal html responses, the first argument to the success callback 
    // is the XMLHttpRequest object's responseText property 
 
    // if the ajaxSubmit method was passed an Options Object with the dataType 
    // property set to 'xml' then the first argument to the success callback 
    // is the XMLHttpRequest object's responseXML property 
 
    // if the ajaxSubmit method was passed an Options Object with the dataType 
    // property set to 'json' then the first argument to the success callback 
    // is the json data object returned by the server 
 
    // alert('status: ' + statusText + '\n\nresponseText: \n' + responseText + 
    //    '\n\nThe output div should have already been updated with the responseText.'); 
} 
