/* Flash */
function InlineSWFObject(appURL,videoURL,imageURL,autostart)
{
	var rnd=parseInt(Math.random()* Math.pow(10,17));
	var s = new SWFObject(appURL + '/tools/player.swf?rnd='+rnd,'single','320','240','7');
	s.addVariable('file',videoURL);
	if(imageURL)
		s.addVariable('image',imageURL);
	s.addParam('autostart',autostart);
	s.addParam('allowfullscreen','true');	
	
	/* X1 Banner parameters */
	/* always insert before 'plugins' variable */
	
	s.addVariable('x1adparams', escape("pub=632203491294404&site=provideo&section=homepage&zone=rectangle_video&size=0x0"));
	s.addVariable('x1pgid',		window.X1_PgId);
	s.addVariable('x1url',		escape(document.URL));
	s.addVariable('x1referrer',	escape(document.referrer));	
	s.addVariable('x1disabled',	'false');	
		
	s.addVariable("plugins",		"http://content.ad20.net/as3/plugins/jwplayer/X1Advertising.swf");
	
	document.write(s.getSWFHTML());
}
function getFlashMovie(movieName)
{
	  var isIE = navigator.appName.indexOf("Microsoft") != -1;
	  return (isIE) ? window[movieName] : document[movieName];
}

/*********************** WISHLIST ****************************/
function WishlistAdd(productId, controlId)
{		
	$pusher.Call('WISHLIST_ADD', productId + '__wish_sep__' + controlId);	
}

function OnWishlistAddComplete(status, message, controlID)
{		 
	if(status)	//wishlist add success				
	{
		$('#' + controlID).removeClass('iconWishlist').addClass('iconWishlistInact');			
		
		$('#cancel_and_wish').attr('title', 'Nu inca');
		$('#cancel_and_wish').attr('onclick', 'CloseFancyBox();');
		$('#cancel_and_wish').text('Nu inca');
	}
	else if(message == 'NOT_LOGGED')
		LoginForm(true);
	else					//wishlist add default error
		alert(message);
}

/* Videoteca */
function VideoView_Modify(act, id, zone)
{
	if(appLogged)
	{
		iCallId++;
		iPid = id;
		if(zone) sZone = zone;
		var HttpReq = new HttpAsyncPostRequest('video_view_' + iCallId);
		HttpReq.Send(appURL + '/cart/modify_video.aspx', {act: act, id: id}, VideoView_Modify_Result);
	}
	else
	{
	}
}

function VideoView_Modify_Result(sResponse, sErrCode, sErrMessage)
{
	if(sResponse == "")
	{
		var o = document.getElementById('pvv' + sZone + iPid);
		if(o) o.className += " wchecked";
	}
}


/* Element */

var iCallId=0;

function Element_GetXY(ObjRefOrId)
{
	var oR = {x:0, y:0};

	var o = typeof(ObjRefOrId) == 'string' ? document.getElementById(ObjRefOrId) : ObjRefOrId;
	if(!o) return oR;


	if(o.getBoundingClientRect)
	{
		var r = o.getBoundingClientRect(), 
			x = document.documentElement.scrollLeft || document.body.scrollLeft, 
			y = document.documentElement.scrollTop || document.body.scrollTop;
		oR = {x: r.left + x - 2, y: r.top + y - 2};
	}
	else
	{
		if(document.getBoxObjectFor)
		{
			var r = document.getBoxObjectFor(o);
			oR = {x: r.x, y: r.y};
		}
		else
		{
			var p = o.offsetParent;
			if (p != o)
			{
				while (p)
				{
					oR.x += p.offsetLeft;
					oR.y += p.offsetTop;
					p=p.offsetParent;
				}
			}
		}
	}

	return oR;
}



