/*
  $Id: general.js,v 1.3 2003/02/10 22:30:55 hpdl Exp $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/
var idSelected = -1;
var idSelectedPack = new Array();

var language = 'espanol';
var lang = 'es';

for (i=0;i<10;i++)
{
	 idSelectedPack[i] = -1;
}

function validarFormEditImages(numImages){
	return true;
	
}

function updatePageTitle(text)
{
	document.title = text;
}

function modifycheckImage(check1, check2, capa){
	mostrarCapa(check1, capa, true);
	document.account_edit_images.elements[check2].checked = false;
}

function deletecheckImage(check1, check2, capa){
	mostrarCapa(check1, capa, false);
	document.account_edit_images.elements[check2].checked = false;	
}

function mostrarCapa(check, capa, mostrar){
 if (document.account_edit_images.elements[check].checked && mostrar){
	 xDisplay(capa, 'block') 
//	 document.account_edit_images.pictures_title0.disabled = false; 
//	 document.account_edit_images.pictures_image0.disabled = false; 	 
 }else{
	 xDisplay(capa, 'none') 		 
//	 document.account_edit_images.pictures_title0.disabled = true; 
//	 document.account_edit_images.pictures_image0.disabled = true; 	 
 }
}


function show_popup(URL)
{
  var posX, posY;
  var wPopUp = 450;
  var hPopUp = 350;
  posX = (screen.width - wPopUp) / 2;
  posY = (screen.height - hPopUp) / 2;
  var options='toolbar=no,menubar=no,scrollbars=yes,resizable=no,width='+wPopUp+',height='+hPopUp+',left='+posX+',top='+posY;
  window.open(URL,'avisolegal',options);
}

function popupWindow(url)
{
  var posX, posY;
  var wPopUp = 480;
  var hPopUp = 380;
  posX = (screen.width - wPopUp) / 2;
  posY = (screen.height - hPopUp) / 2;
  var options='toolbar=no,location=no,directories=no,status=no,menubar=no,width='+ wPopUp +',height=' + hPopUp +
  				'scrollbars=no,resizable=no,left='+posX+',top='+posY;
  var popup = window.open(url,'popup',options);
  popup.resizeTo(wPopUp, hPopUp);
}


function SetFocus(TargetFormName) {
  var target = 0;
  if (TargetFormName != "") {
    for (i=0; i<document.forms.length; i++) {
      if (document.forms[i].name == TargetFormName) {
        target = i;
        break;
      }
    }
  }

  var TargetForm = document.forms[target];
    
  for (i=0; i<TargetForm.length; i++) {
    if ( (TargetForm.elements[i].type != "image") && (TargetForm.elements[i].type != "hidden") && (TargetForm.elements[i].type != "reset") && (TargetForm.elements[i].type != "submit") ) {
      TargetForm.elements[i].focus();

      if ( (TargetForm.elements[i].type == "text") || (TargetForm.elements[i].type == "password") ) {
        TargetForm.elements[i].select();
      }

      break;
    }
  }
}

function RemoveFormatString(TargetElement, FormatString) {
  if (TargetElement.value == FormatString) {
    TargetElement.value = "";
  }

  TargetElement.select();
}

function CheckDateRange(from, to) {
  if (Date.parse(from.value) <= Date.parse(to.value)) {
    return true;
  } else {
    return false;
  }
}

function IsValidDate(DateToCheck, FormatString) {
  var strDateToCheck;
  var strDateToCheckArray;
  var strFormatArray;
  var strFormatString;
  var strDay;
  var strMonth;
  var strYear;
  var intday;
  var intMonth;
  var intYear;
  var intDateSeparatorIdx = -1;
  var intFormatSeparatorIdx = -1;
  var strSeparatorArray = new Array("-"," ","/",".");
  var strMonthArray = new Array("jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec");
  var intDaysArray = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

  strDateToCheck = DateToCheck.toLowerCase();
  strFormatString = FormatString.toLowerCase();
  
  if (strDateToCheck.length != strFormatString.length) {
    return false;
  }

  for (i=0; i<strSeparatorArray.length; i++) {
    if (strFormatString.indexOf(strSeparatorArray[i]) != -1) {
      intFormatSeparatorIdx = i;
      break;
    }
  }

  for (i=0; i<strSeparatorArray.length; i++) {
    if (strDateToCheck.indexOf(strSeparatorArray[i]) != -1) {
      intDateSeparatorIdx = i;
      break;
    }
  }

  if (intDateSeparatorIdx != intFormatSeparatorIdx) {
    return false;
  }

  if (intDateSeparatorIdx != -1) {
    strFormatArray = strFormatString.split(strSeparatorArray[intFormatSeparatorIdx]);
    if (strFormatArray.length != 3) {
      return false;
    }

    strDateToCheckArray = strDateToCheck.split(strSeparatorArray[intDateSeparatorIdx]);
    if (strDateToCheckArray.length != 3) {
      return false;
    }

    for (i=0; i<strFormatArray.length; i++) {
      if (strFormatArray[i] == 'mm' || strFormatArray[i] == 'mmm') {
        strMonth = strDateToCheckArray[i];
      }

      if (strFormatArray[i] == 'dd') {
        strDay = strDateToCheckArray[i];
      }

      if (strFormatArray[i] == 'yyyy') {
        strYear = strDateToCheckArray[i];
      }
    }
  } else {
    if (FormatString.length > 7) {
      if (strFormatString.indexOf('mmm') == -1) {
        strMonth = strDateToCheck.substring(strFormatString.indexOf('mm'), 2);
      } else {
        strMonth = strDateToCheck.substring(strFormatString.indexOf('mmm'), 3);
      }

      strDay = strDateToCheck.substring(strFormatString.indexOf('dd'), 2);
      strYear = strDateToCheck.substring(strFormatString.indexOf('yyyy'), 2);
    } else {
      return false;
    }
  }

  if (strYear.length != 4) {
    return false;
  }

  intday = parseInt(strDay, 10);
  if (isNaN(intday)) {
    return false;
  }
  if (intday < 1) {
    return false;
  }

  intMonth = parseInt(strMonth, 10);
  if (isNaN(intMonth)) {
    for (i=0; i<strMonthArray.length; i++) {
      if (strMonth == strMonthArray[i]) {
        intMonth = i+1;
        break;
      }
    }
    if (isNaN(intMonth)) {
      return false;
    }
  }
  if (intMonth > 12 || intMonth < 1) {
    return false;
  }

  intYear = parseInt(strYear, 10);
  if (isNaN(intYear)) {
    return false;
  }
  if (IsLeapYear(intYear) == true) {
    intDaysArray[1] = 29;
  }

  if (intday > intDaysArray[intMonth - 1]) {
    return false;
  }
  
  return true;
}

function IsLeapYear(intYear) {
  if (intYear % 100 == 0) {
    if (intYear % 400 == 0) {
      return true;
    }
  } else {
    if ((intYear % 4) == 0) {
      return true;
    }
  }

  return false;
}





/* formexp.js compiled from X 4.0 with XC 0.27b. Distributed by GNU LGPL. For copyrights, license, documentation and more visit Cross-Browser.com */

