Array.prototype.maximum = function(){
	if(!this.length)
		return undefined;
	
	var ret = Number(this[0]);
	for(var i=1; i<this.length; i++){
		ret = Number(this[i])>ret?Number(this[i]):ret;
	}
	return ret;
}

function Init(){
	StartMouseMoving();
	
	document.body.clicks = Array();
	document.body.onclick = function(){
		var funcs = document.body.clicks;
		for(name in funcs){
			eval(funcs[name]);
		}
	}
}

function StopPropagation(e){
	if($.browser.msie){
		event.cancelBubble = true;
	}else{
		e.stopPropagation();
	}
}

function BodyOnclickPush(name,data){
	var funcs = document.body.clicks;
	funcs = funcs?funcs:Array();
	data = data.toString();
	data = data.substr(data.indexOf("{")+1);
	if(data.match("}")){
		data = data.substr(0,data.lastIndexOf("}"));
	}
	funcs[name] = data;
	document.body.clicks = funcs;
}
function BodyOnclickPop(name){
	var funcs = document.body.clicks;
	var ret = "";
	if(funcs){
		ret = funcs[name];
		funcs[name] = null;
		document.body.clicks = funcs;
	}
}

function StartMouseMoving(){
	$().mousemove(function(e){
		var pos = [e.pageX,e.pageY];
		document.body.pos = pos;
	});
}

