function newImage(arg) {
  if (document.images) {
    rslt = new Image();
    rslt.src = arg;
    return rslt;
    }
  }

function changeImages(state_id) {
  if (document.images && (preloadFlag == true)) {
    //alert('_common/templates/default/images/harta/state_'+state_id+'.png');
    document.getElementById('judet-evidentiat').style.backgroundImage = 'url(_common/templates/default/images/harta/state_'+state_id+'.png)';
    //document.judet-evidentiat.style.backgroundImage='url(http://www.remcoromania.ro/_common/templates/default/images/harta/state_empty_'+state_id+'.png)';
    }
  }

var preloadFlag = true;
function preloadImages() {
  if (document.images) {
    {$buttons_over}
    buttons = newImage('_common/templates/default/images/harta/harta-ro.gif');
    preloadFlag = true;
    }
  }


function resetimage(src){
  this.src=src;
  this.confirm=true;
  this.alt="Reset";
  this.write=resetimage_write;
  }

function resetimage_write(){
  document.write('<a ');
  if (this.rollover)
      {
      if (! this.name)
          {
          alert('to create a rollover you must give the image a name');
          return;
          }
  
      resetRolls[this.name] = new Object();
      resetRolls[this.name].over = new Image();
      resetRolls[this.name].over.src=this.rollover;
      resetRolls[this.name].out = new Image();
      resetRolls[this.name].out.src=this.src;
      document.write(
          ' onMouseOver="if (document.images)document.images[\'' + 
          this.name + '\'].src=resetRolls[\'' + this.name + '\'].over.src"' + 
          ' onMouseOut="if (document.images)document.images[\'' + 
          this.name + '\'].src=resetRolls[\'' + this.name + '\'].out.src"'
          );
      }
  document.write(' href="javascript:');
  if (this.confirm)
      document.write('if(confirm(\'Stergeti continutul formularului?\'))');
  document.write(
      'document.forms[' + 
      (document.forms.length - 1) + '].reset();void(0);">');
  document.write('<img src="' + this.src + '" alt="' + this.alt + '"');
  document.write(' border=0');
  if (this.name)document.write(' name="' + this.name + '"');
  if (this.height)document.write(' height=' + this.height);
  if (this.width)document.write(' width=' + this.width);
  if (this.otheratts)document.write(' '+ this.otheratts);
  document.write(' /></a>');
}



// return the value of the radio button that is checked
// return an empty string if none are checked, or
// there are no radio buttons
function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

// set the radio button with the given value as being checked
// do nothing if there are no radio buttons
// if the given value does not exist, all the radio buttons
// are reset to unchecked
function setCheckedValue(radioObj, newValue) {
	if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined) {
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++) {
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) {
			radioObj[i].checked = true;
		}
	}
}




function validate_fara_masuri(){

  var f = document.forms.formular;
  
  if ( f.color!= undefined && !getCheckedValue(f.color) )	   
  {
     alert("Alegeti materialul!");
	  return false;
  }
      
  if ( !f.inaltime.value)
  {       
       alert('Specificati inaltimea!');
       f.inaltime.focus();       
       return false;
  }  
  return true;
  
  }	

function validate(){

  var f = document.forms.formular;
  
  if(!getCheckedValue(f.masura)){// nici un radio - masura - selectat(a)
    alert("Indicati masura!");
    return false;}
  else{
    if ( f.circumferinta_bust.selectedIndex == 0 ){
      alert("Indicati circumferinta bust");
      f.circumferinta_bust.focus();               
      return false;
      }
    if ( f.circumferinta_talie.selectedIndex == 0 ){
      alert("Indicati circumferinta talie");
      f.circumferinta_talie.focus();               
      return false;
      }
    if ( f.circumferinta_sold.selectedIndex == 0 ){
      alert("Indicati circumferinta sold");
      f.circumferinta_sold.focus();               
      return false;
      }
    }
  if ( f.color!= undefined && !getCheckedValue(f.color) )	   
  {
     alert("Alegeti materialul!");
	  return false;
  }
      
  if ( !f.inaltime.value)
  {       
       alert('Specificati inaltimea!');
       f.inaltime.focus();       
       return false;
  }  
  return true;
  
  }	

  
  function reset_masura()
  {
    var f = document.forms.formular
    var masura = f.masura
    for ( i=0; i<masura.length; i++)
    {
        if ( masura[i].checked )
        {
           masura[i].checked = false;
           break;
        }
    }
    var ultima = masura.length
    masura[6].checked = true;
  }
  
  function reset_dimensiuni(x,y,z)
  {
     var f = document.forms.formular
     f.circumferinta_bust.selectedIndex = x
     f.circumferinta_talie.selectedIndex = y
     f.circumferinta_sold.selectedIndex = z
  }


(function(jQuery) {
	jQuery.fn.tooltip = function(options) {
		$('body').append('<div id="sstt" style="display:none;"></div>');
		if (typeof options == 'undefined') options = {};
		this.live('mousemove', function(e) {
			
			var att = 'attribute' in options && $(this).attr(options.attribute); 
			if(!att) att = $(this).attr('rel');
			
			var bbox = 'bbox' in options && options.bbox;
			if (!bbox) bbox = $(document);
			
			if ('text' in options && options.text) att = options.text;
			
			if ($(this).is('img')) att = $(this).attr('alt');
			if ($(this).is('a')) att = $(this).attr('title');
			
			var elem = $('#sstt'),csstxt = elem.css('cssText'),ew=elem.width(),dw=bbox.width(),px=e.pageX+10,py=e.pageY+10;
			elem.html(att);
			var eloffset = dw > px+ew && 
				elem.css('cssText', csstxt+';position:absolute;top:'+py+'px;left:'+px+'px;display:block');
				
			!eloffset && 
				elem.css('cssText', csstxt+';position:absolute;top:'+py+'px;left:'+(dw-ew)+'px;display:block');
		});
		this.live('mouseout', function() {
			$('#sstt').hide();
		});
	};
})(jQuery);


