
/*
//
//+-----------------------------------------------------------------+
//|                 RadCLASSIFIEDS GOLD v2 ADMIN                    |
//|                       (November 2007)                           |
//|                Copyright © 2007 RadScripts.com                  |
//|                                                                 |
//| File Name:       script.js                                      |
//| Project Manager:  Ed Pakstas                                    |
//| Email:            support@radscripts.com                        |
//| Website:          http://www.RadScripts.com                     |
//|                                                                 |
//| Note: Any alteration of PHP code in this file will void any     |
//|	     support services which RadScripts.com may provide.     |
//| Note: This script is NOT Freeware and IS NOT Open Source Code!  |
//|       All terms, conditions and copyrights as defined in the    |
//|	RadScripts License Agreement WHICH YOU AGREED TO COMPLY WITH|
//|	when you purchased this software must be adhered to and will|
//|	be strictly enforced.                                       |
//+-----------------------------------------------------------------+
//
*/

function gotocluster(s){
	var d = s.options[s.selectedIndex].value
	if(d){
		top.location.href = d
	}
	s.selectedIndex=0
}

function my_submit_form() {
	obj = eval("document.form1.expbox");
	ki = 0;
	if (obj){
		var iNumItems = obj.length;
		// create product order
		for (i = 0; i < iNumItems; i++ ){
			if( obj.options[i].selected ){
				if (ki == 1){
					document.form1.myExp.value += ':' + obj.options[i].value;
				}else{
					document.form1.myExp.value = obj.options[i].value;
					ki = 1;
				}
			}
		}
	}
}



function bookmarksite(title, url){
if (document.all)
window.external.AddFavorite(url, title);
else if (window.sidebar)
window.sidebar.addPanel(title, url, "")
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function populate(selected,mychoice) {
	document.form1.elements['state'].selectedIndex = 0;
	var nochoice = 1;
	if ( eval(selected+"_array") ){
		var selectedArray = eval(selected+"_array");
		while (selectedArray.length < document.form1.elements['state'].options.length) {
			document.form1.elements['state'].options[(document.form1.elements['state'].options.length - 1)] = null;
		}
		eval("document.form1.elements['state'].options[0]=" + "new Option('--')");
		document.form1.elements['state'].options[0].value="0";
		for (var i=1; i < selectedArray.length; i++) {
			var id = selectedArray[i].substring(0,selectedArray[i].indexOf(":"));
			var val = selectedArray[i].substring(selectedArray[i].indexOf(":")+1, selectedArray[i].length);
			document.form1.elements['state'].options[i]=new Option(val);
			document.form1.elements['state'].options[i].value=id;
			if (id == mychoice){
				document.form1.elements['state'].selectedIndex = i;
				nochoice = 0;
			}
		}
	}else{
		document.form1.elements['state'].options[(document.form1.elements['state'].options.length - 1)] = null;
		eval("document.form1.elements['state'].options[0]=" + "new Option('--')");
		document.form1.elements['state'].options[0].value="0";
	}
	if (nochoice){
		document.form1.elements['state'].selectedIndex = 0;
	}
}



var map;
var directionsPanel;
var directions;

function initialize(address, dispmapinfowin) {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map_canvas"));

        var geocoder = new GClientGeocoder();

        geocoder.getLatLng(
            address,
            function(point) {
                if (!point) {
                    alert(address + " not found");
                } else {
		map.setCenter(point, 15);
		map.addControl(new GMapTypeControl());
		map.addControl(new GLargeMapControl());
                      var marker = new GMarker(point);
		map.addOverlay(marker);

                     if(dispmapinfowin){
		  marker.openInfoWindowHtml("<div style=\'background:white;\'><b>Address:</b><br/> "+address+"</div>");
                    }

            	  GEvent.addListener(marker, "click", function() {
            		    marker.openInfoWindowHtml("<b>Address:</b> "+address);
            	  });

               }
            }
        );
    }
}

function showdirection(from,address) {
      if (GBrowserIsCompatible()) {

        if(!map) return false;

        if(directions) directions.clear();

        directionsPanel = document.getElementById("route");
        directionsPanel.innerHTML="";
        directions = new GDirections(map, directionsPanel);
        directions.load(from+" to "+address);

    }
}


function ajax_get_calendar(cid,listingid,time,forupdate,can_change_month){

    $.get(
        'ajax.php',
        { action: "DispMonth",
           listingid: listingid,
           time: time,
           forupdate: forupdate,
           calid: cid,
           chgmon: can_change_month
        },
        function(data){
            $('div#'+cid).html(data);
        }
    );

    return false;
}

function ajax_update_calendar(cid,listingid,starttime,endtime,status,can_change_month,display_time){

    $.get(
        'ajax.php',
        { action: "ChgDateStatus",
           listingid: listingid,
           starttime: starttime,
           endtime: endtime,
           status: status,
           calid: cid,
           chgmon:can_change_month,
           display_time: display_time
        },
        function(data){
            $('div#'+cid).html(data);
        }
    );

    return false;
}