function LeftMenuShow(a){
	var li = $("ul#leftMenu > li");
	
	li.each(function(index){
		var link = this.getElementsByTagName("a");
		var list = this.getElementsByTagName("ul");
		if(link.length && list.length){
			link = link[0];
			if(link == a){
				//$(list).slideDown();
				//$(list).show();
				list.style.display = "block";
			}else{
				if($(list).is(":visible")){
					//$(list).slideUp();
					//$(list).hide();
					list.style.display = "none";
				}
			}
		}
	});
}
function LeftSubMenu(li,state){
	
	var li = $(li);
	liactive = li.attr("class").match(/active/)?true:false;
	var ul = li.find("ul");
	var ulParent = $("#leftMenu");
	var speed = "slow";
	
	var over = ulParent.attr("over")=="true"?true:false;
	//document.title = "over: "+over;
	
	if(ul.length > 0 && !liactive){
		switch(state){
			case "show":
				if(li.attr("timeout")){
					clearTimeout(li.attr("timeout"));
				}
				if(ul.is(":hidden")){
					li.addClass("hover");
					ul.slideDown(speed);
				}
				break;
			case "hide":
				if(ul.is(":visible")){
					var func = function(){
						li.removeClass("hover");
						ul.slideUp(speed);
					}
					li.attr("timeout",setTimeout(func,1000));
				}
				break;
			case "hideAll":
				var func = function(){
					if(over == false){
						clearTimeout(ulParent.attr("timeout"));
						var lis = $("#leftMenu > li");
						for(var i=0; i<lis.length; i++){
							LeftSubMenu(lis[i],'hide');
						}
					}
				}
				ulParent.attr("timeout",setTimeout(func,150));
				break;
		}
	}
}
function OtherFormats(obj,id){
	CustomContext(obj,id);
}
function bkp_OtherFormats(obj,id,state){
	return;
	var pos = getPosition(obj);
	
	var contextMenu = $("#ContextMenu");
	
	var ie = $.browser.msie?true:false;
	if(ie){
		pos[0] -= 200;
		pos[1] -= 100;
	}
	
	if(!contextMenu.length){
		contextMenu = document.createElement("div");
		contextMenu.id = "ContextMenu";
		contextMenu.style.position = "absolute";
		contextMenu.style.zIndex = 20000;
		
		contextMenu.onmouseout = function(){
			$(this).hide();
		}
		
		document.body.appendChild(contextMenu);
		
		contextMenu = $(contextMenu);
	}
	contextMenu[0].style.left = pos[0]+"px";
	contextMenu[0].style.top = pos[1]+"px";
	contextMenu.html(id);
	
	switch(state){
		case "show":
			contextMenu.show();
			break;
		case "hide":
			contextMenu.hide();
			break;
	}
}
function getPosition(obj){
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do{
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		}while(obj=obj.offsetParent);
	}
	
	return [curleft,curtop];
}
function GenreMore(a){
	a = $(a);
	var ul = a.parent().parent();
	var more = ul.find("ul.more").eq(0);
	if(more){
		if(more.is(":visible")){
			more.slideUp();
			a.html("Elenco Completo >>");
		}else{
			more.slideDown();
			a.html("<< Elenco Breve");
		}
	}
}
function Accordion(a,listid){
	var ul = $("#"+listid);
	var lis = ul.children();

	lis.each(function(i){
		var c = $(this).children();
		var link = c[0];
		var content = c[1];
	
		if(link==a){
			$(content).slideDown("fast");
		}else{
			$(content).slideUp("fast");
		}
	});
}
function TagCloud(format,ids){
	elemid = "tagcloud";
	var opts = {
		url: "/?ajxreq&action=TagCloud&format="+format+"&ids="+ids,
		method: "get",
		beforeSend: function(req){
			$("#"+elemid).html('<img src="/img/throbber.gif" />');
		},
		complete: function(req,statusText){
			all = req.getAllResponseHeaders();
			w = req.getResponseHeader("words").split("{!}");
			p = req.getResponseHeader("points").split("{!}");
			
			var words = Array();
			var points = Array();
			
			for(var i=0; i<w.length; i++){
				words.push(w[i]);
				points.push(p[i]);
			}
			
			var minsize = 10;
			var maxsize = 24;
			Cloud(elemid,words,points,minsize,maxsize);
			if(req.responseText.length){
				alert(req.responseText)
			} 
		}
	};
	$.ajax(opts);
}
function Cloud(id,words,points,minsize,maxsize){
	var data = Array();
	var obj;
	var i;
	
	var max = points.maximum();
	
	for(i=0; i<words.length; i++){
		obj = Array();
		
		// random
		/*var rand = Math.random()*24;
		obj["size"] = Math.round(rand);		
		var rand = Math.round(Math.random()*10); rand = rand>=words.length?words.length-1:rand;
		obj["text"] = words[rand];*/
		
		var perc = Number(Number(points[i])/max);
		var fontsize = Math.round(Number(maxsize)*perc);
		obj["size"] = fontsize<minsize?minsize:fontsize>maxsize?maxsize:fontsize;
		obj["text"] = words[i];
		
		data.push(obj);
	}
	var html = "<ul>";
	for(i=0; i<data.length; i++){
		html += "<li>";
		html += "<span>"+data[i]["size"]+" music tagged with</span>";
		html += '<a href="javascript:void(0)" class="tag" style="font-size:'+data[i]["size"]+'px;">'+data[i]["text"]+'</a>';
		html += "</li>";
	}
	html += "</ul>";
	$("#"+id).html(html);
}

function ShowTab(a){
	var ul = $(a).parent().parent();
	var li = ul.children();
	li.each(function(index){
		var tab_a = $(this).children().get(0);
		var tab_content = $("#"+$(tab_a).attr("accesskey"));
		
		tab_a.className = tab_a.className.replace(/\s*active\s*/g,"");
		if(tab_a == a){
			tab_content.show();
			tab_a.className += " active";
		}else{
			tab_content.hide();
		}
	});
}