function Element_GetWidth(ObjRefOrId)
{
	var iW, o = typeof(ObjRefOrId) == 'string' ? document.getElementById(ObjRefOrId) : ObjRefOrId;
	if(!o) return 0;

	if(o.style.display == 'none')
	{
		o.style.display = '';
		iW = o.offsetWidth;
		o.style.display = 'none';
	}
	else
		iW = o.offsetWidth;

	return iW;
}



function Element_GetHeight(ObjRefOrId)
{
	var iH, o = typeof(ObjRefOrId) == 'string' ? document.getElementById(ObjRefOrId) : ObjRefOrId;
	if(!o) return 0;

	if(o.style.display == 'none')
	{
		o.style.display = '';
		iH = o.offsetHeight;
		o.style.display = 'none';
	}
	else
		iH = o.offsetHeight;

	return iH;
}



function Element_SetWidth(ObjRefOrId, Height)
{
	var iW, o = typeof(ObjRefOrId) == 'string' ? document.getElementById(ObjRefOrId) : ObjRefOrId;
	if(!o) return;
	
	o.style.width = parseInt(Height) + 'px';
}



function Element_SetDisplay(ObjRefOrId, Show)
{
	var o = typeof(ObjRefOrId) == 'string' ? document.getElementById(ObjRefOrId) : ObjRefOrId;
	if (o) 
		o.style.display = Show ? '' : 'none';
}

/* Box */

function Toggle_Visibility(id, img_id, imgPath) 
{  
	var o = document.getElementById(id);
	var list = o.getElementsByTagName("li");
	var bShow = false;
	var img = document.getElementById(img_id);

	for(i=1;i<list.length;i++) {
		if (list[i].style.display == "none")
		{
			bShow = true || bShow;
			list[i].style.display = "block";
		}
	}
	
	if (!bShow)
	{
		for(i=1;i<list.length;i++) {
			list[i].style.display = "none";
		}
		img.src = imgPath + "box_arrow_open.gif";
	} else
	{
		img.src = imgPath + "box_arrow_close.gif";
	}
} 

function Close_Visibility(id, img_id, imgPath) 
{ 

	var o = document.getElementById(id);
	var list = o.getElementsByTagName("li");
	var bShow = false;
	var img = document.getElementById(img_id);

	for(i=1;i<list.length;i++) {
		list[i].style.display = "none";
	}
	img.src = imgPath + "box_arrow_open.gif";
	
} 




/* Event */


function Event_AddListner(ObjRef, EvtName, FncRef)
{
	if(!ObjRef)return;
	if(window.attachEvent) ObjRef.attachEvent("on"+EvtName.toLowerCase(),FncRef);
	else if(window.addEventListener) ObjRef.addEventListener(EvtName.toLowerCase(),FncRef, false);
}


/* Menu */


var Menu_Obj = null;


function Menu_Show(MenuElementId, ClickedElementRef, CallbackFnc, CallbackFncParams)
{
	if(Menu_Obj)
	{
		Menu_Obj.MenuElementRef.style.display = 'none';

		if(Menu_Obj.ClickedElementRef == ClickedElementRef)
		{
			Menu_Obj = null;
			return;
		}
	}

	Menu_Obj =
	{
		ClickedElementRef:	ClickedElementRef,
		MenuElementId:		MenuElementId,
		CallbackFnc:		CallbackFnc,
		CallbackFncParams:	CallbackFncParams
	};

	var o = document.getElementById(MenuElementId);
	if(o)
	{
		Menu_Obj.MenuElementRef = o;

		var oXY = Element_GetXY(ClickedElementRef);

		o.style.display = '';
		o.style.left	= (oXY.x + Element_GetWidth(ClickedElementRef) - Element_GetWidth(o)) + 'px';
		o.style.top		= (oXY.y + Element_GetHeight(ClickedElementRef) + 10) + 'px';
		

		var f = typeof(CallbackFnc) == 'function' ? CallbackFnc : eval(CallbackFnc);

		if(typeof(f) == 'function')
		{
			f(CallbackFncParams);
		}
	}
}


