/* Documento JS - Chocolate Santender :: http://www.chocolatesantader.com :: 
Documento realizado por Tribal Colombia http://www.tribalcolombia.com/
Funciones Javascript de Tribal Colombia
 */




/*ESTA FUNCION SIRVE PARA CENTRAR POPUPS*/
var win = null;
function autoCentrada(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable=no'
win = window.open(mypage,myname,settings)
}




/*ESTA FUNCION SIRVE PARA ABRIR Y CERRAR DIVS Y SUS CORRESPONDIENTES CONTENIDOS */


	var agt = navigator.userAgent.toLowerCase();
	var is_major = parseInt(navigator.appVersion);
	var is_nav = ((agt.indexOf('mozilla') != -1) && (agt.indexOf('spoofer') == -1) && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera') == -1) && (agt.indexOf('webtv') == -1));
	var is_nav4up = (is_nav && (is_major >= 4));
	var is_ie = (agt.indexOf("msie") != -1);
	var is_ie3  = (is_ie && (is_major < 4));
	var is_ie4  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5") == -1) && (agt.indexOf("msie 6") == -1));
	var is_ie4up = (is_ie && (is_major >= 4));
	var is_ie5up  = (is_ie  && !is_ie3 && !is_ie4);
	var is_mac = (agt.indexOf("mac") != -1);
	var is_gecko = (agt.indexOf("gecko") != -1);

	function grabObject (id) {
		if (is_ie4) {
			var view = eval(id);
		}
		if (is_ie5up || is_gecko) {
			var view = document.getElementById(id);
		}
		return view;
	}
	function show_hide(id) {
		if(is_ie4up || is_gecko) {
			if(id!= document.tmpId & document.tmpId!= undefined){
				//alert(id+"-"+document.tmpId)		
				var ant_div = grabObject('hdn'+document.tmpId);//miro el layer ant
				ant_div.style.display = 'none';
			}
			var hdn_div = grabObject('hdn'+id);
			var shdn_span = grabObject('shdn'+id);
			var xpand_img = grabObject('img'+id);
			//feliperod
			if(hdn_div.style.display == 'block') {
				hdn_div.style.display = 'none';
				delete_cookie("argosm");
			//	xpand_img.src = '../images/site/ab.gif';
			} else {
				hdn_div.style.display = 'block';
				delete_cookie("argosm");
				setMenu(id)
			//	xpand_img.src = '../images/site/cer.gif';
			}
			//
		}

		document.tmpId=id;
		
	}

	function open_div(number, default_status) {
		if (is_ie4up || is_gecko) {
			document.writeln("<div id='hdn" + number + "' name='hdn" + number + "' style='display: " + default_status + ";'>");
		
		}
	}


	function close_div(number, default_status) {
		if (is_ie4up || is_gecko) {
			document.writeln("</div>");
		}
	}

function set_cookie ( name, value, exp_y, exp_m, exp_d, path, domain, secure )
{
  var cookie_string = name + "=" + escape ( value );

  if ( exp_y )
  {
    var expires = new Date ( exp_y, exp_m, exp_d );
    cookie_string += "; expires=" + expires.toGMTString();
  }

  if ( path )
        cookie_string += "; path=" + escape ( path );

  if ( domain )
        cookie_string += "; domain=" + escape ( domain );
  
  if ( secure )
        cookie_string += "; secure";
  
  document.cookie = cookie_string;
}

function get_cookie ( cookie_name )
{
  var results = document.cookie.match ( cookie_name + '=(.*?)(;|$)' );

  if ( results )
    return ( unescape ( results[1] ) );
  else
    return null;
}
function delete_cookie ( cookie_name )
{
  var cookie_date = new Date ( );  // current date & time
  cookie_date.setTime ( cookie_date.getTime() - 1 );
  document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
}

function setMenu(id){
    var current_date = new Date;
    var cookie_year = current_date.getFullYear ( ) ;
    var cookie_month = current_date.getMonth ( );
    var cookie_day = current_date.getDate ( )+1;
    set_cookie ( "argosm", id, cookie_year, cookie_month, cookie_day );
}
function getMenu(){
  var idd = get_cookie ( "argosm" );
  if(idd!= null){
	show_hide(idd)	
  }
}
function setMenuIndex(id){
	delete_cookie("argosm");
	setMenu(id)
}