function ScrollerOld(scrollid,pos,jump){
	var classDisable = Array("go-left-end","go-right-end"); 

	if(typeof(scrollTimeout)!="undefined" && parseInt(scrollTimeout)>0){
		return;
	}
	
	var S = $("#"+scrollid);
	var li = $("#"+scrollid+" > li");
	
	var scrollerPosition = parseInt(S.css("margin-left"));
	var itemWidth = $(li[0]).width();
	
	
	var currentPosition = Number(S.attr("position"));
	currentPosition = currentPosition>0?currentPosition:0;
	
	var newPosition = jump?pos:currentPosition+Number(pos);
	
	var isEmpty = $(li[newPosition]).attr("lang") == "empty";
	if(isEmpty){
		var liobj = $(li[newPosition]);
		
		var throbber = $("#"+scrollid).parent();
		throbber = throbber.find(".throbber");
		
		var request = {
			type: "GET",
			url: liobj[0].getAttribute("type"),
			beforeSend:function(req){
				throbber.show();
			},
			complete:function(req,status){
				throbber.hide();
				if(req.status == 200){
					liobj.html(req.responseText);
					liobj.attr("lang","filled");
					Scroller(scrollid,pos,jump);
				}
			}
		};
		var ret = jQuery.ajax(request);
	}else if(newPosition>=0 && newPosition<li.length){
		S.attr({position: newPosition});
		_moveIt(S,(-1)*newPosition*itemWidth);
		
		var goleft = S.parent().find("a.go-left");
		var goright = S.parent().find("a.go-right");
		
		switch(newPosition){
			case 0:
				goleft.addClass(classDisable[0]);
				goright.removeClass(classDisable[1]);
				break;
			case (li.length-1):
				goleft.removeClass(classDisable[0]);
				goright.addClass(classDisable[1]);
				break;
			default:
				goleft.removeClass(classDisable[0]);
				goright.removeClass(classDisable[1]);
				break;
		}

		var positionBtns = $("#"+scrollid+"-position > a");
		positionBtns.each(function(){
			var apos = $(this).attr("accesskey");
			if(apos == newPosition){
				this.className += " active"
			}else{
				this.className = this.className.replace(/\s*active\s*/," ");
			}
		});
		//positioner.css("background-position","center "+(positionerHeight*newPosition*-1)+"px");
	}
}

function _moveIt(S,pos){
	var cp = parseInt(S.css("margin-left"));
	
	var diff = Math.abs(Math.abs(cp) - Math.abs(pos));
	
	if(diff>5){
		var step = Math.round(diff/2);
		var np = cp>pos?cp-step:cp+step;
		S.css("margin-left",np+"px");
		scrollTimeout = setTimeout(function(){_moveIt(S,pos)},100);
	}else{
		S.css("margin-left",pos+"px");
		clearTimeout(scrollTimeout);
		scrollTimeout = null;
	}
}

function ContentAlbumsToggle(a)
{	
	var ul = $(a).parent().parent().parent().parent();
	var li = $(a).parent().parent().parent();
	var speed = "slow";
	
	var tc = li.find(".trackContainer");
	if(tc) {
		var empty = tc.attr("empty")=="1"	?	true	:	false;
		if(empty) {
			var albumid = tc.attr("albumid");
			var throb = li.find(".throbber").eq(0);
			var opts = {
				url: "./",
				data: {ajxreq:1, action: "LoadAlbumTracks", id:albumid},
				beforeSend: function(){
					throb.show();
				},
				complete: function(req){
					throb.hide();
					if(req.status == 200){
						if(req.responseText.length > 0){
							tc.html(req.responseText);
							tc.attr("empty",0);
							ContentAlbumsToggle(a);
							var tst = $('#alb_' + albumid + ' > .item-list').attr('maxprice');
							$('#maxPrice_' + albumid).text(tst);
						}
					}
				}
			};
			$.ajax(opts);
		}else{
			var lis = ul.children();
			for(var i=0; i<lis.length; i++){
				var opened = $(lis[i]).find(".opened");
				var closed = $(lis[i]).find(".closed");
				
				if(lis[i]==li[0]){
					opened.slideDown(speed);
					closed.slideUp(speed);
					$(lis[i]).addClass("active");
				}else{
					opened.slideUp(speed);
					closed.slideDown(speed);
					$(lis[i]).removeClass("active");
				}
			}
		}
	}
}