var xOp7Up,xOp6Dn,xIE4Up,xIE4,xIE5,xNN4,xUA=navigator.userAgent.toLowerCase();

if(window.opera){
	var i=xUA.indexOf('opera');
	if(i!=-1){var v=parseInt(xUA.charAt(i+6));
		xOp7Up=v>=7;
		xOp6Dn=v<7;
	}
}
else if(navigator.vendor!='KDE' && document.all && xUA.indexOf('msie')!=-1){
	xIE4Up=parseFloat(navigator.appVersion)>=4;
	xIE4=xUA.indexOf('msie 4')!=-1;
	xIE5=xUA.indexOf('msie 5')!=-1;
}
else if(document.layers){
	xNN4=true;
}
xMac=xUA.indexOf('mac')!=-1;
function xDef(){
	for(var i=0; i<arguments.length; ++i){
		if(typeof(arguments[i])=='undefined') return false;
	}
	return true;
}
function xDisplay(e,s){
	if(!(e=xGetElementById(e))) return null;
	if(e.style && xDef(e.style.display)) {
		if (xStr(s)) e.style.display = s;
		return e.style.display;
	}
	return null;
}
function xGetElementById(e){
	if(typeof(e)!='string') return e;
	if(document.getElementById) e=document.getElementById(e);
	else if(document.all) e=document.all[e];
	else e=null;
	return e;
}
function xStr(s){
	for(var i=0; i<arguments.length; ++i){
		if(typeof(arguments[i])!='string') return false;
	}
	return true;
}

function clear_input(object)
{
	 if (object.value == "Email")
			object.value = "";
}

function fill_input(object,text)
{
	 if (object.value == "")
		 object.value = text;
}

function clear_input_newsletter(object)
{
	 if (object.value != "" && object.value.indexOf("E-mail") != -1)
			object.value = "";
}

function fill_input_newsletter(object,text)
{
	 if (object.value == "")
		 object.value = text;
}

function changeToText(object) 
{
	 if (object.value == "")
		{				
		   text = 'Contrase\u00f1a';
		   if (language == 'portugal') text = 'Palavra Passe';
					
					document.getElementById('tdPass').innerHTML ='<input id="input_password" style="border: 1px solid rgb(250, 35, 152); height: 19px; width: 120px; font-size: 10px; font-family: Verdana,Arial,Helvetica,sans-serif; color: rgb(250, 35, 152); padding-left: 5px; padding-top: 2px;" name="password" onkeypress="form_loginHeader_submit(event);" onfocus="changeToPass(this);" onblur="changeToText(this);" maxlength="40" value="'+text+'" type="text">';			
		}
}

