function MootoolsHeaderCountry(idCountry,idWine,idGrape,idRender,idLoading)
{
    obL = document.getElementById(idLoading);
    if (obL!=null) obL.style.display = 'block';

    var myHTMLRequest = new Request.HTML(
    {url:'function.aspx',
    noCache:true,
    onSuccess: function(responseText, responseXML, responseHTML, responseJavascript) 
    {
        if (obL!=null) obL.style.display = 'none';
        //$(idRender).empty();
        document.getElementById(idRender).set('html', responseHTML);
    }
    }).get('mod=headercountry&idcountry=' + idCountry + '&idwinetype=' + idWine + '&idwinegrap=' + idGrape);
}
function MootoolsHeaderWine(idCountry,idWine,idGrape,idRender,idLoading)
{
    obL = document.getElementById(idLoading);
    if (obL!=null) obL.style.display = 'block';

    var myHTMLRequest = new Request.HTML(
    {url:'function.aspx',
    noCache:true,
    onSuccess: function(responseText, responseXML, responseHTML, responseJavascript) 
    {
        if (obL!=null) obL.style.display = 'none';
        //$(idRender).empty();
        document.getElementById(idRender).set('html', responseHTML);
    }
    }).get('mod=headerwine&idcountry=' + idCountry + '&idwinetype=' + idWine + '&idwinegrap=' + idGrape);
}
function MootoolsHeaderGrape(idCountry,idWine,idGrape,idRender,idLoading)
{
    obL = document.getElementById(idLoading);
    if (obL!=null) obL.style.display = 'block';

    var myHTMLRequest = new Request.HTML(
    {url:'function.aspx',
    noCache:true,
    onSuccess: function(responseText, responseXML, responseHTML, responseJavascript) 
    {
        if (obL!=null) obL.style.display = 'none';
        //$(idRender).empty();
        document.getElementById(idRender).set('html', responseHTML);
    }
    }).get('mod=headergrape&idcountry=' + idCountry + '&idwinetype=' + idWine + '&idwinegrap=' + idGrape);
}


function BuyProduct(idProduct) {
    BuyProduct(idProduct, 1);
}


function BuyProduct(idProduct, cant) {
    cantStr = "";
    if (cant > 0)
        cantStr = "&cant=" + cant;
        
    var prueboRequest = new Request({
    method: 'get',
       url: 'function.aspx?mod=addproduct&id='+idProduct + cantStr,
       noCache: 'true',
       onRequest: function() { /*document.getElementById('imgLoading').style.display='block'; */ },
       onSuccess: function(texto, xmlrespuesta)
       { 
       
           //document.getElementById('imgLoading').style.display='none'; 
           switch (texto)
           {
               case "login":
                window.location = '/Login.aspx';
               break;
               case "error":
                alert("Por el momento no se puede realizar esta operación");
               break;
               case "ok":
                window.location = '/Carro/Paso1.aspx';
               break;
           }
       
       },
       onFailure: function(){/*document.getElementById('imgLoading').style.display='none';*/ alert("Por el momento no se puede realizar esta operación");}
    }).send();
}    
function MootoolsLogin(email,name,surname,sperror,loading,idproduct)
{
    obL = document.getElementById(loading);
    if (obL!=null) obL.style.display = 'block';

    var myHTMLRequest = new Request.HTML(
    {url:'function.aspx',
    onSuccess: function(responseText, responseXML, responseHTML, responseJavascript) 
    {
        if (obL!=null) obL.style.display = 'none';
	            switch (responseHTML.split('|')[0])
	            {
	                case "ok":
	                    //window.location = window.location;
	                    BuyProduct(idproduct)
	                break;
	                case "error":
	                    ob = document.getElementById(sperror);
	                    if (ob!=null)
	                    {
	                        ob.innerHTML = responseHTML.split('|')[1];
	                    }
	                break;
	            }
    }
    }).get('mod=login&email=' + email + '&name=' + name + '&surname=' + surname + '&idProduct=' + idproduct);

}
function validateEMailFormat(email)
{
  return !(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email));
}
function GetSelectValueItem(sIdOb)
{
    ob = document.getElementById(sIdOb);
    if (ob.length>0)
    {
        return ob[ob.selectedIndex].value;
    }
    else
    {
        return 0;
    }
}
function getURLParam(strParamName){
  var strReturn = "";
  var strHref = window.location.href;
  if ( strHref.indexOf("?") > -1 ){
    var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
    var aQueryString = strQueryString.split("&");
    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
      if ( 
aQueryString[iParam].indexOf(strParamName.toLowerCase() + "=") > -1 ){
        var aParam = aQueryString[iParam].split("=");
        strReturn = aParam[1];
        break;
      }
    }
  }
  return unescape(strReturn);
}


function RemoveValueConotrol(ob)
{
	if (ob!=null)
	{ob.value='';}
}
function IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         return false;
         }
      }
   return true;
   
}
function AddNumberInput(idObject)
{
	ob = document.getElementById(idObject);
	if (ob!=null)
	{
		if (IsNumeric(ob.value))		
		{
			ii = parseInt(ob.value) + 1;
			ob.value = ii;
		}
		else
		{
			ob.value = 1;
		}
	}
}
function SubtractNumberInput(idObject)
{
	ob = document.getElementById(idObject);
	if (ob!=null)
	{
		if (IsNumeric(ob.value))		
		{
			ii = parseInt(ob.value) - 1;
			if (ii>0)
			{ob.value = ii;}
			else
			{ob.value = 1;}
		}
		else
		{
			ob.value = 1;
		}
	}
}

function LoadVideo(divContainerVideo,idContent,playerWidth,playerHeight,showControlBar,sPathImage,sPathFLVVideo)
{
    ob = document.getElementById(divContainerVideo);
    if (ob!=null)
    {
        var so = new SWFObject('swf/player.swf','vdo' + idContent,playerWidth,playerHeight,'9');
        so.addParam("wmode", "transparent");        
        so.addParam('allowscriptaccess','always');
        so.addParam('allowfullscreen','true');
        so.addVariable('autostart','false');
        so.addVariable('file',sPathFLVVideo);
        so.addVariable('image',sPathImage);
        so.addVariable('backcolor','#F4F4F4');
        so.addVariable('screencolor','#000000');
        so.addVariable('lightcolor','#000000');
		if (!showControlBar){so.addVariable('controlbar','none');}
        so.write(divContainerVideo);
	}
}