function SearchArtist(form){
	
	if(form.elements['search_keyword'].value.length<2){
		return false;
	}
	
	var params = "action=Search"
	params += "&catid="+form.elements['catid'].value;
	params += "&search_keyword="+form.elements['search_keyword'].value;
	params += "&search_type=2"
	params += "&ajxreq";
	var opts = {
		method: "post",
		url: "/",
		data: params,
		beforeSend: function(){
			$("#search_throbber").show();
		},
		complete: function(req){
			$("#search_throbber").hide();
			if(req.status==200){
				$("#ArtistSearchContainer").html(req.responseText);
			}
		}
	};
	$.ajax(opts);
}

function FaqToggle(a){
	var obj=$(a).next('.answer');
	
	if(obj.is(':hidden')){
		$(a).parent().addClass("active");
		obj.slideDown();
	}else{
		$(a).parent().removeClass("active");
		obj.slideUp();
	}
}

function DeviceModels(brandid,model){
	model = typeof(model)=="undefined"?"":model;
	
	var data = "ajxreq&action=DeviceModels&manufacturer="+brandid+"&model="+model;
	var opts = {
		url: "/",
		method: "post",
		data: data,
		beforeSend: function(){
			$("#device-throbber").show();
		},
		complete: function(req,statusText){
			$("#device-throbber").hide();
			
			if(req.status==200){
				response = req.responseText;
			}else{
				response = req.status+" "+statusText;
			}
			
			$("#models-container").html(response);
		}
	};
	$.ajax(opts);
}
function checkForm(forma,ids,types){
	var ret = true;
	var err = "&nbsp;";
	
	for(var i=0; i<ids.length; i++){
		var el = forma[ids[i]];
		var type = types[i];
		var rgx = null;
		var code = null;
		switch(type){
			case "cellnumber":
				rgx = /^\d{9,12}$/;
				code = 0;
				break;
			case "anything":
				rgx = /^.+$/;
				code = 6;
				break;
			case "password":
				rgx = /^.+$/;
				code = 3;
				break;
		}
		
		if(rgx && el && !el.value.match(rgx)){
			err = ERROR_MESSAGES[code];
			ret = false;
			break;
		}
	}
	$("#submit_error").html(err);
	return ret;
}
function checkIscriviti(form,natprefix){
	var ret=true;
	var number = form.elements['cellnum'].value;
	number = number.replace(/[^\d]/g,"");
	if(!number.match(/^\d{9,12}$/)){
		return 0;
	}
	//form.elements['cellnum'].value = natprefix+form.elements['cellnum'].value
	
	var opts = {
		url: "/",
		data: "/?ajxreq&action=CheckDownloadCellNumber&number="+number,
		beforeSend: function(){
		},
		complete: function(req){
			if(req.status==200){
				var response = req.getResponseHeader("valid");
				if(!response){
					ret = 1;
				}
			}
		}
	}
	//$.ajax(opts);
	
	return ret;
}

function checkPrivacy(form)
{
	if( !form.elements['accept'].checked ){
		alert('Devi accettare le condizioni di utilizzo e l\'informativa sulla privacy.');
		return false;
	}

	return true;
}

function downloadCheckStep2(form){
	var ret=true;
	var number = form.elements['cellnum'].value;
	var pass = form.elements['password'].value;
	if(!form.elements['accept'].checked){
		return 2;
	}
	if(!pass.length){
		return 3;
	}
	
	var opts = {
		url: "/",
		data: "/?ajxreq&action=CheckDownloadPassword&number="+number+"&pass="+pass,
		beforeSend: function(){
		},
		complete: function(req){
			if(req.status==200){
				var response = req.getResponseHeader("valid");
				if(!response){
					ret = 4;
				}
			}
		}
	}
	//$.ajax(opts);
	
	return ret;
}
function LoadAlbumTracks(id){
	
}

function startPlayAudio( urlFlv )
{
	//document.getElementById("audio_player").playAudioFlash(urlFlv);
	var player = document['flash'];
	if(player){
		player.playAudioFlash(urlFlv);
	}else{
		window.status = "no player object found.";
	}
}