function changeToPass(object) 
{
		document.getElementById('tdPass').innerHTML ='<input id="input_password" style="border: 1px solid rgb(250, 35, 152); height: 19px; width: 120px; font-size: 10px; font-family: Verdana,Arial,Helvetica,sans-serif; color: rgb(250, 35, 152); padding-left: 5px; padding-top: 2px;" name="password" onkeypress="form_loginHeader_submit(event);" onblur="changeToText(this);" maxlength="40" value="" type="password">';
	document.getElementById('input_password').focus();
}

function form_loginHeader_submit(key)
{
	tecla = (document.all) ? key.keyCode : key.which;
	if (tecla!=13 ) return;
	document.forms['loginHeader'].submit();
}
function form_login_submit(key)
{
	tecla = (document.all) ? key.keyCode : key.which;
	if (tecla!=13 ) return;
	document.forms['login'].submit();
}

function showErrorPageGen(error,text)
{
		var message="<table id='table_message' border='0' cellspacing='5' cellpadding='0'><tr><td align='center'><table border='0' cellspacing='5' cellpadding='0'><tr><td align='right'><img src='./images/skins/Pink_v_2_0/validator/error.jpg' alt='Error' /></td><td align='left' class='text'><b>"+text+"</b></td></tr></table></td></tr><tr><td align='center' class='text'>"+error+"</td></tr><tr><td align='center' style='padding-top:10px;'><a href='javascript:hideMessage();'><img src='./images/skins/Pink_v_2_0/buttons/button_continue_OFF.jpg' border='0' alt='Continuar' /></a></td></tr></table>";
		showMessageTransSmall(message);
}

function showMessageGeneral(message,position)
{
	var height = 100;
	if ( document.getElementById("tabContainer") != null )
	  height = document.getElementById("tabContainer").offsetHeight;
	
	document.getElementById("transCategoriesMessage").innerHTML=message;
	document.getElementById("transCategories").style.height= height-10;
	document.getElementById("transCategoriesMessage").style.height= height-15;
	if (position == 't')
	{
		 if (height > 300)
				document.getElementById("transCategoriesMessage").style.top = 200;
	}
	else
	{
		document.getElementById("transCategoriesMessage").style.top = height - 300;
	}
	
	document.getElementById("transCategories").style.display="block";
}


function checkLength(valor, permiteVacio, minimo, maximo)
{
	var cantCar=valor.length;
	if(valor=="")
	{
		if(permiteVacio) return true;
		else return false;
	}
	else
	{
		if(cantCar>=minimo && cantCar<=maximo) return true;
		else return false;
	}
}

function selectMark()
{
		var combo = document.getElementById('manufacturers_id');
		var value = combo.options[combo.selectedIndex].value;
		if (value != "" )
		{
    if (navigator.appName.indexOf("Explorer") != -1) 
				{
							if (value == "0")
								location.href = "index.php";
							else
							{
								location.href = value;
							}										
				}
				else
				{
							if (value == "0")
								location.href = lang +"/index.php";
							else
							{
								location.href = lang +'/'+value;
							}					
				}
		}

}
function selectCategory()
{
		var combo = document.getElementById('c_s');
		var url = combo.options[combo.selectedIndex].value;
		
    if (navigator.appName.indexOf("Explorer") != -1) 
				{
								if (url != -1 )
								{
										location.href= url;
								}
								else
								{
										location.href= "index.php";
								}
				}
				else
				{
							if (url != -1 )
							{
									location.href= lang+"/"+url;
							}
							else
							{
									location.href= lang+"/index.php";
							}
				}
				

}


function changeOverImageGen(obj)
{
	 obj.className ='notSelectedOverTabGen';
}

function changeOutImageGen(obj)
{
	 obj.className ='notSelecteTabGen';
}

function changeOverImageGenLast(obj)
{
	obj.className ="notSelectedOverTabGenLast";
}

function changeOutImageGenLast(obj)
{
	 obj.className ='notSelecteTabGenLast';
}




function selectThis(id)
{
	 var tmp = "";
	 if (idSelected == -1) idSelected = id;
		else
		{
			 document.getElementById(idSelected+"_td").className = "text";
		  document.getElementById(idSelected+"_av").className =		"text";
				
				tmp = document.getElementById(idSelected+"_img").src;
		  document.getElementById(idSelected+"_img").src = document.getElementById(idSelected+"_img_on").src;
		  document.getElementById(idSelected+"_img_on").src = tmp;
				
				idSelected = id;
		}
		document.getElementById(id+"_td").className = "text_bold";
		document.getElementById(id+"_av").className =		"text_bold";
		document.getElementById(id+"_radio").checked=true;
		
		tmp = document.getElementById(id+"_img").src;
		document.getElementById(id+"_img").src = document.getElementById(id+"_img_on").src;
		document.getElementById(id+"_img_on").src = tmp;
}

