	window.addEvent('domready', function() { myCal = new Calendar({ date: 'm/d/Y' }); });

	window.addEvent('domready', function() { new FormCheck('RegForm'); });

	window.addEvent('domready', function() { msg = new SexyAlertBox(); });

	window.addEvent('domready', function() { SexyBox = new SexyLightBox({OverlayStyles: {'background-color': '#000000'}}); });

	window.addEvent('domready', function() {

	//store titles and text

	$$('a.tipz').each(function(element,index) {

		var content = element.get('title').split('::');

		element.store('tip:title', content[0]);

		element.store('tip:text', content[1]);

	});

	//create the tooltips

	var tipz = new Tips('.tipz',{

		className: 'tipz',

		fixed: true,

		hideDelay: 50,

		showDelay: 50

	});

	});

	



	

	function confirma (id,name,t){

	

	var url;

	var str;

		

	  switch(t){

			case 1:

						url = "/products/save.php?op=delete&pid=" + id;

						str =  ConfirmeP1 + name + ConfirmeP2;

			break;

			case 2:		url = "/discounts/save.php?op=delete&did=" + id;

						str = ConfirmeC1;

			break;

	}

	str = "<b>" + Confirme + "</b><br /><br />" + str;  

	msg.confirm(str, {	onComplete:  function(returnvalue) { if(returnvalue) { window.location = url; }}});

	

	}	

	

function subcat(id) {



	window.addEvent('domready', function(){

   	//función a ejecutar cuando esté listo el dom

    // $('mienlace').addEvent('click', function(evento){   

    var nuevoRequest = new Request({

         method: 'get',

         url: 'data.php',

		 data:	'id_cat=' + id,

         onRequest: function() { $('sub-categorias').set('html','<img src="/includes/images/sexyimages/black/loading.gif" width="43" height="11" />');},

         onSuccess: function(texto, xmlrespuesta){ $('sub-categorias').set('html',texto);},

         onFailure: function(){alert('Error!');}

    	}).send();

	});

	

	div 	= document.getElementById("categorias");

	labels  = div.getElementsByTagName("label");

		len = labels.length;

		for(i=0 ; i < len; i ++){

			var oNode = labels.item(i); 

			document.getElementById(oNode.id).className = "categ-normal";

		}

	id = 'cat_' + id;

	document.getElementById(id).className = "categ-sel";

}



	function _mrk (id){

		div 	= document.getElementById("sub-categorias");

		labels  = div.getElementsByTagName("label");

		len = labels.length;

		for(i=0 ; i < len; i ++){

			var oNode = labels.item(i); 

			document.getElementById(oNode.id).className = "categ-normal";

		}

		id_sub = 'sub_' + id;

		document.getElementById(id_sub).className = "categ-sel";

		document.getElementById('category').value = id;

	}

	

	

	function viewsubcat(id){

		window.addEvent('domready', function(){

   	//función a ejecutar cuando esté listo el dom

    // $('mienlace').addEvent('click', function(evento){   

    var nuevoRequest = new Request({

         method: 'get',

         url: 'data.php',

		 data:	'id_cat=' + id,

         onRequest: function() { $('categorias').set('html','<img src="/includes/images/sexyimages/black/loading.gif" width="43" height="11" />');},

         onSuccess: function(texto, xmlrespuesta){ $('categorias').set('html',texto);},

         onFailure: function(){alert('Error!');}

    	}).send();

	});

		if(id == "Ok"){

			viewdiscount('','1','cat');

		}

		else {

			viewdiscount(id,'1','sub');

		}

	}