function checkValueLength(obj,max,statusObjID){
	var s = $("#"+statusObjID);
	max = parseInt(max);
	max = max>0?max:0;
	var val = obj.value;
	
	var left = max - val.length;
	if(left<1){
		left = "0";
		val = val.substr(0,max);
		obj.value = val;
	}
	//s.html(left);
}
function ShowCompatiblePhones(url){
	var width = 640;
	var height = 480;
	
	var options = "width="+width+", ";
	options += "height="+height+", ";
	options += "status=no, ";
	options += "toolbar=no, ";
	options += "location=no, ";
	options += "menubar=no, ";
	options += "directories=no, ";
	options += "resizabile=no, ";
	options += "scrollbars=no";
	var win = window.open(url,"_blank",options);
	if(win){
		win.resizeTo(width, height);
		var l = Math.round((screen.availWidth-width)/2);
		var t = Math.round((screen.availHeight-height)/2);
		win.moveTo(l,t);
		win.focus();
	}
}


 function Popup(url) {
	var width = 640;
	var height = 480;
	
	var options = "width="+width+", ";
	options += "height="+height+", ";
	options += "status=no, ";
	options += "toolbar=yes, ";
	options += "location=no, ";
	options += "menubar=yes, ";
	options += "scrollbar=yes, ";
	options += "directories=no, ";
	options += "resizabile=yes ";
	var win = window.open(url,"_blank",options);
	if(win){
		win.resizeTo(width, height);
		var l = Math.round((screen.availWidth-width)/2);
		var t = Math.round((screen.availHeight-height)/2);
		win.moveTo(l,t);
		win.focus();
	}
 }

 //Advanced search JS functions
//Get artists and albums for selected genre
function advSGenArtist( gid )
{
	if (parseInt(gid) > 0) {
		$('#as-genre-genre > li a').each(function() {		
					if ($(this).attr('genre_id') == gid) {
						$(this).addClass('active');
					}else{
						$(this).removeClass('active');
					}
		});
		$('#ajax-loader-genere-1').fadeIn('slow');	
		var opts = {
				url: "./",
				data: {ajxreq:1, action: 'getASGenreByGenre', genre_id: gid},
				async:true,
				complete: function(req){
					if(req.status == 200){
						if(req.responseText.length > 0){	
							$('#ajax-loader-genere-1').fadeOut('slow');						
							$('#as_genre_container').empty();
							document.getElementById('as_genre_container').innerHTML = req.responseText;
							return false;
						}
					}
				}
			};
		return $.ajax(opts); 
 	} else {
 		alert(error_msg[901]);	
 	}
 	
}
//Get albums regarding to genre id and artist id 
function advSGenAlbum(el, artist_id)
{
	var gid=el.getAttribute('genere_id');
 	if(gid) {
 		$('#as-genre-artists > li a').each(function() {		
 			if ($(this).attr('artist_id') == artist_id) {
				$(this).addClass('active');
			}else{
				$(this).removeClass('active');
			}
 		});
 		$('#ajax-loader-genere-2').fadeIn('slow');	
 		var opts = {
				url: "./",
				data: {ajxreq:1, action: 'getASGenreByArtist', genre_id: gid, artist_id: artist_id},
				async:true,
				complete: function(req){
					if(req.status == 200){
						if(req.responseText.length > 0){	
							$('#ajax-loader-genere-2').fadeOut('slow');
							$('#as-genre-albums').empty();
							document.getElementById('as-genre-albums').innerHTML = req.responseText;
							return false;
						}
					}
				}
			};
		return $.ajax(opts);	
 	}
 	else{
 		alert(error_msg[901]);
 	}	
}
 
 function advSArtGenere(artist_id){
	 if(artist_id){
 			$('#as-artist-artists > li a').each(function() {		
 				if ($(this).attr('artist_id') == artist_id) {
 	 				$(this).addClass('active');
 				}else{
 					$(this).removeClass('active');
 				}
 	 		});
 			$('#ajax-loader-artist-1').fadeIn('slow');
 			var opts = {
				url: "./",
				data: {ajxreq:1, action: 'getASArtistByArtist', artist_id: artist_id},
				async:true,
				complete: function(req){
					if(req.status == 200){
						if(req.responseText.length > 0){	
							$('#ajax-loader-artist-1').fadeOut('slow');
							$('#as-artist-chunk').empty();
							document.getElementById('as-artist-chunk').innerHTML = req.responseText;
							return false;
						}
					}
				}
			};
		return $.ajax(opts);
 		}else{
 			alert(error_msg[901]);	
 		}
 }
 