function selectThisPack(id,countProduct)
{
	 var tmp = "";
	 if (idSelectedPack[countProduct] == -1) idSelectedPack[countProduct] = id;
		else
		{
			 document.getElementById(idSelectedPack[countProduct]+"_td_"+countProduct).className = "text";
		  //document.getElementById(idSelectedPack[countProduct]+"_av_"+countProduct).className =		"text";
				
				tmp = document.getElementById(idSelectedPack[countProduct]+"_img_"+countProduct).src;
		  document.getElementById(idSelectedPack[countProduct]+"_img_"+countProduct).src = document.getElementById(idSelectedPack[countProduct]+"_img_on_"+countProduct).src;
		  document.getElementById(idSelectedPack[countProduct]+"_img_on_"+countProduct).src = tmp;
				
				idSelectedPack[countProduct] = id;
		}
		document.getElementById(id+"_td_"+countProduct).className = "text_bold";
		//document.getElementById(id+"_av_"+countProduct).className =		"text_bold";
		document.getElementById(id+"_radio_"+countProduct).checked=true;
		
		tmp = document.getElementById(id+"_img_"+countProduct).src;
		document.getElementById(id+"_img_"+countProduct).src = document.getElementById(id+"_img_on_"+countProduct).src;
		document.getElementById(id+"_img_on_"+countProduct).src = tmp;
}

function showMessageTransCart(message)
{
	var height = 100;
	if ( document.getElementById("tabContainerDiv") != null )
	  height = document.getElementById("tabContainerDiv").offsetHeight;
	document.getElementById("transCartMessage").innerHTML=message;
	document.getElementById("transCart").style.height= height;
	document.getElementById("transCartMessage").style.height= height;
	if ((height / 2) > 100)
	 document.getElementById("transCartMessage").style.top= (height / 2) - 85;
    else
	 document.getElementById("transCartMessage").style.top= (height / 2) - 45;	

	document.getElementById("transCart").style.display="block";	
}

function showMessageTransSmall(message)
{
	var height = 100;
	if ( document.getElementById("tabContainer") != null )
	  height = document.getElementById("tabContainer").offsetHeight;
	document.getElementById("transSmallMessage").innerHTML=message;
	document.getElementById("transSmall").style.height= height - 10;
	document.getElementById("transSmallMessage").style.height= height - 10;
	if ((height / 2) > 100)
	 document.getElementById("transSmallMessage").style.top= (height / 2) - 85;
 else
	 document.getElementById("transSmallMessage").style.top= (height / 2) - 45;	

	document.getElementById("transSmall").style.display="block";
	document.getElementById("transSmall").style.visibility="visible";

}

function showMessageTransSmallNewsletter(message)
{
	var height = 100;
	if ( document.getElementById("tabContainer") != null )
	  height = document.getElementById("tabContainer").offsetHeight;
	document.getElementById("transSmallMessageNewsletter").innerHTML=message;
	document.getElementById("transSmallNewsletter").style.height= height - 10;
	document.getElementById("transSmallMessageNewsletter").style.height= height - 10;
	if ((height / 2) > 100)
	 document.getElementById("transSmallMessageNewsletter").style.top= (height / 2) - 85;
 else
	 document.getElementById("transSmallMessageNewsletter").style.top= (height / 2) - 45;	

	document.getElementById("transSmallNewsletter").style.display="block";
		
}

function hideMessageNewsletter()
{
	document.getElementById("transSmallNewsletter").style.display="none";
}

function hideMessage()
{
	document.getElementById("transSmall").style.display="none";
}

function showMessageShippingCostChanged()
{
				var message="<table id='table_message' border='0' cellspacing='5' cellpadding='0'><tr><td align='center'><table border='0' cellspacing='5' cellpadding='0'><tr><td align='center' class='text_bold'>Los gastos de envio han sido modificados. Pulse para continuar...</b></td></tr></table></td></tr><tr><td align='center' style='padding-top:10px;'><a href='javascript:hideMessage();'><img src='./images/skins/Pink_v_2_0/buttons/button_continue_OFF.jpg' border='0' alt='Continuar' /></a></td></tr></table>";
		 showMessageTransSmall(message);	
}

function showMessageShippingCostFree()
{
				var message="<table id='table_message' border='0' cellspacing='5' cellpadding='0'><tr><td align='center'><table border='0' cellspacing='5' cellpadding='0'><tr><td align='center' class='text_bold'>Los gastos de envio son gratuitos. Pulse para continuar...</b></td></tr></table></td></tr><tr><td align='center' style='padding-top:10px;'><a href='javascript:hideMessage();'><img src='./images/skins/Pink_v_2_0/buttons/button_continue_OFF.jpg' border='0' alt='Continuar' /></a></td></tr></table>";
		 showMessageTransSmall(message);	
}

