﻿/* base 64 */

if(!Base64){
var Base64 = {
 
	// private property
	_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
 
	// public method for encoding
	encode : function (input) {
		var output = "";
		var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
		var i = 0;
 
		input = Base64._utf8_encode(input);
 
		while (i < input.length) {
 
			chr1 = input.charCodeAt(i++);
			chr2 = input.charCodeAt(i++);
			chr3 = input.charCodeAt(i++);
 
			enc1 = chr1 >> 2;
			enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
			enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
			enc4 = chr3 & 63;
 
			if (isNaN(chr2)) {
				enc3 = enc4 = 64;
			} else if (isNaN(chr3)) {
				enc4 = 64;
			}
 
			output = output +
			this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
			this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
 
		}
 
		return output;
	},
 
	// public method for decoding
	decode : function (input) {
		var output = "";
		var chr1, chr2, chr3;
		var enc1, enc2, enc3, enc4;
		var i = 0;
 
		input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
 
		while (i < input.length) {
 
			enc1 = this._keyStr.indexOf(input.charAt(i++));
			enc2 = this._keyStr.indexOf(input.charAt(i++));
			enc3 = this._keyStr.indexOf(input.charAt(i++));
			enc4 = this._keyStr.indexOf(input.charAt(i++));
 
			chr1 = (enc1 << 2) | (enc2 >> 4);
			chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
			chr3 = ((enc3 & 3) << 6) | enc4;
 
			output = output + String.fromCharCode(chr1);
 
			if (enc3 != 64) {
				output = output + String.fromCharCode(chr2);
			}
			if (enc4 != 64) {
				output = output + String.fromCharCode(chr3);
			}
 
		}
 
		output = Base64._utf8_decode(output);
 
		return output;
 
	},
 
	// private method for UTF-8 encoding
	_utf8_encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";
 
		for (var n = 0; n < string.length; n++) {
 
			var c = string.charCodeAt(n);
 
			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}
 
		}
 
		return utftext;
	},
 
	// private method for UTF-8 decoding
	_utf8_decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;
 
		while ( i < utftext.length ) {
 
			c = utftext.charCodeAt(i);
 
			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}
 
		}
 
		return string;
	}
 
}

}



//v1.0
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = args[i+1];
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}
function cambiar(src,ancho,alto,calidad,wmode){
		AC_FL_RunContent(
			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0',
			'width', ancho,
			'height', alto,
			'src', src,
			'quality', calidad,
			'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
			'align', 'middle',
			'play', 'true',
			'loop', 'true',
			'scale', 'showall',
			'wmode', wmode,
			'devicefont', 'false',
			'id', 'home',
			'bgcolor', '#663399',
			'name', 'home',
			'menu', 'true',
			'allowScriptAccess','sameDomain',
			'movie', src,
			'salign', ''
		); 	
}





	
	function switch_tabs(obj)
{
	$('.tab-content').hide();
	$('.tabs a').removeClass("selected");
	var id = obj.attr("rel");
 
	$('#'+id).show();
	obj.addClass("selected");
}
	
	
	function ToggleOpen(id){	   	   
		    var elem = $(id).next();	
			var icon = $(id).children('span');						
			if(elem.is('ul') && elem.html() != ''){
	
				$('.navigation-menu-items ul:visible').not(elem).slideUp();
				$('.navigation-menu-items li a span').not(icon).attr('class','navigation-icon-close');
				icon.toggleClass('navigation-icon-open');
				elem.slideToggle();
			
			}
	}
	
	
	function _block(){

    $("<div></div>").addClass("ui-widget-overlay").appendTo(document.body).css({width:$(document).width(),height:$(document).height()});
   // $('<div class="ui-widget-overlay" style="width: '+$(document).width()+'px; height: '+$(document).height()+'px; z-index: 1001;"></div>').appendTo('body')
}

function _unblock(){
    $('.ui-widget-overlay').remove();
}




