var DragHandler = {


    // private property.
    _oElem : null,


    // public method. Attach drag handler to an element.
    attach : function(oElem) {
        oElem.onmousedown = DragHandler._dragBegin;

        // callbacks
        oElem.dragBegin = new Function();
        oElem.drag = new Function();
        oElem.dragEnd = new Function();

        return oElem;
    },


    // private method. Begin drag process.
    _dragBegin : function(e) {
        var oElem = DragHandler._oElem = this;

        if (isNaN(parseInt(oElem.style.left))) { oElem.style.left = '450px'; }
        if (isNaN(parseInt(oElem.style.top))) { oElem.style.top = '489px'; }

        var x = parseInt(oElem.style.left);
        var y = parseInt(oElem.style.top);

        e = e ? e : window.event;
        oElem.mouseX = e.clientX;
        oElem.mouseY = e.clientY;

        oElem.dragBegin(oElem, x, y);

        document.onmousemove = DragHandler._drag;
        document.onmouseup = DragHandler._dragEnd;
        return false;
    },


    // private method. Drag (move) element.
    _drag : function(e) {
        var oElem = DragHandler._oElem;

        var x = parseInt(oElem.style.left);
        var y = parseInt(oElem.style.top);

        e = e ? e : window.event;
        oElem.style.left = x + (e.clientX - oElem.mouseX) + 'px';
        oElem.style.top = y + (e.clientY - oElem.mouseY) + 'px';

        oElem.mouseX = e.clientX;
        oElem.mouseY = e.clientY;

        oElem.drag(oElem, x, y);

        return false;
    },


    // private method. Stop drag process.
    _dragEnd : function() {
        var oElem = DragHandler._oElem;

        var x = parseInt(oElem.style.left);
        var y = parseInt(oElem.style.top);

        oElem.dragEnd(oElem, x, y);

        document.onmousemove = null;
        document.onmouseup = null;
        DragHandler._oElem = null;
    }

}
///---fin drag and drop