function showMessageShippingCostChangedAndGift(count)
{
	 text = "Se ha eliminado un regalo";
	 if (count > 1) text = "Se han eliminado "+count+" regalos";
		
		var message="<table id='table_message' border='0' cellspacing='5' cellpadding='0'><tr><td align='center'><table border='0' cellspacing='5' cellpadding='0'><tr><td align='center' class='text_bold'>Los gastos de envio han sido modificados. <br>"+text+" de su cesta de la compra.<br> Pulse para continuar...</b></td></tr></table></td></tr><tr><td align='center' style='padding-top:10px;'><a href='javascript:hideMessage();'><img src='./images/skins/Pink_v_2_0/buttons/button_continue_OFF.jpg' border='0' alt='Continuar' /></a></td></tr></table>";
		 showMessageTransSmall(message);	
}

function showMessageShippingCostFreeAndGift(count)
{
	 text = "Se ha eliminado un regalo";
	 if (count > 1) text = "Se han eliminado "+count+" regalos";

  var message="<table id='table_message' border='0' cellspacing='5' cellpadding='0'><tr><td align='center'><table border='0' cellspacing='5' cellpadding='0'><tr><td align='center' class='text_bold'>Los gastos de envio son gratuitos.<br>"+text+" de su cesta de la compra.<br> Pulse para continuar...</b></td></tr></table></td></tr><tr><td align='center' style='padding-top:10px;'><a href='javascript:hideMessage();'><img src='./images/skins/Pink_v_2_0/buttons/button_continue_OFF.jpg' border='0' alt='Continuar' /></a></td></tr></table>";
		 showMessageTransSmall(message);	
}

function showMessageGiftsDeleted(count)
{
	 text = "Se ha eliminado un regalo";
	 if (count > 1) text = "Se han eliminado "+count+" regalos";

  var message="<table id='table_message' border='0' cellspacing='5' cellpadding='0'><tr><td align='center'><table border='0' cellspacing='5' cellpadding='0'><tr><td align='center' class='text_bold'>"+text+" de su cesta de la compra. Pulse para continuar...</b></td></tr></table></td></tr><tr><td align='center' style='padding-top:10px;'><a href='javascript:hideMessage();'><img src='./images/skins/Pink_v_2_0/buttons/button_continue_OFF.jpg' border='0' alt='Continuar' /></a></td></tr></table>";
			showMessageTransSmall(message);	
}

function rowOverEffect(object) {
  if (object.className == 'moduleRow') object.className = 'moduleRowOver';
}

function rowOutEffect(object) {
  if (object.className == 'moduleRowOver') object.className = 'moduleRow';
}

function findLeftObj(obj) 
{  
 var curleft = 0;  
 if (obj.offsetParent) 
	{  
    while (obj.offsetParent) 
				{  
     curleft += obj.offsetLeft  
     obj = obj.offsetParent;  
    }  
 }  
 else 
	{  
  if(obj.x) 
		{  
    curleft += obj.x;  
  }  
 }  
 return(curleft);  
}  
           
function findTopObj(obj) 
{  
 var curtop = 0;  
 if (obj.offsetParent) 
	{  
     while (obj.offsetParent) 
					{  
         curtop += obj.offsetTop  
         obj = obj.offsetParent;  
     }  
 }  
 else 
	{  
   if (obj.y) 
			{  
     curtop += obj.y;  
   }  
 }  
 return(curtop);  
}  

function showHowToBuy(pID)
{
  var message = '<table border="0" cellpadding="0" cellspacing="0"><tr><td><div class="div_how_to_buy"><table border="0" cellspacing="20" cellpadding="0"><tr><td><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="900" height="400" title="Como Comprar" align="absmiddle"><param name="movie" value="images/skins/Pink_v_2_0/howtobuy/howtobuy3.swf"><param name="quality" value="high" /><param name="wmode" value="transparent"/><embed src="images/skins/Pink_v_2_0/howtobuy/howtobuy3.swf" type="application/x-shockwave-flash" width="900" height="400"></embed></object></td></tr></table></div><div id="div_how_to_buy_close" style="margin-top:-455px;margin-right:-945px;position:relative;top:-1px; right:-910px;"><a href="javascript:hideDemo();"><img src="images/skins/Pink_v_2_0/buttons/button_close_demo_OFF.png" alt="Cerrar" onmouseover="marcar(this);" onmouseout="desmarcar(this);" title=" Cerrar " border="0" width="35" height="33"></a></div></td></tr></table>';

		document.getElementById("transSmallMessageEdit").innerHTML=message;
		
		document.getElementById("transSmallMessageEdit").style.top = f_scrollTop() + 0.5 * ( f_clientHeight() - 447) + "px";
		document.getElementById("transSmallMessageEdit").style.left = f_scrollLeft() + 0.5 * ( f_clientWidth() - 940) + "px";
		
		document.getElementById("transSmallEdit").style.top = 0;
		document.getElementById("transSmallEdit").style.left = 0;
		
		if (document.getElementById("img_footer") != null)
		{    
				document.getElementById("transSmallEdit").style.height = posicion_object_height(document.getElementById("img_footer")) + 50;
		}
		else		
			document.getElementById("transSmallEdit").style.height = screen.availHeight + 450;
		
		document.getElementById("transSmallEdit").style.width = f_clientWidth();
		document.getElementById("transSmallEdit").style.display="block";		
}