function _blelm_(el){

/*ui-widget-overlay*/
/*<div class="ui-widget-overlay" style="width: 1135px; height: 1402px; z-index: 1001;"></div>*/

$(el).addClass('ui-widget-overlay').css('position','relative');

/*$(el).addClass('ui-widget-overlay',2000, function(){
    $(el).css('position','relative');
    }
);
*/
/*.appendTo('body').show();*/

}




   function _PCMSCartSubmitForm(OPath, pId, pQty, priceId){
        var rand   = Math.random(9999);         
        var urlLand = OPath+'?Template=_includes/_NGNAjaxCart/_NGNAjaxCartResponseMessage';
        urlLand = Base64.encode(urlLand);
        var url = OPath+'Actions.ashx?_do=addcart&';
        if(priceId>0)
        url+='PriceId='+priceId;
        else
        url+='ItemId='+pId;
        url+='&count='+pQty;
        /*+'Actions.aspx?moduleName=cart&_action=add&ID='+pId+'&Quantity='+pQty+'&returnUrl='+urlLand+'&rand='+rand;*/
        var $dlg = $('<div> <p align="center">Espere por favor...</p><p align="center"><img src="'+OPath+'_css/_images/loader.gif" border="0" /></p></div>').appendTo('body');								 
        $dlg.dialog({
				        modal:true,
				        width:570,
				        resizable: false ,
				        title:'Carrito de Compras'
				    });
				    $.getJSON(url+'&rnd='+rand, function(data) {                              
                            
                            if(data[0].errCode=='0')
                           {
                            var rand   = Math.random(9999); 
                            $('#_crt_holder').load(OPath+'_loader.aspx?ctrl=CartBox&rnd='+rand);
                            $dlg.load(OPath+'DetCart.aspx?rnd='+rand, function(){
                                    $('.closecartdlg').click(function(ev){
                                    $dlg.dialog('close');
                                    return false;
        
                                        });
                                    
                                });

                           
                           
                           }
                            else                                    
                            $dlg.html(data[0].errMsg);                                
                                                                                  
                            });       
				        return false;
            }
	
	
	
	
	function _PCMSContactSubmitForm(frmid){
 var rand   = Math.random(9999);
 var formData = $('#_pcms_contact_'+frmid).serialize();
 var OPath=$('#_arp_'+frmid).val();
 if(!OPath)
 OPath='';
 $('#_pcms_contact_'+frmid).html('<div> <p align="center">Espere por favor...</p><p align="center"><img src="'+OPath+'_css/_images/loader.gif" border="0" /></p></div>');
 $('#_pcms_contact_'+frmid).load(OPath+'_loader.aspx?'+formData+'&ctrl=contact-form&FormName='+frmid+'&_frm_rnd='+rand, function() {
        // perform some action when the content is loaded
        $(this).fadeIn('slow');

        // unsure if $(this) works with .load(), use the line below if it doesn't
        $('#_pcms_contact_'+frmid).fadeIn('slow');  
        $(".pcms-contact-submit").click(function(){
                return _PCMSContactSubmitForm($(this).attr('id').replace('contact-submit-',''));
                
                
            });      
    });
    
 return false;   
}

	
	
	$(function(){
	/* Navigation menu */
		$('.navigation-menu-items li a').click(function(event){
			var elem = $(this).next();
			var icon = $(this).children('span');						
			if(elem.is('ul') && elem.html() != ''){
				event.preventDefault();
				$('.navigation-menu-items ul:visible').not(elem).slideUp();
				$('.navigation-menu-items li a span').not(icon).attr('class','navigation-icon-close');
				icon.toggleClass('navigation-icon-open');
				elem.slideToggle();
			
			}else
			return true;
		});
		                        
        /* Hide default values in inputs... */
        $('.hidef').focus( function(){                    
            if(!$(this).attr('def-cnt'))
                $(this).attr('def-cnt',$(this).val())
            $(this).attr('def-cnt') == $(this).val()
                $(this).val('');
        });
        
        $('.hidef').blur( function(){
            if($(this).val() == '')
            $(this).val($(this).attr('def-cnt'));           
        });
        
        
        /* Contact Submit */
          $(".pcms-contact-submit").click(function(){
                return _PCMSContactSubmitForm($(this).attr('id').replace('contact-submit-',''));                                
            });

        
        /*tabs */
        $('.tabs a').click(function(){
		        switch_tabs($(this));
		        return false;
	            });	            	            
 
	    switch_tabs($('.defaulttab'));



    /* Country, City State, town populator */
    
    $(".__priceoptionselect__").change(function() {
        
        $(".__pricevalue__").html($(".__priceoptionselect__ option:selected").val().split('-')[1]);
    });
    
    $(".__stateselect__").change(function() {
                
                $(".__citiesselect__").html("<option>Aguarde por favor...</option>");                
                var StateID = $(".__stateselect__ option:selected").val();
                var s = '';                
                if (StateID != 0) {                                                              
                       $.getJSON('LocationData.ashx?get=city&id=' + StateID, function(data) {                                                               
                                 var html = '';
                                 $(".__citiesselect__").html("");                
                                var len = data.length;
                                for (var i = 0; i< len; i++) {
                                        html += '<option value="' + data[i].ID + '">' + data[i].City + '</option>';
                                }
                                $('.__citiesselect__').append(html);  
                                                              
                                });                
                }
            
            });
  /*          
    $(".__citiesselect__").change(function() {
                
                $(".__townsselect__").html("<option>Aguarde por favor...</option>");                
                var StateID = $(".__citiesselect__ option:selected").val();
                var s = '';                
                if (StateID != 0) {                                                              
                       $.getJSON('LocationData.ashx?get=town&id=' + StateID, function(data) {                                                               
                                 var html = '';
                                 $(".__townsselect__").html("");                
                                var len = data.length;
                                for (var i = 0; i< len; i++) {
                                        html += '<option value="' + data[i].ID + '">' + data[i].Town + '</option>';
                                }
                                $('.__townsselect__').append(html);  
                                                              
                                });                
                }
            
            });        */
            
            
            
            /* Boton de compra */
              $('._PCMS_CART_BUTTON').click(function(ev) {     
         ev.preventDefault();
        var itemid = $(this).attr('item-id');
        var rootPath = '';//$(this).attr('root-path');
        var qt1 = 1;        
        if($(this).attr('qty-im')){
                qt1 = $($(this).attr('qty-im')).val();
                
            }
        var picid = $(".__priceoptionselect__ option:selected").val();
        if(picid=='0')
          priceid= 0;
          else
          priceid = picid.split('-')[0];  
        _PCMSCartSubmitForm(rootPath, itemid, qt1, priceid);
        /*alert($(this).attr('title'));
        var $target = $(ev.target);
        alert($target.attr('title'));*/
        //itemId = $(this).attr('src');
        return false;
     });


	});



/* Raise Dialog */

function __Message(cssc, title, icon, message){
$( "#___dialog-message__:ui-dialog" ).dialog( "destroy" );



					
var $data = $('<div class="'+cssc+'" id="___dialog-message__" title="'+title+'"><div style="margin-top: 20px; padding: 0pt 0.7em;  min-height: 59.4px; padding-top:5px;" class="'+cssc+' ui-corner-all"> <p><span class="ui-icon '+icon+'" style="float:left; margin:0 7px 50px 0;"></span>'+message+'</p></div></div>').appendTo('body');								 				    							    
    
    $data.dialog({
			modal: true,
			buttons: {
				Ok: function() {
					$( this ).dialog( "close" );
				}
			}
		});

		    
		}