function Menu_Hide(ev)
{
	if(Menu_Obj)
	{
		var t = (window.event ? window.event.srcElement : (ev ? ev.target : null));
		
		if (t == Menu_Obj.ClickedElementRef) return;

		if(Menu_Obj.MenuElementRef)
			Menu_Obj.MenuElementRef.style.display = 'none';

		Menu_Obj = null;
	}
}


function Menu_AddBodyClickHandler()
{
	Event_AddListner(window.document.body, 'click', Menu_Hide);
}


Event_AddListner(window, 'load', Menu_AddBodyClickHandler);





/* PopUp Window */


function PopUp_Open(URL, Width, Height)
{
	var w = screen.availWidth, h = screen.availHeight, l = 0, t = 0;
	
	l = Math.round((w-Width-10)/2);
	t = Math.round((h-Height-30)/2);

	window.open(URL,'PopUpWindow', "width="+Width+",height="+Height+",left="+l+",top="+t+",location=0,menubar=0,resizable=1,scrollbars=1,status=1,toolbar=0");
}





/* Cookies */


function Cookie_Get(sName)
{
	var i, v = document.cookie.split(';'), vT;
	
	for (i = 0; i < v.length; i++)
	{
		vT = v[i].split(sName + '=');	if (vT.length > 1) return vT[1];
	}

	return null;
}

function Cookie_Set(sName, sValue, iSeconds)
{
	var sE = "";

	if (iSeconds)
	{
		var d = new Date();
		d.setTime(d.getTime() + iSeconds * 1000);
		sE = '; expires=' + d.toGMTString();
	} 

	document.cookie = sName + '=' + sValue + sE + '; path=/';
}

function Cookie_Delete(sName)
{
	Cookie_Set(sName, '', -1);
}




/* String */

function String_Trim(s)
{
	return typeof(s) == 'undefined' ? '' : s.toString().replace(/^\s+|\s+$/g, '');
}


/* Email */

function CheckEmailAddress(field)
{
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	var goodEmail = filter.test(field);
	return goodEmail
}

/* Login */
//Event_AddListner(window, 'load', Login_Set);
function Login_Set()
{
	Attach_Focus('semail');
	Attach_Focus('spassword');
}
function Attach_Focus(objName)
{
	var o = document.getElementById(objName);
	if(o) 
	{
		Event_AddListner(o, 'focus', Input_Focus);
		Event_AddListner(o, 'blur', Input_Blur);
	}
}
function Input_Focus(ev)
{
	var o = (window.event ? window.event.srcElement : (ev ? ev.target : null));
	if(o) 
	{
		if(!document['store' + o.name] || document['store' + o.name] == o.value)
		{
			document['store' + o.name] = o.value;
			o.value='';
		}					
	}		
}
function Input_Blur(ev)
{
	var o = (window.event ? window.event.srcElement : (ev ? ev.target : null));
	if(o) 
	{
		if( document['store' + o.name] && o.value.length <= 0 )
		{
			o.value=document['store' + o.name];
		}
	}		
}


/* date validation */

var minYear = 1900;
function daysInFebruary (year){
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}



/* tooltip */
var offsetxpoint=-120 //Customize x offset of tooltip
var offsetypoint=20 //Customize y offset of tooltip
var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
var tipobj=document.all? document.all["tooltip"] : document.getElementById? document.getElementById("tooltip") : ""

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thediv,thetext, thecolor, thewidth)
{
tipobj=document.all? document.all[thediv] : document.getElementById? document.getElementById(thediv) : "";
if (ns6||ie){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
if(thetext)
	tipobj.innerHTML=thetext
enabletip=true
return false
}
}
function positiontip(e){
if (enabletip){
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20

var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth)
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
else if (curX<leftedge)
tipobj.style.left="5px"
else
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetxpoint+"px"

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight)
tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
else
tipobj.style.top=curY+offsetypoint+"px"
tipobj.style.visibility="visible"
}
}
function hideddrivetip(){
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}
document.onmousemove = positiontip;

