/**
 * Cookie plugin
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */

/**
 * Create a cookie with the given name and value and other optional parameters.
 *
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Set the value of a cookie.
 * @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
 * @desc Create a cookie with all available options.
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Create a session cookie.
 * @example $.cookie('the_cookie', null);
 * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
 *       used when the cookie was set.
 *
 * @param String name The name of the cookie.
 * @param String value The value of the cookie.
 * @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
 * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
 *                             If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
 *                             If set to null or omitted, the cookie will be a session cookie and will not be retained
 *                             when the the browser exits.
 * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
 * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
 * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
 *                        require a secure protocol (like HTTPS).
 * @type undefined
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */

/**
 * Get the value of a cookie with the given name.
 *
 * @example $.cookie('the_cookie');
 * @desc Get the value of a cookie.
 *
 * @param String name The name of the cookie.
 * @return The value of the cookie.
 * @type String
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */
 
 /* Copyright (c) 2007 Paul Bakaus (paul.bakaus@googlemail.com) and Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 *
 * $LastChangedDate: 2007-12-20 08:46:55 -0600 (Thu, 20 Dec 2007) $
 * $Rev: 4259 $
 *
 * Version: 1.2
 *
 * Requires: jQuery 1.2+
 */

(function($){
	
$.dimensions = {
	version: '1.2'
};

// Create innerHeight, innerWidth, outerHeight and outerWidth methods
$.each( [ 'Height', 'Width' ], function(i, name){
	
	// innerHeight and innerWidth
	$.fn[ 'inner' + name ] = function() {
		if (!this[0]) return;
		
		var torl = name == 'Height' ? 'Top'    : 'Left',  // top or left
		    borr = name == 'Height' ? 'Bottom' : 'Right'; // bottom or right
		
		return this.is(':visible') ? this[0]['client' + name] : num( this, name.toLowerCase() ) + num(this, 'padding' + torl) + num(this, 'padding' + borr);
	};
	
	// outerHeight and outerWidth
	$.fn[ 'outer' + name ] = function(options) {
		if (!this[0]) return;
		
		var torl = name == 'Height' ? 'Top'    : 'Left',  // top or left
		    borr = name == 'Height' ? 'Bottom' : 'Right'; // bottom or right
		
		options = $.extend({ margin: false }, options || {});
		
		var val = this.is(':visible') ? 
				this[0]['offset' + name] : 
				num( this, name.toLowerCase() )
					+ num(this, 'border' + torl + 'Width') + num(this, 'border' + borr + 'Width')
					+ num(this, 'padding' + torl) + num(this, 'padding' + borr);
		
		return val + (options.margin ? (num(this, 'margin' + torl) + num(this, 'margin' + borr)) : 0);
	};
});

// Create scrollLeft and scrollTop methods
$.each( ['Left', 'Top'], function(i, name) {
	$.fn[ 'scroll' + name ] = function(val) {
		if (!this[0]) return;
		
		return val != undefined ?
		
			// Set the scroll offset
			this.each(function() {
				this == window || this == document ?
					window.scrollTo( 
						name == 'Left' ? val : $(window)[ 'scrollLeft' ](),
						name == 'Top'  ? val : $(window)[ 'scrollTop'  ]()
					) :
					this[ 'scroll' + name ] = val;
			}) :
			
			// Return the scroll offset
			this[0] == window || this[0] == document ?
				self[ (name == 'Left' ? 'pageXOffset' : 'pageYOffset') ] ||
					$.boxModel && document.documentElement[ 'scroll' + name ] ||
					document.body[ 'scroll' + name ] :
				this[0][ 'scroll' + name ];
	};
});

$.fn.extend({
	position: function() {
		var left = 0, top = 0, elem = this[0], offset, parentOffset, offsetParent, results;
		
		if (elem) {
			// Get *real* offsetParent
			offsetParent = this.offsetParent();
			
			// Get correct offsets
			offset       = this.offset();
			parentOffset = offsetParent.offset();
			
			// Subtract element margins
			offset.top  -= num(elem, 'marginTop');
			offset.left -= num(elem, 'marginLeft');
			
			// Add offsetParent borders
			parentOffset.top  += num(offsetParent, 'borderTopWidth');
			parentOffset.left += num(offsetParent, 'borderLeftWidth');
			
			// Subtract the two offsets
			results = {
				top:  offset.top  - parentOffset.top,
				left: offset.left - parentOffset.left
			};
		}
		
		return results;
	},
	
	offsetParent: function() {
		var offsetParent = this[0].offsetParent;
		while ( offsetParent && (!/^body|html$/i.test(offsetParent.tagName) && $.css(offsetParent, 'position') == 'static') )
			offsetParent = offsetParent.offsetParent;
		return $(offsetParent);
	}
});

function num(el, prop) {
	return parseInt($.curCSS(el.jquery?el[0]:el,prop,true))||0;
};

})(jQuery);
 
 
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};