function hideDemo()
{
	 	document.getElementById("transSmallEdit").style.display="none";
}

function showInfNut(imagename)
{

	 document.getElementById("transSmallMessageEdit").innerHTML = '<table border="0" cellpadding="0" cellspacing="0"><tr><td>aaaaaaaa<div class="div_edit_cart_header_info" align="right"><div style="margin-right:20px;"><br><a href="javascript:hideUpdate();"><img src="./images/skins/Pink_v_2_0/buttons/button_close_OFF.jpg" alt="Cerrar" onmouseover="marcar(this);" onmouseout="desmarcar(this);" title=" Cerrar " border="0"></a></div></div></td></tr><tr><td><div class="div_edit_cart_content_info" align="center"><br><div style="width:615px; height:400px;overflow:auto;"><table border="0" cellpadding="0" cellspacing="0"><tr><td><img src="img/prod/n/'+imagename+'" alt="" border="0"></td></tr></table></div><br></div></td></tr><tr><td><div class="div_edit_cart_footer_info" align="center"></div></td></tr></table>';
				
		document.getElementById("transSmallMessageEdit").style.top = f_scrollTop() + 0.5 * ( f_clientHeight() - 500) + "px";
		document.getElementById("transSmallMessageEdit").style.left = f_scrollLeft() + 0.5 * ( f_clientWidth() - 640) + "px";
		
		document.getElementById("transSmallEdit").style.top = 0;
		document.getElementById("transSmallEdit").style.left = 0;
		
		if (document.getElementById("img_footer") != null)
		{    
				document.getElementById("transSmallEdit").style.height = posicion_object_height(document.getElementById("img_footer")) + 50;
		}
		else		
			document.getElementById("transSmallEdit").style.height = screen.availHeight + 450;
		
		document.getElementById("transSmallEdit").style.width = f_clientWidth();
		document.getElementById("transSmallEdit").style.display="block";	
		 	
}

function showAlertStock(sid,idProduct)
{
	
 	currentSid = sid;

	 var message = '<table border="0" cellpadding="0" cellspacing="0"><tr><td><div class="div_stock_alert_header"></div></td></tr><tr><td><div><table cellpadding="0" cellspacing="0" border="0"><tr><td class="div_edit_cart_right" width="9"></td><td width="583"><table cellpadding="0" cellspacing="0" border="0" class="div_table_desc" width="583"><tr><td><table width="100%" cellpadding="0" cellspacing="0" border="0" class="div_table_desc"><tr><td><img src="images/pixel_trans.gif" alt="" border="0" width="100%" height="10"></td></tr><tr><td width="85" align="right"><img src="./images/skins/Pink_v_2_0/validator/loading_s.gif" alt="Enviando"></td><td width="10"></td><td width="125" align="left" class="small_text_pink_bold">Cargando Datos ...</td></tr><tr><td><img src="images/pixel_trans.gif" alt="" border="0" width="100%" height="10"></td></tr></table></td></tr></table></td><td class="div_edit_cart_left" width="9"></td></tr></table></div></td></tr><tr><td><div class="div_stock_alert_footer" align="center"></div></td></tr></table>';

		document.getElementById("transSmallMessageEdit").innerHTML=message;
		
		document.getElementById("transSmallMessageEdit").style.top = f_scrollTop() + 0.5 * ( f_clientHeight() - 300) + "px";
		document.getElementById("transSmallMessageEdit").style.left = f_scrollLeft() + 0.5 * ( f_clientWidth() - 520) + "px";
		
		document.getElementById("transSmallEdit").style.top = 0;
		document.getElementById("transSmallEdit").style.left = 0;
		
		if (document.getElementById("img_footer") != null)
		{    
				document.getElementById("transSmallEdit").style.height = posicion_object_height(document.getElementById("img_footer")) + 50;
		}
		else		
			document.getElementById("transSmallEdit").style.height = screen.availHeight + 450;
		
		document.getElementById("transSmallEdit").style.width = f_clientWidth();
		document.getElementById("transSmallEdit").style.display="block";	
 
	
	 var url= lang+'/product_info_ajax.php?action=stock_alert&'+sid+"&pID="+idProduct;

		createAjax();
		xmlhttp.open("GET", url+'', true);
		xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		xmlhttp.onreadystatechange=function()
		{
			if (xmlhttp.readyState==4)
			{
						var message = '<table border="0" cellpadding="0" cellspacing="0"><tr><td><div class="div_stock_alert_header"></div></td></tr><tr><td><div><table cellpadding="0" cellspacing="0" border="0"><tr><td class="div_edit_cart_right" width="9"></td><td width="583"><table cellpadding="0" cellspacing="0" border="0" class="div_table_desc" width="583"><tr><td>'+xmlhttp.responseText+'</td></tr></table></td><td class="div_edit_cart_left" width="9"></td></tr></table></div></td></tr><tr><td><div class="div_edit_cart_footer_newsletter" align="center"></div></td></tr></table>';
						
						document.getElementById("transSmallMessageEdit").innerHTML=message;										
			}
		}
		xmlhttp.send(null);	 
	
	
	
	
}