function advSArtAlbum(genre_id)
{ 
	if(genre_id > 0) {
		var artist_id = $('#as-artist-artists > li a.active').attr('artist_id');
		$('#as-artist-genre > li a').each(function() {		
			if ($(this).attr('genre_id') == genre_id) {
				$(this).addClass('active');
			}else{
				$(this).removeClass('active');
			}
		});
 		
		$('#ajax-loader-artist-2').fadeIn('slow');
 		var opts = {
				url: "./",
				data: {ajxreq:1, action: 'getASArtistByGenre', artist_id: artist_id, genre_id: genre_id},
				async:true,
				complete: function(req){
					if(req.status == 200){
						if(req.responseText.length > 0) {	
							$('#ajax-loader-artist-2').fadeOut('slow');
							$('#as-artist-albums').empty();
							document.getElementById('as-artist-albums').innerHTML = req.responseText;
							return false;
						}
					}
				}
			};
		return $.ajax(opts);
 	}
 	else{
 		alert(error_msg[901]);
 	}	
 }

function getASArtistByName()
{
		
	var artist_name = $('#artistInputField').val();
	artist_name = artist_name.replace(/^\s+|\s+$/g,"");
	if (artist_name.length >= 2) {
		$('#ajax-loader-artist-name').css('display', 'block');	
		$('#purchase-btn').fadeOut('slow');	
		var opts = {
				url: "./",
				data: {ajxreq:1, action: 'getASArtistByName', artist_name : artist_name},
				async:true,
				complete: function(req) {
					if(req.status == 200) {
						if(req.responseText.length > 0) {	
							$('#as-artist-container').empty();
							document.getElementById('as-artist-container').innerHTML = req.responseText;
							$('#ajax-loader-artist-name').css('display', 'none');
							$('#purchase-btn').fadeIn('slow');					
							return false;
						}
					}
				}
			};
		$.ajax(opts);
		return false;
	}else{
		alert(error_msg[501]);
	}
	return false;

}

function checkSearchField()
{
	var searchString = document.forms['searchForm'].search.value;
	searchString = $.trim(searchString)
	if (searchString.length < 2) {
		alert(error_msg[501]);
		return false;
	}
	return true;
}


function showActivePageStatic(current_page )
{
	$('#pagination li a').each(function(index){
		index+1 == current_page ?	$(this).addClass('bold')	:	$(this).removeClass('bold'); 	
	});
}

