function getResponseVal(resp)
{
var doc = resp.responseXML.documentElement;
if(doc.hasChildNodes()) {
return doc.childNodes[0].firstChild.data;
}
return '';
}
function showFeedSnip ( feed )
{
var query = "/global.ajax.php";
var pars = "action=rss_feed_snip&feed=" + encodeURI(feed);
$('rss_feed_snip').innerHTML = 'Obteniendo y analizando el feed...';
var myAjax = new Ajax.Updater(
{success: 'rss_feed_snip'},
query,
{
method: 'get',
parameters: pars,
onFailure: reportError
});
}
function reportError(request)
{
alert('Lo sentimos. Ha ocurrido un error.');
}
function createAccount()
{
$('create_account_notice').innerHTML = 'Preparandose para crear la cuenta... Por favor, espere...';
$('create_account_notice').style.display = 'block';
new Ajax.Request("/global.ajax.php", {
onSuccess : function(resp) {
var result = getResponseVal(resp);
if(result == 'success'){
//$('create_account_notice').style.display = 'none';
$('create_account').submit();
} else {
$('create_account_notice').innerHTML = result;
$('create_account_notice').style.display = 'block';
}
},
onFailure : function(resp) {
$('create_account_notice').innerHTML = "Lo sentimos, su cuenta no se puede crear. Por favor, inténtelo de nuevo.";
$('create_account_notice').style.display = 'block';
},
parameters : "action=create_account&" + Form.serialize($("create_account"))
});
}
function showLb (obj, url, params)
{
var lb_obj = new lightbox(obj);
var lb_ajax = new Ajax.Request(
url,
{
method: 'post',
parameters: params, onComplete: function(resp)
{
lb_obj.processInfo.bindAsEventListener(lb_obj);
//yo creo que arriba esto sobra???
lb_obj.processInfo(resp);
if (browser == 'Internet Explorer'){
lb_obj.getScroll();
lb_obj.prepareIE('100%', 'hidden');
lb_obj.setScroll(0,0);
lb_obj.hideSelects('hidden');
}
lb_obj.displayLightbox("block");
}
}
);
}
function beginCheckout(me)
{
$('reviews_notice').innerHTML = 'Preparando la comprobación de la petición... Por favor, espere...';
$('reviews_notice').style.display = 'block';
new Ajax.Request("/global.ajax.php", {
onSuccess : function(resp) {
var result = getResponseVal(resp);
if(result == 'success'){
$('reviews_notice').innerHTML = "Petición preparada... ";
$('reviews_form').submit();
} else if (result == 'success-login') {
// show login
//var lb_win = showLb(me, '/login.php', 'lb=true&include_cart_vars=true');
document.location = "login.php";
//$('reviews_notice').innerHTML = '';
//$('reviews_notice').style.display = 'none';
} else {
$('reviews_notice').innerHTML = result;
$('reviews_notice').style.display = 'block';
}
},
onFailure : function(resp) {
$('reviews_notice').innerHTML = "Lo sentimos, sus productos no se han enviado. Por favor, inténtelo de nuevo.";
$('reviews_notice').style.display = 'block';
},
parameters : "" + Form.serialize($("reviews_form"))
});
}
function autofill(cartId, inventoryId, previousPackage)
{
var thisPackage = cartId+'_'+inventoryId;
if ($('autofill'+thisPackage).checked == true) {
$('product_url'+thisPackage).value = $('product_url'+previousPackage).value;
$('product_name'+thisPackage).value = $('product_name'+previousPackage).value;
$('product_desc'+thisPackage).value = $('product_desc'+previousPackage).value;
$('product_type_id'+thisPackage).value = $('product_type_id'+previousPackage).value;
$('product_url_directo'+thisPackage).value = $('product_url_directo'+previousPackage).value;
}
}
function ShowLocationOptions (val) {
if (val != "USA") {
Element.show('province');
Element.hide('state');
} else {
Element.hide('province');
Element.show('state');
}
}
function markAsSeen (type, id) {
new Ajax.Request("/global.ajax.php", {
onSuccess : function(resp) {
var result = getResponseVal(resp);
$('alerts-view-opts').style.display = 'block';
if(result == 'success'){
return true;
} else {
return false;
}
},
onFailure : function(resp) {
alert('No se puede marcar '+ type +' como visto en este momento.');
},
parameters : "action=" + type + "_mark_as_seen&id=" + id
});
Element.hide(type + '-' + id);
}
function getMouseXY(e) {
if (IE) { // grab the x-y pos.s if browser is IE
tempX = event.clientX + document.body.scrollLeft
tempY = event.clientY + document.body.scrollTop
} else { // grab the x-y pos.s if browser is NS
tempX = e.pageX
tempY = e.pageY
}
// catch possible negative values in NS4
if (tempX < 0){tempX = 0}
if (tempY < 0){tempY = 0}
// show the position values in the form named Show
// in the text fields named MouseX and MouseY
document.Show.MouseX.value = tempX
document.Show.MouseY.value = tempY
return true
}
function showTooltip(id, show, text, extra)
{
var tooltip = $(id);
if (text == 'ssn_exp') {
tooltip.innerHTML = 'Es obligatorio un SSN/Tax ID para recibir los pagos.';
tooltip.style.top = '630px';
tooltip.style.left = '155px';
} else if(text == 'sites_payout_exp'){
tooltip.innerHTML = 'Ganas el 70%(aprox.) del precio del análisis.';
tooltip.style.top = '340px';
tooltip.style.left = '685px';
} else if (text == 'sites_ranking_exp') {
tooltip.innerHTML = 'La posición según el promedio de estrellas que alcanza esta página Web para Alexa, Technorati, fecuencia de actualización e índice en Google. Se recalcula mensualmente.';
tooltip.style.top = '350px';
tooltip.style.left = '488px';
} else if (text == 'sites_price_exp') {
tooltip.innerHTML = 'Zync determina el precio dependiendo de varios factores como, el diseño, el tráfico estimado, la popularidad del enlace. El precio es recalculado mensualmente.';
tooltip.style.top = '350px';
tooltip.style.left = '578px';
} else if (text == 'alexa_exp') {
tooltip.innerHTML = 'Alexa es una indicación general del tráfico a la página Web. Cuanto más pequeño es el valor en Alexa, mayor tráfico recibe la página.';
tooltip.style.top = '345px';
tooltip.style.left = '310px';
} else if (text == 'technorati_exp') {
tooltip.innerHTML = 'La posición en Technorati es una medida del número de blogs que enlazan a este blog. Cuanto más pequeño es el valor, más popular es el blog.';
tooltip.style.top = '345px';
tooltip.style.left = '310px';
} else if (text == 'frecuencia_exp') {
tooltip.innerHTML = 'Valoración de la frecuencia de actualización del site. Cuanto más se actualice, mejor.';
tooltip.style.top = '345px';
tooltip.style.left = '310px';
} else if (text == 'google_exp') {
tooltip.innerHTML = 'Posición en el índice de Google.';
tooltip.style.top = '345px';
tooltip.style.left = '310px';
} else if (text == 'visitas_mensuales_exp') {
tooltip.innerHTML = 'Número de visitas únicas mensuales.';
tooltip.style.top = '345px';
tooltip.style.left = '310px';
} else if (text == 'paginas_vistas_exp') {
tooltip.innerHTML = 'Número de páginas vistas al mes.';
tooltip.style.top = '345px';
tooltip.style.left = '310px';
} else if (text == 'overall_rank_exp') {
tooltip.innerHTML = 'La posición según el promedio de estrellas que alcanza esta página Web para Alexa, Technorati, fecuencia de actualización e índice en Google. Se recalcula mensualmente.';
if(extra != '_mousecoord' && show){
tooltip.style.top = '345px';
tooltip.style.left = '310px';
}
} else if (text == 'promo_25k_exp') {
tooltip.innerHTML = 'Cuando eres aceptado como blogger por Zync, tu primera oferta de análisis te vendrá de Zync. Seguiremos aceptando pedidos de análisis hasta que paguemos 25,000€!';
tooltip.style.width = '250px';
tooltip.style.top = '190px';
tooltip.style.left = '310px';
} else if (text == 'product_name_tt'){
tooltip.innerHTML = 'Nombre identificativo de lo que quieres que sea analizado';
tooltip.style.width = '250px';
tooltip.style.top = '190px';
tooltip.style.left = '310px';
} else if (text == 'product_url_tt'){
tooltip.innerHTML = 'URL del producto a analizar o donde obtener más información del producto';
tooltip.style.width = '250px';
tooltip.style.top = '190px';
tooltip.style.left = '310px';
} else if (text == 'product_desc_tt'){
tooltip.innerHTML = 'Descripción de lo que quieres que sea analizado. Es muy importante que describas perfectamente lo que deseas';
tooltip.style.width = '250px';
tooltip.style.top = '190px';
tooltip.style.left = '310px';
} else if (text == 'number_reviews_total_tt'){
tooltip.innerHTML = 'Introduce el número de análisis que necesitas. Sólo se cobrarán los realizados.';
tooltip.style.width = '250px';
tooltip.style.top = '190px';
tooltip.style.left = '310px';
} else if (text == 'posicion_tt'){
tooltip.innerHTML = 'Limita el número de blogs que pueden realizar tus análisis según su posición en el ranking.';
tooltip.style.width = '250px';
tooltip.style.top = '190px';
tooltip.style.left = '310px';
} else if (text == 'idioma_tt'){
tooltip.innerHTML = 'Filtra los blogs según el idioma en el que escriben la mayoría de sus posts';
tooltip.style.width = '250px';
tooltip.style.top = '190px';
tooltip.style.left = '310px';
} else if (text == 'categoria_tt'){
tooltip.innerHTML = 'Sólo aquellos blogs que pertenezcan a alguna de las categorías que elijas, podrán realizar tus análisis';
tooltip.style.width = '250px';
tooltip.style.top = '190px';
tooltip.style.left = '310px';
} else if (text == 'color_fondo_tt'){
tooltip.innerHTML = 'Haz clic sobre el recuadro pequeño de abajo para elegir el color de fondo o, pon directamente en la caja de texto el código hexadecimal del color. Ejemplo #ff0000. Por defecto es transparente.';
tooltip.style.width = '250px';
tooltip.style.top = '190px';
tooltip.style.left = '310px';
tooltip.style.fontSize='12px';
} else if (text == 'analisis_dia_tt'){
tooltip.innerHTML = 'Destacamos aquí un análisis realizado utilizando Zync.';
tooltip.style.width = '100px';
tooltip.style.top = '190px';
tooltip.style.left = '310px';
tooltip.style.fontSize='12px';
} else if (text == 'articulo_dia_tt'){
tooltip.innerHTML = 'Mostramos un artículo interesante descubierto en la red de blogs de Zync.';
tooltip.style.width = '100px';
tooltip.style.top = '190px';
tooltip.style.left = '310px';
tooltip.style.fontSize='12px';
} else if (text == 'blog_dia_tt'){
tooltip.innerHTML = 'Un blog que nos ha parecido muy interesante.';
tooltip.style.width = '100px';
tooltip.style.top = '190px';
tooltip.style.left = '310px';
tooltip.style.fontSize='12px';
} else if (text == 'excluir_tt'){
tooltip.innerHTML = 'Si marcas esta casilla, no recibirán petición aquellos blogs que te hayan realizado algún análisis entre las fechas que pongas abajo.';
tooltip.style.width = '250px';
tooltip.style.top = '190px';
tooltip.style.left = '310px';
} else if (text == 'excluirurl_tt'){
tooltip.innerHTML = 'No podrán entrar en este mercadillo aquellos blogs cuyas urls añadas en esta caja de texto. Una url por línea.';
tooltip.style.width = '250px';
tooltip.style.top = '190px';
tooltip.style.left = '310px';
} else if (text == 'desde_tt'){
tooltip.innerHTML = 'No recibirán petición aquellos blogs que te hayan realizado algún análisis entre estas dos fechas';
tooltip.style.width = '250px';
tooltip.style.top = '190px';
tooltip.style.left = '310px';
} else if (text == 'enlace_directo_exp'){
tooltip.innerHTML = 'Marcando esta casilla, solicitas enlace directo en lugar del sistema por defecto de redirección.';
tooltip.style.width = '250px';
tooltip.style.top = '190px';
tooltip.style.left = '310px';
} else if (text == 'enlace_directo_1'){
tooltip.innerHTML = 'Recomendamos utilizarla cuando el producto tenga relación con la línea editorial de tu blog o te parezca suficientemente interesante.';
tooltip.style.width = '250px';
tooltip.style.top = '190px';
tooltip.style.left = '310px';
} else if (text == 'enlace_directo_2'){
tooltip.innerHTML = 'Mediante este enlace, podemos medir la efectividad del análisis en clics.';
tooltip.style.width = '250px';
tooltip.style.top = '190px';
tooltip.style.left = '310px';
} else if (text == 'enlace_directo_3'){
tooltip.innerHTML = 'Si conoces HTML, puedes usar este código recomendado por Google cuando el enlace no tiene relación con la línea editorial del blog';
tooltip.style.width = '250px';
tooltip.style.top = '190px';
tooltip.style.left = '310px';
} else if (text == 'excluir_url'){
tooltip.innerHTML = 'En el siguiente campo puedes introducir direcciones de blogs, estos no recibirán petición de análisis por estar baneados.';
tooltip.style.width = '250px';
tooltip.style.top = '190px';
tooltip.style.left = '310px';
}
if (extra == '_mousecoord') {
Event.observe(document, 'mousemove',
function(event){
tooltip.style.left = (Event.pointerX(event) - ((document.body.clientWidth - 900)/2) + 4) + "px";
tooltip.style.top = (Event.pointerY(event) + 6) + "px";
}
);
}
if(show)
tooltip.style.display = 'block';
else
tooltip.style.display = 'none';
}
function toggleVis (id) {
if ($(id).style.display == 'none') {
$(id).style.display = 'block';
} else {
$(id).style.display = 'none';
}
return true;
}
function editCartItem (inventory_id, add, offer) {
$('mini_cart_place_holder').innerHTML = 'Actualizando cesta... Por favor, espere...';
var query = '/global.ajax.php';
var extra_offer = '';
if (offer)
extra_offer = '&oferta='+offer;
var pars = 'action=edit_cart_items&inventory_id=' + inventory_id + '&add=' + add+extra_offer;
var myAjax = new Ajax.Updater(
{success: 'mini_cart_place_holder'},
query,
{
method: 'get',
parameters: pars,
onFailure: reportError
});
}
var mercadillo_paso_numero = 1;
var mercadillo_numero_pasos = 3;
function mercadilloPaso (go)
{
//primero compruebo los campos::
var proceed_to_cart = true;
var num_missing = 0;
var fields = '';
var field_name = '';
var elmArray = new Array();
if (mercadillo_paso_numero==1 && go>0) //paso 1
{
elmArray[0]= $('create_campaign_form').campaign_name;
elmArray[1]= $('create_campaign_form').number_reviews_total;
elmArray[2]= $('create_campaign_form').price_per_review;
elmArray[3]= $('create_campaign_form').price_total;
$('create_campaign_1_notice').innerHTML = 'Comprobando paso 1... Por favor, espera...';
$('create_campaign_1_notice').style.display = 'block';
actualizarPrecioMercadillo();
elmArray.each(function(item)
{
if ($(item.id + '_label'))
{
if (!item.value || item.value == 0 || item.value == 0.00)
{
num_missing++;
field_name = $(item.id + '_label').innerHTML;
field_name = field_name.replace(/\:/g, '');
field_name = field_name.replace(/\*/g, '');
$(item.id + '_p').className = 'missing';
if (fields == '')
{
fields = field_name;
}
else
{
fields += ', ' + field_name;
}
}
else
{
$(item.id + '_p').className = '';
}
}
});
if (num_missing > 0)
{
var s = 's';
if (num_missing == 1) { s = ''; }
$('create_campaign_1_notice').innerHTML = 'Por favor, rellena los siguientes campo' + s + ':
' + fields + '. ';
proceed_to_cart = false;
}
var myRegxp = /[0-9]/;
if (!myRegxp.test($('price_per_review').value))
{
$('price_per_review').value = 0;
$('create_campaign_1_notice').innerHTML += '
El precio por análisis debe ser un número. ';
proceed_to_cart = false;
}
if ($('price_per_review').value < precio_minimo_mercadillo)
{
$('create_campaign_1_notice').innerHTML += '
El precio por análisis debe ser al menos de '+precio_minimo_mercadillo+'€. ';
proceed_to_cart = false;
}
if (!proceed_to_cart)
{
$('create_campaign_1_notice').innerHTML += '
Corrige los errores anteriores y vuelve a pulsar en siguiente. ';
}
if (!proceed_to_cart)
{
return;
}
else
{
$('create_campaign_1_notice').innerHTML = '';
$('create_campaign_1_notice').style.display = 'none';
$('notice_message').innerHTML = '';
$('notice_message').style.display = 'none';
}
}
else if (mercadillo_paso_numero==2 && go>0) //paso 2
{
elmArray[0]= $('create_campaign_form').product_type_id;
elmArray[1]= $('create_campaign_form').product_name_1;
elmArray[2]= $('create_campaign_form').product_url;
elmArray[3]= $('create_campaign_form').product_desc;
elmArray[4]= $('create_campaign_form').posicion;
elmArray[5]= $('create_campaign_form').cat_id;
$('create_campaign_2_notice').innerHTML = 'Comprobando paso 2... Por favor, espera...';
$('create_campaign_2_notice').style.display = 'block';
actualizarPrecioMercadillo();
elmArray.each(function(item)
{
if ($(item.id + '_label'))
{
if (!item.value || item.value == 0 || item.value == 0.00)
{
num_missing++;
field_name = $(item.id + '_label').innerHTML;
field_name = field_name.replace(/\:/g, '');
field_name = field_name.replace(/\*/g, '');
$(item.id + '_p').className = 'missing';
if (fields == '')
{
fields = field_name;
}
else
{
fields += ', ' + field_name;
}
}
else
{
$(item.id + '_p').className = '';
}
}
});
if (num_missing > 0)
{
var s = 's';
if (num_missing == 1) { s = ''; }
$('create_campaign_2_notice').innerHTML = 'Por favor, rellena los siguientes campo' + s + ':
' + fields + '. ';
proceed_to_cart = false;
}
if (num_cats == 0)
{
$('cat_id_p').className = 'missing';
$('create_campaign_2_notice').innerHTML += '
Tienes que elegir al menos una categoría para la oferta. ';
proceed_to_cart = false;
}
if (!proceed_to_cart)
{
$('create_campaign_2_notice').innerHTML += '
Corrige los errores anteriores y vuelve a pulsar en siguiente. ';
}
if (!proceed_to_cart)
{
return;
}
else
{
$('create_campaign_2_notice').innerHTML = '';
$('create_campaign_2_notice').style.display = 'none';
$('notice_message').innerHTML = '';
$('notice_message').style.display = 'none';
}
}
mercadillo_paso_numero += go;
mercadilloOcultarTodos();
$('step_count').innerHTML = mercadillo_paso_numero;
$('step_'+mercadillo_paso_numero).show();
if (mercadillo_paso_numero == 2)
{
if ( $('product_name_1').value == '' ) {
$('product_name_1').value = $('campaign_name').value;
}
}
}
function mercadilloOcultarTodos () {
for (var i = 1; i <= mercadillo_numero_pasos; i++) {
$('step_'+i).hide();
}
}
function actualizarPrecioMercadillo () {
var price_total = 0.00;
var myRegxp = /[0-9]/;
if (!myRegxp.test($('price_per_review').value) && $('price_per_review').value != '') { $('price_per_review').value = 0; }
if (!myRegxp.test($('number_reviews_total').value) && $('number_reviews_total').value != '') { $('number_reviews_total').value = 0; }
price_total = $('number_reviews_total').value * $('price_per_review').value;
if(isNaN(price_total)) price_total = 0;
price_total = price_total.toFixed(2);
$('price_total').value = price_total;
$('price_total_display').innerHTML = price_total;
}
var all_cats = $H();
var max_cats = 4;
var num_cats = 0;
function addCartCampaignCat (cat_id)
{
if (num_cats == max_cats)
return;
all_cats[cat_id] = $('opt_'+cat_id).innerHTML;
num_cats++;
buildAllCartCats();
}
function removeCartCampaignCat (cat_id) {
all_cats.remove(cat_id);
num_cats--;
buildAllCartCats();
}
function buildAllCartCats () {
$('campaign_cats').innerHTML = '';
all_cats.each ( function(pair) {
$('campaign_cats').innerHTML += '