// must use with jquery!

function AdvShowRate(){
	this.advPosMap = new Array();
}

AdvShowRate.prototype.addAdv = function(advId, posId){

	var list = this.advPosMap[posId];
	if (list == null){
		list = new Array();
		this.advPosMap[posId] = list;
	}
	
	var length = list.length;
	
	if (advId.indexOf("?") != -1){
		var temp = advId.split("?");
		if (temp[0] == "advbanner.php"){
			var aiStr = temp[1];
			list[length] = aiStr.split("=")[1];
		}
	} else 
		list[length] = advId;

}

AdvShowRate.prototype.toString = function(){
	var str = "";

	//for(var i=0;i<this.advPosMap.length;i++){
	//	document.write("<b>this.advPosMap["+i+"] is </b>=>"+this.advPosMap[i]+"<br>");
	//}

	for (var word in this.advPosMap){
		
		if(!isNaN(word)){
			var list = this.advPosMap[word];
			var posStr = word + "=" + list + ";";
			str += posStr;
		}
	}
	
	return str;
}

AdvShowRate.prototype.submit = function(location) {
	if (location == null)
		location = "/adv_show_rate.php";
	
	var connector = new Connector();
	var params = {"data": this.toString()};
	connector.submit(location, params);
}

var advShowRate = new AdvShowRate();