// Functie de aparut mesaj sus (nu schimab id-uri)
//	var theCookie = 'modificare-tarife-1-iulie2';	// dupa ce schimbi mesajul, schimbi si cookie-ul
//	setTimeout(function() {
//	if (jQuery.cookie(theCookie)!='yes') {
//		$('<div id="upbar" style="background: #F7F6E5; padding: 9px; border-bottom:1px solid #d5d4c3; color: #333; "><div id="upbarcontent" style="width: 975px; margin:0 auto; text-align:left;line-height: 1.3em;" ><div id="uptext" style="float: left; width: 890px; font-size:14px;"></div><div id="upbuton" style="float: right;"><input type="button" value="Inchide" style="padding: 4px;" /></div><div style="clear: both;"></div></div></div>').prependTo('body');
//		$('#uptext').html('RCS & RDS a actualizat tarifele pentru serviciile Digi, <a style="color: #333; text-decoration: underline;" target="_blank" href="/resources/doc/Anunt majorare TVA la 1 iulie 2010.pdf">conform noilor prevederi legislative de aplicare a TVA (24%)</a>. <br />Compania a pastrat unele tarife neschimbate, suportand diferenta rezultata din cresterea de TVA. Pentru detalii, va rugam consultati oferta.');
//		$('#upbar').fadeIn();
//		$('#upbuton input[type=button]').click(function() {
//			jQuery.cookie(theCookie,'yes', {expires: 1000});
//			$('#upbar').fadeOut();
//		});
//	} else {
			
//	}
//	},1000);
	
	
//});
// end functie


function qatoggle() {
	$(this).parent().find('div.a').toggle(300);
}

jQuery(function() {
	
	if ($('.intrebari').length>0) {
		$('.intrebari > li.intrebare > span.q').click(qatoggle);
	}
	
});

function vselecttab(tab) {
	var liToShow = $('div.tabNavigationControl ul.tabNavigation li[href=#'+tab+']');
	
	var tabContainers = $('div.tabNavigationControl > div');
	
	//tabContainers.hide().filter(liToShow.attr('href')).show();
	
	$('div.tabNavigationControl ul.tabNavigation a').removeClass('selected');
		$('div.tabNavigationControl ul.tabNavigation li').removeClass('selected');
        liToShow.addClass('selected');
		liToShow.parent().addClass('selected');
		//document.location.hash = 'tab_'+$(this).attr('href').replace('#','');
		text=window.xconf.text;
		if (text === false) {
			liToShow.parent().find('a').hide();
			liToShow.find('a').show();
			liToShow.parent().find('li').css({width: '22px'});
			liToShow.css({width:'auto'});
		}
        return false;
}