var RIP = null;

var APP_PATH = '/MuvixSite/',
	IMG_PATH = '/MuvixSite/App_Themes/1/img/';

if (window.location.toString().indexOf('http://www.muvix.ro') == 0 || window.location.toString().indexOf('http://muvix.ro') == 0 || window.location.toString().indexOf('http://muvix.next') == 0)
{
	APP_PATH = '/';
	IMG_PATH = '/App_Themes/1/img/';
}

var SRC_FILTER = IMG_PATH + 'Filter.gif',
	SRC_ASC = IMG_PATH + 'SortAscImg.gif',
	SRC_DESC = IMG_PATH + 'SortDescImg.gif',
	SRC_LOADER = IMG_PATH + 'Loader.gif';

function XMLParser(xmlString)
{
	var xmlDoc;
	if (window.ActiveXObject)
	{
		xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.async = false;
		var loaded = xmlDoc.loadXML(xmlString);
		if (loaded)
			return xmlDoc;
		else
		{
			window.status = xmlDoc.parseError.reason + '\r\n' + xmlDoc.parseError.srcText;
			return null;
		}
	}
	else if (window.DOMParser)
	{
		var domParser = new DOMParser();
		xmlDoc = domParser.parseFromString(xmlString, 'text/xml');
		var errorNamespace = 'http://www.mozilla.org/newlayout/xml/parsererror.xml',
			docElement = xmlDoc.documentElement;
		if (docElement.tagName == 'parserError' || docElement.namespaceURI == errorNamespace)
		{
			var sourceText = docElement.getElementsByTagNameNS(errorNamespace, 'sourcetext')[0];
			window.status = docElement.firstChild.data + (sourceText != null ? '\r\n' + sourceText.firstChild.data : '');
			return null;
		}
		else
			return xmlDoc;
	}
	else
	{
		window.status = 'XMLParser not supported by the current browser!';
		return null;
	}
}
function encodeXml(string)
{
	return string.replace(/\&/g, '&' + 'amp;').replace(/</g, '&' + 'lt;').replace(/>/g, '&' + 'gt;').replace(/\'/g, '&' + 'apos;').replace(/\"/g, '&' + 'quot;');
}
function TestEmail(email)
{
	if (typeof (email) == 'undefined')
		return false;

	return /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test(email);
}

function TestURL(url)
{
	if (typeof (url) == 'undefined')
		return false;

	return /^http\:\/\/www\.imdb\.com\/title\/tt\d{7}\/{0,1}/i.test(url);
}
function FormatBytes(val)
{
	var byteSize = Math.round(val / 1024 * 100) * .01,
		suffix = 'KB';

	if (byteSize > 1000)
	{
		byteSize = Math.round(byteSize * .001 * 100) * .01;
		suffix = 'MB';
	}

	var sizeParts = byteSize.toString().split('.');
	if (sizeParts.length > 1)
		byteSize = sizeParts[0] + '.' + sizeParts[1].substr(0, 2);
	else
		byteSize = sizeParts[0];

	return byteSize + ' ' + suffix;
}

//validate number
function CorrectNumber(o)
{	
	o.value = o.value.replace(/[^0-9]/gi, '');
}

function CorrectText(o)
{
	o.value = o.value.replace(/[^a-zA-Z\.\- ]+/gi, '');
}

function StripHtmlTags(o)
{
	o.value = o.value.replace(/<(.|\n)*?>/gi, '');
}

//get year
function GetRealYear(date) 
{ 
    if(date.getFullYear)
        return date.getFullYear();
    else
        return date.getYear() + 1900; 
};


/***************************** LOGIN *****************************/
function LoginForm(hasToScrollTop)
{
	$('#navUser .boxLogin').css('display', 'inline');
	
	if ( $('#navUser .boxForgotPass').css('display') == 'none') 
	{
		if ( $('#navUser .linkLogin').hasClass('activ') ) 		
			$('#navUser .linkLogin').removeClass('activ');
		 
		else 		
			$('#navUser .linkLogin').addClass('activ');		
	}
	
	$("#navUser .boxRegisterDone, #navUser .boxForgotPass").css("display","none");
	$("#navUser .linkRegister").removeClass("activ");
	
	$('#login_email').focus();	
	
	if(hasToScrollTop)
		$.scrollTo($("#navUser .linkLogin"));
}

var VH = ViewPort().height - 80;

function ViewPort()
{
	var o = { width: 0, height: 0 };

	if (typeof window.innerWidth != 'undefined')
	{
		o.width = top.innerWidth;
		o.height = top.innerHeight;
	}
	else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0)
	{
		o.width = top.document.documentElement.clientWidth;
		o.height = top.document.documentElement.clientHeight;
	}
	else
	{
		o.width = top.document.getElementsByTagName('body')[0].clientWidth;
		o.height = top.document.getElementsByTagName('body')[0].clientHeight;
	}

	return o;
}

