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

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];}}
}

/* ajax */

function load_ad(adid){
    //alert(adid);
    $.get(
        'ajax.php',
        { action: "LoadAdContent",
           id:adid
        },
        function(data){
            //alert(data);
            $('div#'+adid).html(data);
            //$('div#'+adid).css('width','100%');
            //$('div#'+adid).css('height','100%');
            $("div#"+adid).bind("click", function(e){
                click_ad(adid);
                // add click event
                //$("div#"+adid).text("Click "+data+" happened! ");
            });

        }
    );
}

function click_ad(adid){

    //alert(adid);
    $.get(
        'ajax.php',
        { action: "ClickAd",
           id:adid
        },
        function(data){
            window.open(data,"new");
            //window.location.href=data;
        }
    );

}

function getAdPlanDetail(bnid){
    var bpid=$('select#planlist'+bnid).val();
    $.get(
        'ajax.php',
        { action: "GetAdPlanDetail",
           bpid:bpid
        },
        function(data){
            $('div#plandetail'+bnid).html(data);
        }
    );

}

function addBannerPlan(bnid,bpid){
    //var bpid=$('span#planlist'+bnid).html();
    $.get(
        'ajax.php',
        { action: "AddBannerPlan",
           bpid:bpid,
           bnid:bnid
        },
        function(data){
            var result=data.substr(0,1);
            var str=data.substring(2);
            if(result=='1'){
                $('div#addplanresult'+bnid).html('new plan added');
                $('span#showclickcount'+bnid).html(str);
            }else if(str){
                $('div#addplanresult'+bnid).html(data);
            }else{
                $('div#addplanresult'+bnid).html('process failed, please try again');
            }
            $('div#addplanresult'+bnid).fadeIn(1000);
            $('div#addplanresult'+bnid).fadeOut(6000);
        }
    );
}