function showAlertStockAttrs(sid,idProduct,attrs)
{
	 var attrsToPass = '';
	 if (attrs != null)
		{
			   var segmentos = attrs.split('-');
						for(i=0;i<segmentos.length;i++)
						{
							  option = segmentos[i];
									check = document.getElementById("stock_alert_"+option);
									
									if (check.checked == true)
									{
										  if (attrsToPass != '') attrsToPass = attrsToPass + '-';
										  attrsToPass = attrsToPass + option;
									}
						}																
		}

  if (attrsToPass == '')
		{
			  alert ("Por Favor, Selecciona al menos un sabor sobre el cual deseas recibir la notificacion.");
					return;
		}

  var optionID = document.getElementById("product_option_name").value;

	 var message = '<table border="0" cellpadding="0" cellspacing="0"><tr><td><div class="div_stock_alert_header"></div></td></tr><tr><td><div><table cellpadding="0" cellspacing="0" border="0"><tr><td class="div_edit_cart_right" width="9"></td><td width="558"><table cellpadding="0" cellspacing="0" border="0" class="div_table_desc" width="558"><tr><td><table width="100%" cellpadding="0" cellspacing="0" border="0" class="div_table_desc"><tr><td><img src="images/pixel_trans.gif" alt="" border="0" width="100%" height="10"></td></tr><tr><td width="85" align="right"><img src="./images/skins/Pink_v_2_0/validator/loading_s.gif" alt="Enviando"></td><td width="10"></td><td width="125" align="left" class="small_text_pink_bold">Cargando Datos ...</td></tr><tr><td><img src="images/pixel_trans.gif" alt="" border="0" width="100%" height="10"></td></tr></table></td></tr></table></td><td class="div_edit_cart_left" width="9"></td></tr></table></div></td></tr><tr><td><div class="div_stock_alert_footer" align="center"></div></td></tr></table>';

		document.getElementById("transSmallMessageEdit").innerHTML=message;
		
		document.getElementById("transSmallMessageEdit").style.top = f_scrollTop() + 0.5 * ( f_clientHeight() - 300) + "px";
		document.getElementById("transSmallMessageEdit").style.left = f_scrollLeft() + 0.5 * ( f_clientWidth() - 520) + "px";
		
		document.getElementById("transSmallEdit").style.top = 0;
		document.getElementById("transSmallEdit").style.left = 0;
		
		if (document.getElementById("img_footer") != null)
		{    
				document.getElementById("transSmallEdit").style.height = posicion_object_height(document.getElementById("img_footer")) + 50;
		}
		else		
			document.getElementById("transSmallEdit").style.height = screen.availHeight + 450;
		
		document.getElementById("transSmallEdit").style.width = f_clientWidth();
		document.getElementById("transSmallEdit").style.display="block";	
 
	
	 var url= lang+'/product_info_ajax.php?action=stock_alert_attrs&'+sid+"&pID="+idProduct+"&optionID="+optionID+"&optionValueID="+attrsToPass;
	
		createAjax();
		xmlhttp.open("GET", url+'', true);
		xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		xmlhttp.onreadystatechange=function()
		{
			if (xmlhttp.readyState==4)
			{
						var message = '<table border="0" cellpadding="0" cellspacing="0"><tr><td><div class="div_stock_alert_header"><br><br><center><img src="images/skins/Pink_v_2_0/stock_alerts/espanol/text.png"></center></div></td></tr><tr><td><div><table cellpadding="0" cellspacing="0" border="0"><tr><td class="div_edit_cart_right" width="9"></td><td width="558"><table cellpadding="0" cellspacing="0" border="0" class="div_table_desc" width="558"><tr><td>'+xmlhttp.responseText+'</td></tr></table></td><td class="div_edit_cart_left" width="9"></td></tr></table></div></td></tr><tr><td><div class="div_edit_cart_footer_newsletter2" align="center"></div></td></tr></table>';
						
						document.getElementById("transSmallMessageEdit").innerHTML=message;										
			}
		}
		xmlhttp.send(null);	 
	
	
	
	
}