function OnTestComplete(speed)
{
	if(typeof(speed) != 'undefined')
		$('#contact_bandwidth').val(speed);
}





/* DISABLE */
function DisableButtons(state)
{
	if (!state)
	{
		$("div[class='disable_action']").remove();
	}
	else
	{
		var c = $('body');
		var CP = GetXY(c.get(0));
		var Xmin = CP.x,
			Xmax = CP.x + c.outerWidth();
		$("body").append('<div class="disable_action" style="position:absolute; z-index:10009; top:' + CP.y + 'px; left:' + CP.x + 'px; width:' + c.outerWidth() + 'px; height:' + c.outerHeight() + 'px; background-color:#000; filter:alpha(opacity=50); opacity:0.5;"></div>');
/*
		$.each($("a.iconWishlist, #popup_watch_movie, a.buttons, input.submit"), function()
		{
			var o = $(this);
			var P = GetXY(o.get(0));
			if (P.x > 0 && P.y > 0 && P.x > Xmin && P.x < Xmax)
			{
				var H = o.outerHeight(),
					W = o.outerWidth();
				$("body").append('<div class="disable_action" style="position:absolute; z-index:10009; top:' + P.y + 'px; left:' + P.x + 'px; width:' + W + 'px; height:' + H + 'px; background-color:#cacaca; filter:alpha(opacity=50); opacity:0.5;"></div>');
			}
		});
*/
	}
}
function GetXY(ObjRefOrId)
{
	var oR = { x: -10000, y: -10000 };

	var o = typeof (ObjRefOrId) == 'string' ? document.getElementById(ObjRefOrId) : ObjRefOrId;
	if (!o) return oR;

	if (o.getBoundingClientRect && !document.getBoxObjectFor)
	{
		var r = o.getBoundingClientRect(),
				x = document.documentElement.scrollLeft || document.body.scrollLeft,
				y = document.documentElement.scrollTop || document.body.scrollTop;
		oR = { x: r.left + x - 2, y: r.top + y - 2 };
	}
	else
	{
		if (document.getBoxObjectFor)
		{
			var r = document.getBoxObjectFor(o);
			oR = { x: r.x, y: r.y };
		}
		else
		{
			if (o.offsetParent)
			{
				oR.x = o.offsetLeft
				oR.y = o.offsetTop

				while (o = o.offsetParent)
				{
					oR.x += o.offsetLeft
					oR.y += o.offsetTop
				}
			}
		}
	}

	return oR;
}
function ToggleActionButtons(state)
{
	//	if (state)
	//	{
	//		$.each($("a[class='action']"), function()
	//		{
	//			var o = $(this);
	//			var pos = o.position(),
	//				height = o.outerHeight(),
	//				width = o.outerWidth();
	//			$("body").append('<div class="disable_action" style="position:absolute; z-index:10; top:' + (pos.top + 10) + 'px; left:' + pos.left + 'px; width:' + width + 'px; height:' + height + 'px; background-color:#cacaca; filter:alpha(opacity=50); opacity:0.5;"></div>');
	//		});
	//	}
	//	else
	//		$("div[class='disable_action']").remove();
}

