/**
 * @projectname     Cazare Turistica
 * @version         1.0 2010.04.01
 * @copyright       Copyright (C) 2008 - 2010 All rights reserved.
 * @license         Commercial
 * @author          Székely Csaba / csaba@szekely.ro / http://www.csaba.szekely.ro
 *
 *
 * @desc            Script for country map functions
 */


 var current_area = 0;

// on document ready runing page
jQuery(document).ready(function(){
    // init map hilighting
    loadMapHilight();
    // handling click for countys
    $('area').click(function(e){
        // clearing last clicked area
        jQuery('#'+ current_area ).data('maphilight', {}).trigger('alwaysOn.maphilight');
        // setting current clicked
        current_area=$(this).attr('id');
        // preventing default action
        e.preventDefault();
        // setting data variable
        var data = $(this).data('maphilight') || {};
        data.alwaysOn = !data.alwaysOn;
        // assigining value
        $(this).data('maphilight', data).trigger('alwaysOn.maphilight');
        // displaying cocations
        showLocUnits(jQuery(this).attr('id'));
    }); // end on click
}); // end on ready



/**
* Reloading map hilight
* @access public
* @param none
* @return none
*/

function loadMapHilight(){
    // loading image map plugin
    jQuery('#harta_romaniei').maphilight({
        fill: true,
        fillColor: '0173B1',
        fillOpacity: 0.3,
        stroke: true,
        strokeColor: 'E39E37',
        strokeOpacity: 1,
        strokeWidth: 3,
        fade: false,
        alwaysOn: false
    });
}; // end function map hilight



/**
* The county click handling function
* @access public
* @param conty_id
* @return none
*/

function showLocUnits(cty_id){
    // displaying loding icon
    jQuery('.ct_map_bottm_unit').html(jQuery('.ajax_small_loading_img_container').html());
	// if slidebar hidden then show
	if(jQuery('.ct_map_bottm_unit').is(":hidden")) {
		// display slide
		jQuery('.ct_map_bottm_unit').slideDown(200);
	}  // end if hidden show slidebar.

    // loading locations for county
    jQuery('.ct_map_bottm_unit').load('./modules/countryMap/country_map_hendler.php?action=loadLoc&countyid=' + cty_id);// end load
}; // end function show loc units from map




/**
* The county click handling function
* @access public
* @param conty_id
* @return none
*/

function closeUnit(){
    // hidding unit
    jQuery('.ct_map_bottm_unit').slideUp(200);
    // resetting map
    jQuery('#'+ current_area ).data('maphilight', {}).trigger('alwaysOn.maphilight');
}; // end function show loc units from map