function vinittabs(conf) {
	var text = true;
	if (conf && conf.text == false) {
		text = false;	
	}
	
	var hash = false;
	if (conf && conf.hash == true) {
		hash = true;
	}
	
	window.xconf = conf || {};
	
	
	
	var tabContainers = $('div.tabNavigationControl > div');
	
	tabContainers.css({float:'left',width:'680px'}); 
	
	if (!text) {	
		$('ul.tabNavigation li a').hide();
	}
    
    var ret = $('div.tabNavigationControl ul.tabNavigation li').click(function (e) {
		e.preventDefault();		//alert(hash);								
		//debugger;
		var loc = '?t='+$(this).attr('href').replace(/#/,'')+(hash?'#taburi':'');
		//alert(loc);
		  
		  document.location.replace(loc);
		   
		//document.location.replace('?t='+$(this).attr('href').replace(/#/,'')+hash?'#taburi':'');
		return false;
        tabContainers.hide().filter($(this).attr('href')).show();
        $('div.tabNavigationControl ul.tabNavigation a').removeClass('selected');
		$('div.tabNavigationControl ul.tabNavigation li').removeClass('selected');
        $(this).addClass('selected');
		$(this).parent().addClass('selected');
		document.location.hash = 'tab_'+$(this).attr('href').replace('#','');
		if (!text) {
			$(this).parent().find('a').hide();
			$(this).find('a').show();
			$(this).parent().find('li').css({width: '22px'});
			$(this).css({width:'auto'});
		}
        return false;
    });
	
	return false;
	
	if (document.location.hash!='') {
		$('div.tabNavigationControl ul.tabNavigation li[href='+document.location.hash.replace(/tab_/,'')+']').click();
	} else { ret.filter(':first').click(); }	
}
































var isJWRendered = false;
		var jwPlayer = null;
		var thePlayerControl = null;
		var shouldInitMovie = true;
		
		function playerReady(thePlayer) {
			thePlayerControl = window.document[thePlayer.id];
			//thePlayerControl.sendEvent('PLAY');
			thePlayerControl.addControllerListener('STOP', 'jwStopEvent');
		}
		
		function jwStopEvent() {
			thePlayerControl.sendEvent('STOP');
			$('.rolling > .rolling-video').slideUp(null, function() {
				$('.rolling > img').show();
				setTimeout(function() { shouldInitMovie = true; }, 500);
				return false;														  
			});
			return false;		
		}
	
		function initRollMovie(conf) {
			$('.rolling > img').click(function() {
				if (shouldInitMovie) {
					if (!isJWRendered) {
						jwPlayer = new SWFObject('/resources/rich/jwplayer/player-licensed.swf','mpl',conf.w,conf.h,'9');
						jwPlayer.addParam('allowfullscreen','true');
						jwPlayer.addParam('allowscriptaccess','always');
						jwPlayer.addParam('wmode','opaque');
						jwPlayer.addVariable('file',conf.src);
						jwPlayer.addVariable('controlbar','none');
						jwPlayer.addVariable('autostart','true');
						jwPlayer.write('mediaspace');
						isJWRendered = true;
					}
					$('.rolling > .rolling-video').slideDown();
					$(this).hide();
					try {
						thePlayerControl.sendEvent('PLAY');
					} catch(e) {}
					shouldInitMovie = false;
				}
			}).css({cursor:'pointer'});
			$('.rolling > .rolling-video a').click(jwStopEvent);
		}
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		$(document).ready(function() {					   
	$('.tooltip')/*.css({position:'relative'})*/.hover(
		function(e) {
			//debugger;
			if (e.target.className.indexOf('tooltip')<0) { return false; }
			var ttl = $(this);
			var txt=ttl.html().replace(/<.*>/ig, "");
		var ttip = $(this).attr('titletooltip');
		$(this).wrapInner(
			'<div class="tooltip-wrap">'
					+ttip
			+'</div>'
		);
		if (txt) {
		$('.tooltip-wrap h4').text(txt);
		}

		$('.tooltip-wrap').css({left:ttl.offset().left+'px',top:ttl.height()+ttl.offset().top+'px'}).slideDown('fast');//.fadeIn(200);
		//ttl.css({position: 'static'});
		
		//console.log(ttl.offset());

	},
	function() {		
		$('.tooltip-wrap').slideUp(function(){$(this).remove()});//.remove();
		}
	);
});




function positionToRight() {
	var wh = window.innerHeight || document.documentElement.clientHeight;	
	$('#normal-scrollable').css({top: $(window).scrollTop()+10 }); // + wh - $('#normal-scrollable').width() + 15});
	$('#normal-scrollable').css({left:$('#wrapper').offset().left+$('#wrapper').width()-$('#normal-scrollable').width()+140});
}


$(function() {
	$(window).scroll(positionToRight).resize(positionToRight); 
	$(window).scroll();
});