function validateFormStockAlert()
{
	
		document.getElementById("email_stock_alert").className="account_text_field";

		error=0;
		var email_stock_alert = document.getElementById('email_stock_alert');
		var pID = document.getElementById('pID');

		var message="<img src='./images/skins/Pink_v_2_0/validator/loading.gif' alt='Enviando'><br><span class='text'><b>Validando Datos. Por favor espere.</b></span><br><br>";

		showMessageTransSmallNewsletter(message);
		
		createAjax();
		
		var url = '&email_stock_alert='+encodeURIComponent(email_stock_alert.value)+'&pID='+pID.value;
				
		var request = lang+'/product_info_ajax.php?action=create_stock_alert'+ url;
										
		xmlhttp.open("GET", request, true);
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlhttp.send(null);
		xmlhttp.onreadystatechange=function()
		{
			if (xmlhttp.readyState==4)
			{
				var response=xmlhttp.responseText;
								
				if( response!= "" && response.indexOf(OKCODE) != -1)
				{
					
					 response = response.substring(9,response.length);
					 var message="<table id='table_message' border='0' cellspacing='5' cellpadding='0'><tr><td align='center'><table border='0' cellspacing='5' cellpadding='0'><tr><td align='right'><img src='./images/skins/Pink_v_2_0/validator/ok.png' alt='Ok'></td><td align='left' class='text'><b>Enhorabuena</b></td></tr></table></td></tr><tr><td align='center' class='text'>"+response+"</td></tr><tr><td align='center' style='padding-top:10px;'><a href='javascript:hideUpdate();'><img src='./images/skins/Pink_v_2_0/buttons/button_continue_OFF.jpg' border='0' alt='Continuar' /></a></td></tr></table>";				
					 showMessageTransSmallNewsletter(message);
 
				}
				else
				{
	 	  text = 'Error al procesar la peticion:';
 		  if (language == 'portugal') text = 'Erro ao processar:';								
					setFieldError(document.getElementById("email_stock_alert"));
	    var message="<table id='table_message' border='0' cellspacing='5' cellpadding='0'><tr><td align='center'><table border='0' cellspacing='5' cellpadding='0'><tr><td align='right'><img src='./images/skins/Pink_v_2_0/validator/error.jpg' alt='Error' /></td><td align='left' class='text'><b>"+text+"</b></td></tr></table></td></tr><tr><td align='center' class='text'>"+response+"</td></tr><tr><td align='center' style='padding-top:10px;'><a href='javascript:hideMessageNewsletter();'><img src='./images/skins/Pink_v_2_0/buttons/button_continue_OFF.jpg' border='0' alt='Continuar' /></a></td></tr></table>";				
					showMessageTransSmallNewsletter(message);
					
				}
			}
		}
}

function validateFormStockAlertAttrs()
{
	
		document.getElementById("email_stock_alert").className="account_text_field";

		error=0;
		var email_stock_alert = document.getElementById('email_stock_alert');
		var pID = document.getElementById('pID');
		var optionID = document.getElementById('optionID');
		var optionValueID = document.getElementById('optionValueID');

		var message="<img src='./images/skins/Pink_v_2_0/validator/loading.gif' alt='Enviando'><br><span class='text'><b>Validando Datos. Por favor espere.</b></span><br><br>";

		showMessageTransSmallNewsletter(message);
		
		createAjax();
		
		var url = '&email_stock_alert='+encodeURIComponent(email_stock_alert.value)+'&pID='+pID.value+'&optionID='+optionID.value+'&optionValueID='+optionValueID.value;
				
		var request = lang+'/product_info_ajax.php?action=create_stock_alert_attrs'+ url;
										
		xmlhttp.open("GET", request, true);
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlhttp.send(null);
		xmlhttp.onreadystatechange=function()
		{
			if (xmlhttp.readyState==4)
			{
				var response=xmlhttp.responseText;
								
				if( response!= "" && response.indexOf(OKCODE) != -1)
				{
					
					 response = response.substring(9,response.length);
					 var message="<table id='table_message' border='0' cellspacing='5' cellpadding='0'><tr><td align='center'><table border='0' cellspacing='5' cellpadding='0'><tr><td align='right'><img src='./images/skins/Pink_v_2_0/validator/ok.png' alt='Ok'></td><td align='left' class='text'><b>Enhorabuena</b></td></tr></table></td></tr><tr><td align='center' class='text'>"+response+"</td></tr><tr><td align='center' style='padding-top:10px;'><a href='javascript:hideUpdate();'><img src='./images/skins/Pink_v_2_0/buttons/button_continue_OFF.jpg' border='0' alt='Continuar' /></a></td></tr></table>";				
					 showMessageTransSmallNewsletter(message);
 
				}
				else
				{
	 	  text = 'Error al procesar la peticion:';
 		  if (language == 'portugal') text = 'Erro ao processar:';								
					setFieldError(document.getElementById("email_stock_alert"));
	    var message="<table id='table_message' border='0' cellspacing='5' cellpadding='0'><tr><td align='center'><table border='0' cellspacing='5' cellpadding='0'><tr><td align='right'><img src='./images/skins/Pink_v_2_0/validator/error.jpg' alt='Error' /></td><td align='left' class='text'><b>"+text+"</b></td></tr></table></td></tr><tr><td align='center' class='text'>"+response+"</td></tr><tr><td align='center' style='padding-top:10px;'><a href='javascript:hideMessageNewsletter();'><img src='./images/skins/Pink_v_2_0/buttons/button_continue_OFF.jpg' border='0' alt='Continuar' /></a></td></tr></table>";				
					showMessageTransSmallNewsletter(message);
					
				}
			}
		}
}