/***************** COUNTER ***************************/
function Counter(id, eta) {
	var countDown = parseInt(eta);
	var intv = null;

	if (eta > 0) {
		if (intv != null)
			window.clearInterval(intv);
		intv = window.setInterval(function() { Countdown(); }, 1000);
	}
	else
		Hide();

	function Countdown() {
		var seconds_in_day = 86400;

		// Calculate the number of days left
		var days = Math.floor(countDown / seconds_in_day);
		var sDays = (days < 10 ? '0' : '') + days;
		$('#container_' + id + ' b.day').html(sDays);

		// After deducting the days calculate the number of hours left			
		var hours = Math.floor((countDown - (days * seconds_in_day)) / 3600);
		var sHours = (hours < 10 ? '0' : '') + hours;
		$('#container_' + id + ' b.hour').html(sHours);

		// After days and hours , how many minutes are left 			
		var mins = Math.floor((countDown - (days * seconds_in_day) - (hours * 3600)) / 60);
		var sMins = (mins < 10 ? '0' : '') + mins;
		$('#container_' + id + ' b.min').html(sMins);

		// Finally how many seconds left after removing days, hours and minutes. 			
		var secs = Math.floor((countDown - (days * seconds_in_day) - (hours * 3600) - (mins * 60)));
		var sSecs = (secs < 10 ? '0' : '') + secs;
		$('#container_' + id + ' b.sec').html(sSecs);

		countDown--;

		if (countDown < 0)
			Hide();
	};

	function Hide() {
		if (intv != null)
			window.clearInterval(intv);

		$('#container_' + id).hide('slow');
		$('#container_' + id).css('display', 'none');
	};
}

/********************************************* notificare */
function DisplayNotification(notificationMessage) {
	return;

	if ($('#notification').length == 0 || typeof (notificationMessage) == 'undefined' || notificationMessage.length == 0)
		return;

	if (Cookie_Get("checkcookie") == null)
		Cookie_Set('checkcookie', 1, 3600);

	if (Cookie_Get("checkcookie") == null || Cookie_Get("MuvixNotifyCookie") == "1")
		return;

	var container = $('#notification');
	container.html('');

	var closeButton = $("<a></a>").attr("href", "javascript://").attr("id", "btnClose").addClass("buttonClose");
	closeButton.text('Inchide');

	try {
		container.append(notificationMessage);
		container.append(closeButton);
		container.show();
	} catch (e) { }

	setTimeout(function() {
		HideNotification();
	}, 60000);

	$("#btnClose").click(function() {
		HideNotification();
	});

	Cookie_Set('MuvixNotifyCookie', 1, 3600 * 24 * 365);
}
function HideNotification() {
	$('#notification').hide();
}
var MANDATORY_MESSAGE = " - obligatoriu";
var INCORRECT_MESSAGE = " - incorect";
var MINIM_MESSAGE = " - minim 5 caractere";