function viewdiscount(id,p,u){

		window.addEvent('domready', function(){

   	//función a ejecutar cuando esté listo el dom

    // $('mienlace').addEvent('click', function(evento){   

	

	switch(u){

		case 'user': 

			var datos = 'op=user&aid=' + id;

			break;

		case 'all':

			var datos = 'op=all&subcat_id=' + id + '&page=' + p;

			break;

		case 'cat':

			var datos = 'op=cat';

			break;

		case 'sub':

			var datos = 'op=sub&id_cat=' + id;

			break;

		case 'bus':

			var datos = 'op=bus&search_dis_txt=' + id;

			break;

		case 'sea':

			var datos = 'op=sea&info=' + id;

			break;

		case 'fav':

			var datos = 'op=fav';

			break;

		case 'new':

			var datos = 'op=new';

			break;

		case 'top':

			var datos = 'op=top';

			break;

	}

			

    var nuevoRequest = new Request({

         method: 'get',

         url: '/catalog/viewdiscount.php',

		 data:	datos,

         onRequest: function() { $('discounts').set('html','<img src="/includes/images/sexyimages/black/loading.gif" width="43" height="11" />');},

         onSuccess: function(texto, xmlrespuesta){ $('discounts').set('html',texto);},

         onFailure: function(){alert('Error!');}

    	}).send();

	});

	}



function adddis(id){

		window.addEvent('domready', function(){

   	//función a ejecutar cuando esté listo el dom

    // $('mienlace').addEvent('click', function(evento){   

	iddiv = 'dis-add-' + id;

    var nuevoRequest = new Request({

         method: 'get',

         url: 'adddiscount.php',

		 data:	'did=' + id,

		 onRequest: function() { $(iddiv).set('html','<img src="/includes/images/sexyimages/black/loading.gif" width="43" height="11" />');},

         onSuccess: function(texto, xmlrespuesta){ $(iddiv).set('html',texto);},

         onFailure: function(){alert('Error!');}

    	}).send();

	});

	}

	





function viewdatails(id){

window.addEvent('domready', function(){

   	//función a ejecutar cuando esté listo el dom

    // $('mienlace').addEvent('click', function(evento){   

	iddiv 	= 'des-detalle-' + id;

	aid   	= 'show-hidde-' + id;

	img   	= 'img-show-hidde-' + id;

	$status = document.getElementById(aid).name

	

	if($status == 'Ver'){

		//alert('Error Fatal: Windows debe reiniciarse');	

		document.getElementById(aid).name = "NoVer";

		document.getElementById(img).innerHTML ='<img src="/includes/images/dis_close.png" alt="" width="16" height="16" align="absmiddle">';

	}

	else{

		document.getElementById(iddiv).innerHTML = "&nbsp;";

		document.getElementById(img).innerHTML ='<img src="/includes/images/dis_open.png" alt="" width="16" height="16" align="absmiddle">';

		document.getElementById(aid).name = "Ver";

		return;

	}

	 

	

    var nuevoRequest = new Request({ 

         method: 'get',

         url: '/catalog/discount_detail.php',

		 data:	'did=' + id,

		 onRequest: function() { $(iddiv).set('html','<img src="/includes/images/sexyimages/black/loading.gif" width="43" height="11" />');},

         onSuccess: function(texto, xmlrespuesta){ $(iddiv).set('html',texto);},

         onFailure: function(){alert('Error!');}

    	}).send();

	});

	}



function coupon_ie (num,did,tipo){



if(isNaN(num.value)){

	num.value = '';

	return;

}

else {

	id = 'id-printed-ie-' + did + '-' + tipo;

	window.addEvent('domready', function(){

		var nuevoRequest = new Request({ 

        	method: 'get',

    	    url: '/catalog/coupon_ie_gen.php',

			data:	'tipo=' + tipo + '&id=' + did + '&num=' + num.value,

			onRequest: function() { $(id).set('html','<img src="/includes/images/sexyimages/black/loading.gif" width="43" height="11" />');},

	        onSuccess: function(texto, xmlrespuesta){ $(id).set('html',texto);},

        	onFailure: function(){alert('Error!');}

    	}).send(); });

	}

}





function pw_refresh(pag,num){

	window.addEvent('domready', function(){

		var nuevoRequest = new Request({ 

        	method: 'get',

    	    url: '/members/ajax/pwline.php',

			data:	'pag=' + pag + '&num=' + num,

			onRequest: function() { $('pw_div').set('html','<img src="/includes/images/sexyimages/black/loading.gif" width="43" height="11" />');},

	        onSuccess: function(texto, xmlrespuesta){ $('pw_div').set('html',texto);},

        	onFailure: function(){alert('Error!');}

    	}).send(); });

}




