";
if(type<3)fstr += "

";
if(atype=="mysub"){
if(subflag){
fstr += "
"+item.name+"";
}else{
fstr += "
"+item.name+"";
}
}
fstr += "
";
fstr += "
";
});
$j(root).parent().find("div").html("").removeClass("loader");
$j(root).parent().find("div").append(fstr);
$j(root).parent().find("div a").bind("click",getData).bind("click",setCheck);
$j(root).parent().find("div img").bind("click",getData);
},"jsonp");
}else{
$j(root).parent().find("div:first").toggle();
}
}
}
var arr = new Array;
var continent = "";
var territory = "";
var region = "";
var place = "";
function getPolygon(proot,clicktype){
var narr = new Array;
var typarr = new Array;
var val = 0;
var subtype = "";
var type;
var count;
continent = "";
territory = "";
region = "";
place = "";
type = $j(proot).parent().find("a").attr("type");
subtype = "mysub";
val = $j(proot).parent().find("a").attr("value");
count = $j(proot).parent().find("a").attr("count");
if(clicktype=="click"){
if(jQuery.inArray($j(proot).parent().find("a").attr("value"), arr)=="-1"){
narr.push($j(proot).parent().find("a").attr("value"));
typarr.push($j(proot).parent().find("a").attr("type"));
arr.push($j(proot).parent().find("a").attr("value"));
}
}
if(narr.length){
addPolygon(clicktype,val,typarr,narr);
}else{
createPolygons(clicktype,val);
}
}
function addPolygon(clicktype,val,typarr,narr){
$j.get("http://www.sitesee.com/getAddPolygon.php",{"type[]":typarr,"id[]":narr},
function(data){
$j.each(data, function(i,item){
createBoundary("mysub",data[i]['type'],data[i]['did'],data[i]['id'],data[i]["name"],data[i]["data"],data[i]["parent"],data[i]["lng"],continent,territory,region,place,0,data[i]["lat"]);
});
createPolygons(clicktype,val);
},"jsonp");
}
function addDragableMarker(dpoint){
if(_mouse_marker)map.removeOverlay(_mouse_marker);
/*var p_obj = pobj[org1];
var dpoint = p_obj.getPolygonCenter();*/
_mouse_marker=new GMarker(dpoint,{icon:icons,draggable:true});
map.addOverlay(_mouse_marker);
addDragable();
setLatLng(_mouse_marker);
//if(currentType<=2)addDragable();
//else addCityDragable();
}
function addDragable(){
GEvent.addListener(_mouse_marker, "dragstart", function() {
currentPt=_mouse_marker.getPoint();
});
GEvent.addListener(_mouse_marker, "dragend", function() {
if (!inPoly(points,_mouse_marker.getPoint()))
{
_mouse_marker.setPoint(currentPt);
_mouse_marker.setImage("widget/images/man.png");
} else
{
var pixel=map.fromLatLngToDivPixel(_mouse_marker.getPoint());
//set latitue and longitude
setLatLng(_mouse_marker);
var x=pixel.x+6;
var y=pixel.y+6;
if (x > map.getSize().width - 120) { x = map.getSize().width - 120 }
if (y > map.getSize().height - 10) { y = map.getSize().height - 10 }
var pos = new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(x,y));
//pos.apply(mcontext);
}
});
GEvent.addListener(_mouse_marker, "drag", function() {
if (inPoly(points,_mouse_marker.getPoint()))
{
_mouse_marker.setImage("widget/images/man.png");
//mcontext.style.visibility="hidden";
} else
{
_mouse_marker.setImage("widget/images/caution.png");
var pixel=map.fromLatLngToDivPixel(_mouse_marker.getPoint());
var x=pixel.x+6;
var y=pixel.y+6;
if (x > map.getSize().width - 120) { x = map.getSize().width - 120 }
if (y > map.getSize().height - 10) { y = map.getSize().height - 10 }
var pos = new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(x,y));
//pos.apply(mcontext);
}
});
}
function addCityDragable(){
GEvent.addListener(_mouse_marker, "dragstart", function() {
currentPt=_mouse_marker.getPoint();
});
GEvent.addListener(_mouse_marker, "dragend", function() {
var pixel=map.fromLatLngToDivPixel(_mouse_marker.getPoint());
//set latitue and longitude
setLatLng(_mouse_marker);
var x=pixel.x+6;
var y=pixel.y+6;
if (x > map.getSize().width - 120) { x = map.getSize().width - 120 }
if (y > map.getSize().height - 10) { y = map.getSize().height - 10 }
var pos = new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(x,y));
//pos.apply(mcontext);
});
GEvent.addListener(_mouse_marker, "drag", function() {
_mouse_marker.setImage("widget/images/man.png");
//mcontext.style.visibility="hidden";
});
}
function inPoly(poly,pt){
var npoints = poly.length-1;
var xnew,ynew,xold,yold,x1,y1,x2,y2,i;
var inside=false;
if (npoints < 3) {
return false;
}
xold=poly[npoints-1].x; yold=poly[npoints-1].y;
for (i=0 ; i < npoints ; i++) {
xnew=poly[i].x; ynew=poly[i].y;
if (xnew > xold) {
x1=xold; x2=xnew; y1=yold; y2=ynew;
}else{
x1=xnew; x2=xold; y1=ynew; y2=yold;
}
if ((xnew < pt.x) == (pt.x <= xold) && ((pt.y-y1)*(x2-x1) < (y2-y1)*(pt.x-x1))) {
inside=!inside;
}
xold=xnew; yold=ynew;
};
return inside;
}
function setLatLng(marker){
document.getElementById("lat").value=_mouse_marker.getPoint().lat();
document.getElementById("lng").value=_mouse_marker.getPoint().lng();
}
/**
* Array convenience method to clear membership.
*
* @param object element
* @returns void
*/
Array.prototype.clear = function () {
this.length = 0;
};