function purchaseContent(content_id, purchaseType)
{
	$('#purchase_msg').css('display', 'block');
	$('#purchase-image-mob').css('display', 'none');
	$('#purchase-image-pc').css('display', 'none');
	$('#purchase-loader').fadeIn('slow');
	
	var opts = {
			url: "./",
			data: {	ajxreq:1, 
					action: 'purchaseContent', 
					purchaseType: purchaseType, 
					content_id : content_id
					},
			async:true,
			complete: function(req) {
				if(req.status == 200) {
					if(req.responseText.length > 0) {	
						document.getElementById('purchase_msg').innerHTML = req.responseText;
						
						var contentPrice = $('div.acquistandoB').attr('contentPrice');
						var credits 		= $('div.acquistandoB').attr('credits');
						var isInReservationMob = $('div.acquistandoB').attr('isInReservationMob');
						var isInReservationPC = $('div.acquistandoB').attr('isInReservationPC');
						var downloadUrl = $('div.acquistandoB').attr('downloadUrl');
						
						if (downloadUrl != undefined) {
							var ifrm = null;
							if ($.browser.msie && parseInt($.browser.version) < 7) {
								ifrm = document.createElement('<iframe src="#">');
							}else{
								ifrm = document.createElement("IFRAME");
							}
							
							ifrm.setAttribute("src", downloadUrl);
							ifrm.style.width = "0px";
							ifrm.style.height = "0px";	   
							document.getElementById('purchase-wrapper').appendChild(ifrm); 
						}
						if (isInReservationMob == 1) {
							$('span#contentPriceMob').text('0 cr');
						}
						if (isInReservationPC != "undefined") {
							if (isInReservationPC == 1) {
								$('span#contentPriceWeb').text('0 cr');
							}
							else {
								$('span#contentPriceWeb').text(contentPrice + ' cr');
							}
						}
						if (credits != ""  && credits != undefined) {
							$('span#userCredits').text(credits + ' cr');
						}
						$('#purchase-loader').fadeOut('slow', function(){
							$('#purchase-image-mob').css('display', 'block');
							$('#purchase-image-pc').css('display', 'block');
							});
						
						var messageMob = $('div.acquistandoB').attr('messageMob');
						var messagePc  = $('div.acquistandoB').attr('messagePc');
						//Change title for appropriate elements according to the action
						$("#purchase-img-mob").attr('title', messageMob);	
						$("#contentPriceMob").attr('title', messageMob);
						
						$("#purchase-img-pc").attr('title', messagePc);
						$("#contentPriceWeb").attr('title', messagePc);
						$("#clicker_pc").click(function() {
							purchaseContent(content_id, 'wap')
						})
						$("#clicker_mob").click(function() {
							purchaseContent(content_id, 'web')
						})
					}else{
						alert('sorry, there was a error!');
					}
					return false;
				}
			}
		};
	$.ajax(opts);
	return false;
}

function purchaseContentWithoutLogIn(content_id, purchaseType, msisdnId, password)
{
	$('#purchase_msg').css('display', 'block');
	$('#purchase-image-mob').css('display', 'none');
	$('#purchase-image-pc').css('display', 'none');
	$('#purchase-loader').fadeIn('slow');
	
	var opts = {
			url: "./",
			data: {	ajxreq: 1, 
					action: 'purchaseContentWithoutLogIn', 
					purchaseType: purchaseType, 
					content_id : content_id, 
					msisdnId : msisdnId, 
					password : password
					},
			async:true,
			complete: function(req) {
				if(req.status == 200) {
					if(req.responseText.length > 0) {	
						document.getElementById('purchase_msg').innerHTML = req.responseText;						
						var downloadUrl = $('div.acquistandoB').attr('downloadUrl');
						if (downloadUrl != undefined) {
							ifrm = document.createElement("IFRAME");
							ifrm.setAttribute("src", downloadUrl);
							ifrm.style.width = "0px";
							ifrm.style.height = "0px";	   
							document.getElementById('purchase-wrapper').appendChild(ifrm); 
						}
						
						$('#purchase-loader').fadeOut('slow', function(){
							$('#purchase-image-mob').css('display', 'block');
							$('#purchase-image-pc').css('display', 'block');
							});
						
						var messageMob = $('div.acquistandoB').attr('messageMob');
						var messagePc  = $('div.acquistandoB').attr('messagePc');
						//Change title for appropriate elements according to the action
						$("#purchase-img-mob").attr('title', messageMob);	
						$("#contentPriceMob").attr('title', messageMob);
						
						$("#purchase-img-pc").attr('title', messagePc);
						$("#contentPriceWeb").attr('title', messagePc);
						$("#clicker_pc").click(function() {
							purchaseContent(content_id, 'wap')
						})
						$("#clicker_mob").click(function() {
							purchaseContent(content_id, 'web')
						})
					}else{
						alert('sorry, there was a error!');
					}
					return false;
				}
			}
		};
	$.ajax(opts);
	return false;
}