/**************************** LOGIN ************************/
function Login()
{
	var valid = true;
	var loginArr = [];

	//open <register> node
	loginArr.push('<login ');

	//email
	var email = $('#login_email').val();
	if (email == '')		//empty field
	{
		$('#span_login_email').addClass("error");
		$('#span_login_email label small').text(MANDATORY_MESSAGE);
		valid = valid && false;
	}
	else if (!TestEmail(email))		//incorrect email
	{
		$('#span_login_email').addClass("error");
		$('#span_login_email label small').text(INCORRECT_MESSAGE);
		valid = valid && false;
	}
	else
	{
		$('#span_login_email').removeClass("error");
		$('#span_login_email label small').text('');
		loginArr.push('e="' + encodeXml(email) + '" ');
		valid = valid && true;
	}

	//password
	var password = $('#login_password').val();
	if (password == '')		//empty field
	{
		$('#span_login_password').addClass("error");
		$('#span_login_password label small').text(MANDATORY_MESSAGE);
		valid = valid && false;
	}
	else
	{
		$('#span_login_password').removeClass("error");
		$('#span_login_password label small').text('');
//>>>	loginArr.push('pass="' + encodeXml(password) + '" ');
		loginArr.push('pass="' + top['aes'].U(password) + '" ');
		valid = valid && true;
	} 

	if ($('#login_remember').attr('checked'))
		loginArr.push('r="1" ');

	//close <login> node
	loginArr.push(' />');

	if (valid)
		$pusher.Call('LOGIN', loginArr.join(''));
	else
		return false;
}

function OnLoginComplete(status, message, name, sold, currency)
{
	if (status)
	{
		$('#navUser').css('display', 'none');
		$('#navUserLogged').css('display', 'inline');
		$('#user_name').text('Bine ai venit, ' + name + '!');
		$('#user_points').html('Ai in cont <span id="contact_sold">' + sold + ' ' + currency + '</span>');
		DisplayNotification('Pentru a respecta politica studiourilor internationale, incepand din data de 27 martie 2010 vei putea vedea filmele de pe Muvix.ro numai de pe doua calculatoare. Pentru detalii intra in Pagina ta de cont personal.');
	}
	else
	{
		var status_span = $('#login_message');
		status_span.html(message);
		status_span.css('color', 'Red');
	}
}

function LoginEnterSubmit(e)
{
	var keycode;

	if (window.event)
		keycode = window.event.keyCode;
	else if (e)
		keycode = e.which;

	if (keycode == 13)
	{
		Login();
		return false;
	}
	else
		return true;
}


/**************************** FORGOT PASSWORD **********************/
function ForgotPassword()
{
	var valid = true;
	var forgotPassArr = [];

	//open <forgot_password> node
	forgotPassArr.push('<forgot_password ');

	//email
	var email = $('#forgot_email').val();
	if (email == '')		//empty field
	{
		$('#span_forgot_email').addClass("error");
		$('#span_forgot_email label small').text(MANDATORY_MESSAGE);
		valid = valid && false;
	}
	else if (!TestEmail(email))		//incorrect email
	{
		$('#span_forgot_email').addClass("error");
		$('#span_forgot_email label small').text(INCORRECT_MESSAGE);
		valid = valid && false;
	}
	else
	{
		$('#span_forgot_email').removeClass("error");
		$('#span_forgot_email label small').text('');
		forgotPassArr.push('e="' + encodeXml(email) + '" ');
		valid = valid && true;
	}

	//close <forgot_password> node
	forgotPassArr.push(' />');

	if (valid)
		$pusher.Call('FP', forgotPassArr.join(''));
	else
		return false;
}

function OnForgotPasswordComplete(status, message)
{
	if (status)	//register success		
	{
		//message
		$("#navUser .boxForgotPasswordDone").html(message);

		//box
		$("#navUser .boxLogin, #navUser .boxForgotPass, #navUser .boxRegister").css("display", "none");
		$("#navUser .boxForgotPasswordDone").css("display", "block");
		$("#navUser .boxForgotPasswordDone").delay(5000, function()
		{
			$(this).fadeOut();
			$("#navUser .linkLogin").removeClass("activ");
		});
	}
	else					//forgot password error
	{
		var status_span = $('#forgot_password_message');
		status_span.html(message);
		status_span.css('color', 'Red');
	}
}

function ForgotPasswordEnterSubmit(e)
{
	var keycode;

	if (window.event)
		keycode = window.event.keyCode;
	else if (e)
		keycode = e.which;

	if (keycode == 13)
	{
		ForgotPassword();
		return false;
	}
	else
		return true;
}