$(document).ready(function() {
  $('#content_frame').jScrollPane({showArrows: true});
  $('#productpics').cycle({
		fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		cleartypeNoBg: true
	});
  $("#productpics").removeClass("hidden");
  $('#newsticker').cycle({
		fx: 'scrollUp', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		cleartypeNoBg: true 
	});
  $("#newsticker").removeClass("hidden");

/*
  $("#cortina_left").fadeIn('slow',function(){
    $(this).animate({'left': '-=5px'},'slow');
  });
  $("#cortina_right").fadeIn('slow',function(){
    $(this).animate({'left': '+=5px'},'slow');
  });
  $("#cortina_center").fadeIn('slow',function(){
    $(this).animate({'top': '-=10px'},'slow');
  });
  $("#cortina_top_left").fadeIn('slow',function(){
    $(this).animate({'top': '-=10px'},'slow');
  });
  $("#cortina_top_right").fadeIn('slow',function(){
    $(this).animate({'top': '-=10px'},'slow');
  });
*/

  $.fn.pause = function(duration) {
      $(this).animate({ dummy: 1 }, duration);
      return this;
  };
  $("#cortina_left_above").pause(1000).fadeIn('slow',function(){
    $(this).animate({'left': '-=230px'},'slow');
  });
  $("#cortina_right_above").pause(1000).fadeIn('slow',function(){
    $(this).animate({'left': '+=230px'},'slow');
  });
  $("#cortina_top_left_extrem").pause(1000).fadeIn('slow',function(){
    $(this).animate({'left': '-=35px'},'slow');
  });
  $("#cortina_top_right_extrem").pause(1000).fadeIn('slow',function(){
    $(this).animate({'left': '+=35px'},'slow');
  });
  $("#cortina_center").pause(1000).fadeIn('slow',function(){
    $(this).animate({'top': '-=10px'},'slow');
  });
  $("#cortina_top_left").pause(1000).fadeIn('slow',function(){
    $(this).animate({'top': '-=10px'},'slow');
  });
  $("#cortina_top_right").pause(1000).fadeIn('slow',function(){
    $(this).animate({'top': '-=10px'},'slow');
  });



$('.carousel-image').tooltip();
$('.prevnext-image').tooltip();


/*
    $(".div_reg").backgroundScale({
        imageSelector: "#imageID",
        centerAlign: true,
        containerPadding: 100
    });
*/
});

/*google +1*/
/*
  (function() {
    var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
    po.src = 'https://apis.google.com/js/plusone.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
  })();
*/
/*facebook*/
(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) {return;}
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
  
$(document).ready(function() {
	$().piroBox_ext({
	piro_speed : 700,
		bg_alpha : 0.5,
		piro_scroll : true // pirobox always positioned at the center of the page
	});
});

  $(document).ready(function () {
    $("#waterwheel-carousel-horizon").waterwheelCarousel({
      // number tweeks to change apperance
      startingItem:               1,      // item to place in the center at the start, set to zero to be the middle item
      startingItemSeparation:     200,
      itemSeparationFactor:       .1,
      startingWaveSeparation:     10,
      itemDecreaseFactor:         .85,
      opacityDecreaseFactor:      1,
      centerOffset:               10,
      // animation
      speed:                      800,    // speed in milliseconds it will take to rotate from one to the next
      animationEasing:            'linear',// the animation easing when rotating each item
      quickerForFurther:          true,   // set to true to make animations faster when clicking an item that is far away from the center
      // misc
      linkHandling:               2,      // 1 to disable all (used for facebox), 2 to disable all but center (to link images out)
      autoPlay:                   2000,      // indicate the speed in milliseconds to wait before autorotating. 0 to turn off. Can be negative
      orientation:                'horizontal', // indicate if the carousel should be horizontal or vertical
      activeClassName:            'active', // the name of the class given to the current item in the center
      keyboardNav:                true,  // set to true to move the carousel with the arrow keys
      keyboardNavOverride:        true,   // set to true to override the normal functionality of the arrow keys (prevents scrolling)
      edgeReaction:               'reverse', // what does the carousel do when it reaches an edge? accepted: reset/reverse/nothing
    });

    
    $('.target').click(function() {
      //alert('Handler for .click() called.');
      window.location=$(this).attr('href');
    });
    
  });


this.imagePreview = function(){	
	/* CONFIG */
		
		xOffset = 10;
		yOffset = 30;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$("a.preview").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "" + this.t : "";
		//$("body").append("<p id='preview'><img src='"+ this.href +"' alt='Image preview' />"+ c +"</p>");								 
		$("body").append("<p id='preview'>"+ c +"</p>");								 
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#preview").remove();
    });	
	$("a.preview").mousemove(function(e){
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};


// starting the script on page load
$(document).ready(function(){
	imagePreview();
});

$(document).ready(function(){
  $('img').load(function(){
    $(this).parent().show();
  });
});

 