function vIE(){
return (navigator.appName=='Microsoft Internet Explorer')?parseFloat((new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})")).exec(navigator.userAgent)[1]):-1;}




function mueveMyGmap(p1,p2){
	var capa=document.getElementById('viewMyGmap').style;
	var VAL;
	
		VAL=parseInt(p2-0)+'px';
		
		capa.top=VAL;

                $(window).scrollTo( { top: parseInt(p2-100), left:700}, 800 );
}

/**
 * jQuery.ScrollTo - Easy element scrolling using jQuery.
 * Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under MIT and GPL.
 * Date: 5/25/2009
 * @author Ariel Flesler
 * @version 1.4.2
 *
 * http://flesler.blogspot.com/2007/10/jqueryscrollto.html
 */
;(function(d){var k=d.scrollTo=function(a,i,e){d(window).scrollTo(a,i,e)};k.defaults={axis:'xy',duration:parseFloat(d.fn.jquery)>=1.3?0:1};k.window=function(a){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!i)return a;var e=(a.contentWindow||a).document||a.ownerDocument||a;return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement})};d.fn.scrollTo=function(n,j,b){if(typeof j=='object'){b=j;j=0}if(typeof b=='function')b={onAfter:b};if(n=='max')n=9e9;b=d.extend({},k.defaults,b);j=j||b.speed||b.duration;b.queue=b.queue&&b.axis.length>1;if(b.queue)j/=2;b.offset=p(b.offset);b.over=p(b.over);return this._scrollable().each(function(){var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');switch(typeof f){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){f=p(f);break}f=d(f,this);case'object':if(f.is||f.style)s=(f=d(f)).offset()}d.each(b.axis.split(''),function(a,i){var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);if(s){g[c]=s[h]+(u?0:l-r.offset()[h]);if(b.margin){g[c]-=parseInt(f.css('margin'+e))||0;g[c]-=parseInt(f.css('border'+e+'Width'))||0}g[c]+=b.offset[h]||0;if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]}else{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);if(!a&&b.queue){if(l!=g[c])t(b.onAfterFirst);delete g[c]}});t(b.onAfter);function t(a){r.animate(g,j,b.easing,a&&function(){a.call(this,n,b)})}}).end()};k.max=function(a,i){var e=i=='x'?'Width':'Height',h='scroll'+e;if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;return Math.max(l[h],m[h])-Math.min(l[c],m[c])};function p(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);

function limpiarWmap(){
	document.getElementById('viewMyGmap').style.visibility='hidden'; 
}

function viewGmap(e,myAlo,this_array){
	var capa=document.getElementById('viewMyGmap').style;
	
			if (!e) var e = window.event;
			if (e.pageY)
			{
				posy = e.pageY;
			}
			else if (e.clientY)
			{
			
			if(vIE()==6)
			{
			posy = e.clientY+document.documentElement.scrollTop;//document.body.scrollTop;
			}
			else if(vIE()>=7)
			posy = e.clientY+document.documentElement.scrollTop;
					
			}
			
			
	cap_1=capa.top;
	cap_2=posy;
	capa.visibility='visible'; 
	mueveMyGmap(cap_1,cap_2);
	
	load_my_gmap(this_array);
	
	var viewMyGmap = DragHandler.attach(document.getElementById('viewMyGmap'));
}





/*

function load_my_gmap(DM) {


LAT=DM[0];
LNG=DM[1];
NOM=DM[2];
IMG=DM[3];
PRE=DM[4];
COMO_LLEGAR=DM[5];
ID_ALOJAMIENTO = DM[6];

PRE = document.getElementById('precioAlojamiento_'+ID_ALOJAMIENTO).innerHTML;

if(navigator.userAgent.match(/safari/i)){
	overflow="";
}else{
	overflow="style='max-height:52px;overflow-y:auto;overflow-x:visible;'";
}

	
var WINDOW_HTML = ''; 

	WINDOW_HTML ="<table width='370'><tr><td valign='middle'><div> <img src='"+IMG+"' width='90' height='70'  align='top' style='border:1px solid SteelBlue;'/> </div></td><td style='padding-left:3px' valign='top'><div style='font-size:11px;font-weight:bold;line-height:100%;line-width:100%;text-align:left;padding-bottom:0px;'>"+NOM+"</div><div style='font-size:10px;margin-top:5px;padding-bottom:2px;text-transform:capitalize;'><x>price from</x>: <span style='font-weight: bold;font-size:10px;'>"+PRE+"</span></div><div style='font-size:9px;'>"+COMO_LLEGAR+"</div><table width='205' border='0' cellspacing='0' cellpadding='0'><tr><td><a href='javascript:ewindow.hide()'><img id='ewindow_close' width='14' height='13' src='/images/eclose.gif' border='0'></a></td></tr></table>";
    

	
	
  if (GBrowserIsCompatible()) {
  
    var map = new GMap2(document.getElementById("mapita"));
	ewindow = new EWindow(map, E_STYLE_1);
	map.addControl(new GLargeMapControl());
	map.addControl(new GMapTypeControl());
	map.setCenter (new GLatLng(LAT, LNG), 11);
	map.setZoom(15);

	var icon1 				= new GIcon();
    icon1.image 			= "/imagenes/tema1/marker.png";
    icon1.iconSize 			= new GSize(20, 34);
    icon1.iconAnchor 		= new GPoint(6, 20);
    icon1.infoWindowAnchor 	= new GPoint(5, 11);
	
	var marker = new GMarker(new GLatLng(LAT, LNG), icon1);

	map.addOverlay(ewindow);
	map.addOverlay(marker);
	
	if( WINDOW_HTML != '' ){
		GEvent.addListener(marker, "click", function() {
		  ewindow.openOnMarker(marker, WINDOW_HTML); 
		});
		ewindow.openOnMarker(marker, WINDOW_HTML);
	}



        function createMarkerTitLug(point, title, ii) {

            var markerr = new GMarker(point, { draggable: false, icon:ii });
            GEvent.addListener(markerr, "click", function() {
              markerr.openInfoWindowHtml(title);
            });
            return markerr;
        }


          h_icon1 = new GIcon();

        h_icon1.iconSize = new GSize(20, 34);

        h_icon1.iconAnchor = new GPoint(6, 20);

        h_icon1.infoWindowAnchor = new GPoint(4, 11);


        { foreach item=mapaLanding from=$mapa_lugares_interes }


            h_icon1.image = "{$mapaLanding.iconoCategoria}";

            map.addOverlay(createMarkerTitLug( new GLatLng({$mapaLanding.latitud}, {$mapaLanding.longitud}) , "{$mapaLanding.titulo}",h_icon1));
        {/foreach }


// ========== Close the EWindow if theres a map click ==========
      GEvent.addListener(map, "click", function(marker,point) {
        if (point) {
          //ewindow.hide();
        }
      });

  }
}*/



