function DCTRedirect(url)
{
	window.location=url;
}

function DCTReload()
{
	location.reload(true);
}

function callURL(href,method, data, onsucess)
{
	$.ajax
	(
			{
				url: href,
				type: method,
				data: data,
				dataType: "html",
				success: onsucess
			}
	);
	
}

function DCTLoadPopUp(href,popupid)
{
	$.ajax
	(
			{
				url: href,
				type: "GET",
				dataType: "html",
				success: function (data)
						{
							DCTLoadPopUpData(data,popupid);
						},
			}
	);
	
}

function DCTLoadPopUpData(data,popupid)
{
	
	
	if (popupid == undefined || popupid == null)
	{
		popupid="1";
	}
	
	dstdiv = 'topopup'+popupid;
	dstpopup = 'popup'+popupid;
	
	$('#'+dstdiv).html(data);
	DCTInitpopup(dstpopup);	
}

function DCTLoadPopUpData1(data)
{
	DCTLoadPopUpData(data,1);
}

function DCTInitpopup(id)
{
	//Get the screen height and width
	var maskHeight = $(document).height();
	var maskWidth = $(document).width();
	
	//Set heigth and width to mask to fill up the whole screen
	$('#mask').css({'width':maskWidth,'height':maskHeight});
	
	//transition effect		
	$('#mask').fadeIn(500);	
	$('#mask').fadeTo("slow",0.7);	
	

	//Get the window height and width
	var winH = $(window).height();
	var winW = $(window).width();

	
	var popup = document.getElementById(id);
	
	//Set the popup window to center
	$(popup).css('top',  winH/2-$(popup).height()/2);
	$(popup).css('left', winW/2-$(popup).width()/2);
	
	//transition effect
	$(popup).fadeIn(500); 
}

function DCTClosepopup(popupid)
{
	if (popupid == undefined || popupid == null)
	{
		popupid="1";
	}
	
	dstpopup = 'popup'+popupid;

	if (popupid == 1)
	{
		$('#mask').hide();	
	}
	
	$('#'+dstpopup).hide();

}

function DCTSubmitFormIdAjax(formid, action, onsuccess)
{
	var eform = document.getElementById(formid);
	
	
	DCTSubmitFormAjax(eform, action, onsuccess);
}

/** Submit Form Con Ajax **/
function DCTSubmitFormAjax(form, action, onsuccess)
{
	if (action != undefined && action != null)
	{
		form.action=action;	
	}
	
	
	var data = $(form).serialize();
	callURL(form.action,'POST', data, onsuccess);
	/*
	var options = 
	{ 
	        success: onsuccess,
					
		    			
	    	error: function (httpObj, textStatus) 
	    			{
						document.open();
						document.write(httpObj.responseText);
						document.close();
	    			},
			type: "POST",
			
	    	beforeSend: showWait,
			
			complete: hideWait
    };

    $(form).ajaxSubmit(options);
    */
}

/************************ WAIT *******************/
function showWait()
{
	
	if ( document.getElementById('wait') === undefined)
	{
		return;
	}
	
	//Get the window height and width
	var winH = $(window).height();
	var winW = $(window).width();

	//Set the popup window to center
	$('#wait').css('top',  winH/2-$('#wait').height()/2);
	$('#wait').css('left', winW/2-$('#wait').width()/2);
	
	$('#wait').show();
	
}

function hideWait()
{
	if ( document.getElementById('wait') === undefined)
	{
		return;
	}
	
	$('#wait').hide();
}

//Facebook Javascript SDK
(!function(d, s, id) 
	{
		var js, fjs = d.getElementsByTagName(s)[0];
		if (d.getElementById(id)) {return;}
		js = d.createElement(s); js.id = id;
		js.src = "//connect.facebook.net/es_ES/all.js#xfbml=1";
		fjs.parentNode.insertBefore(js, fjs);
	}
	(document, 'script', 'facebook-jssdk')
);

(!function(d,s,id)
	{
		var js,fjs = d.getElementsByTagName(s)[0];
		if(!d.getElementById(id))
		{
			js=d.createElement(s);
			js.id=id;js.src="//platform.twitter.com/widgets.js";
			fjs.parentNode.insertBefore(js,fjs);
		}
	}(document,"script","twitter-wjs")
);

(function() {
    var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
    po.src = 'https://apis.google.com/js/plusone.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
 })();


