function winInfo(bannerId, bannerName, url) {
  var win = new Window({id: "win1", className: "alphacube", resizable: false, title: '<span id="infoTitle">' + bannerName + '<span>', width:720, height:380});
  win.getContent().innerHTML = '<div id="windowPopUp"><iframe src="/homepage/'+url+'/bannerId/'+bannerId+'" width="720" height="380" scrolling="no" style="border:none;"></ifarme></div>';

  win.setDestroyOnClose();
  win.showCenter();
  //win.setConstraint(true, {left:0, right:0, top: 30, bottom:10} );
  win.toFront();
}

function emailWindow(keywordId, url) {
  var win = new Window({id: "win1", className: "alphacube", resizable: false, title: '<span id="infoTitle">Изпращане на имейл до всички от групата<span>', width:720, height:380});
  win.getContent().innerHTML = '<div id="windowPopUp"><iframe src="/homepage/'+url+'/keywordId/'+keywordId+'" width="720" height="380" scrolling="no" style="border:none!important;"></ifarme></div>';

  win.setDestroyOnClose();
  win.showCenter();
  //win.setConstraint(true, {left:0, right:0, top: 30, bottom:10} );
  win.toFront();
}

function winMap(lat, lng, id) {
  var win = new Window({id: "win4", className: "alphacube", resizable: false, title: "<h3 id='infoTitle'>Карта</h3>", width:720, height:470});
  win.getContent().innerHTML = '<div id="windowPopUp"><iframe src="/homepage/googleDirection/id/'+id+'" width="720px" height="470px"  scrolling="no" style="border:none;"></ifarme></div>';

  win.setDestroyOnClose();
  win.showCenter();
  //win.setConstraint(true, {left:0, right:0, top: 30, bottom:10} )
  win.toFront();
}

function initialize(lat,lng, toAddress) {
	
  if (GBrowserIsCompatible()) {
    map = new GMap2(document.getElementById("map_canvas"),{ size: new GSize(620,520) } );
    
    map.removeMapType(G_HYBRID_MAP);
	//map.setCenter(new GLatLng(42.6976489,23.3221545), 15);
	
	var center = new GLatLng(lat,lng);
	map.setCenter(center, 15);
	
	//postavqne na icona
	//var icon = new GIcon(G_DEFAULT_ICON);
	//icon.image = "/uploads/biona/galery/iconMadalBall.png";
	//var marker = new GMarker(center, {icon: icon});

	//map.addOverlay(marker); 
	
	//za tooltip-a
    var maxContent = "<center><img src='mega_splat.jpg' height='230' width='300'/></center>";
    var maxTitle = "You asked for it!";
    
    //za tooltip-a
    GEvent.addListener(marker, 'click', function() {
      marker.openInfoWindowHtml("<b>Maximize me!</b>",
        {maxContent: maxContent,
         maxTitle: maxTitle});
    });

    //za tooltip-a
    var contentNode = document.createElement('div');
    contentNode.innerHTML = maxContent;
    var titleNode = document.createElement('div');
    titleNode.innerHTML = maxTitle;
		
    //za tooltip-a
    GEvent.addListener(map, 'click', function(overlay, latlng) {
      if (latlng) {
        map.openInfoWindowHtml(latlng, '<b>Maximize me!</b>', {
          maxContent: contentNode,
          maxTitle: titleNode
        });
      }
    });
    
    var mapControl = new GMapTypeControl();
    map.addControl(mapControl);
    map.addControl(new GLargeMapControl());
  }
}

//Autocomplete function
function lookup(inputString, flag) {
  if(inputString.length == 0) {
          // Hide the suggestion box.
          jQuery('#suggestions').hide();
  } else {
    jQuery.post("/homepage/ajaxSearchKeywords",
    {
      queryString: ""+inputString+"",
      flag: ""+flag+""
      }, function(data){
      if(data.length >0) {
        jQuery('#suggestions').show();
        jQuery('#autoSuggestionsList').html(data);
      }
    });
  }
} // lookup

function lookupRegister(inputString) {
	if(inputString.length == 0) {
		// Hide the suggestion box.
		jQuery('#suggestions').hide();
	} else {
		jQuery.post("/homepage/ajaxSearchKeywords", {queryString: ""+inputString+""}, function(data){
			if(data.length >0) {
				jQuery('#suggestions').show();
				jQuery('#autoSuggestionsList').html(data);
			}
		});
	}
} // lookupRegister

//Autocomplete function
function fill(thisValue, flagForPage) {
	if(flagForPage == "search") {
		jQuery('#search').val(thisValue);
	}else {
		jQuery('#newRegister').val(thisValue);
	}
	setTimeout("jQuery('#suggestions').hide();", 200);
} // fill

//Autocomplete function
function fillRegister(thisValue) {
	jQuery('#newRegister').val(thisValue);
	setTimeout("jQuery('#suggestions').hide();", 200);
} // fill

function KeywordUrl(keywordId) {
  location.href = location.href + '/keyword_id/' + keywordId;
}

function registerUpdate(registerId) {
  new Ajax.Updater(
	'registerFlag', 
	'ajaxUpdateRegister', {
      method: 'post',
      parameters: {
        registerId: registerId
	  }
  });
}

function updateClientInfo(clientId) {
	  new Ajax.Updater(
				'cleintInfo', 
				'client/ajaxUpdateClient', {
			      method: 'post',
			      parameters: {
			        clientId: clientId
				  }
			  });	
}

function photoUpdate(photoId) {
	  new Ajax.Updater(
				'photoInfo', 
				'ajaxUpdatePhoto', {
			      method: 'post',
			      parameters: {
			        photoId: photoId
				  }
			  });	
}

function updateClientBanner(bannerId) {
	  new Ajax.Updater(
				'cleintBanners', 
				'ajaxUpdateBanner', {
			      method: 'post',
			      parameters: {
			        bannerId: bannerId
				  }
			  });		
}

function updateClientInfoEdit(companyId) {
	  new Ajax.Updater(
				'cleintInfoEdit', 
				'client/ajaxUpdateClientEdit', {
			      method: 'post',
			      parameters: {
			        companyId: companyId
				  }
			  });		
}
