Course = function(unId, phpPath, siteUrl){
	this.unId = unId;
	if(typeof(siteUrl)!='undefined')
		this.siteUrl = siteUrl;
//	alert(this.siteUrl);
	this.tableId = 'tableCourses'+this.unId;
	this.graphId = 'graphCourses'+this.unId;
	this.flag = true;
	if(typeof(phpPath)!='undefined'){
		this.Ajax = new Ajax();
		this.phpPath = phpPath;
//		alert(this.phpPath);
	}
}

Course.prototype._elementCreate = function( eleType, id, eleClass, eleContent, elePar )
{
	var ele = document.createElement(eleType);
	if(id) ele.id = id;
	if(eleClass) ele.className = eleClass;
	if(eleContent) ele.innerHTML = eleContent;
	if(elePar) elePar.appendChild(ele);
	return ele;
}

Course.prototype.showTable = function(typId, ele){
	if($('#'+this.tableId+typId).css('display') != 'none' || this.flag == false) return;

	$('#'+this.graphId+typId).hide();
	$('#'+this.tableId+typId).show();
	ele.className = 'selected';
	ele.parentNode.lastChild.className = '';
}

Course.prototype.showGraph = function(typId, ele){
	var pointer = this;
	if($('#'+this.graphId+typId).css('display') != 'none') return;

//	$('#curses > .table-graph').css('float','right');

	$('#'+this.tableId+typId).hide();
	this.flag = false;
	$('#'+this.graphId+typId).show(500, function(){pointer.flag = true;});
	ele.className = 'selected';
	ele.parentNode.firstChild.className = '';

}

Course.prototype.paintGraph = function(src, eleId, parId){
	$('#'+eleId).attr('class','selected');
	$('#'+eleId).siblings(".selected").attr('class','');

	$('#'+parId).css('opacity','0.1');
	elePar = document.getElementById(parId);
	if(elePar.childNodes.length == 0)
		eleImg = this._elementCreate('img', null, null, null, elePar);
	else
		eleImg = elePar.firstChild;

//	alert($('#'+parId).children('img').attr('src'));
//	$('#'+parId).children('img').fadeOut(500);
	$('#'+parId).fadeTo(250,1);
//	$('#'+parId).fadeIn(500);
	eleImg.src = src;

//	eleImg.style.width = '100%';
}


Course.prototype.paintGraphFlash = function(curId, idPar, eleId, idStart, idEnd){
	var pointer = this;
	var dateFrom = $('#'+idStart).children('input:hidden').val();
	var dateTo = $('#'+idEnd).children('input:hidden').val();
	var url = pointer.siteUrl+'/tools/courses/xml.php?curId='+curId+'&dateFrom='+dateFrom+'&dateTo='+dateTo;
	pointer.paintFlash(curId, url, idPar);
	$('#'+eleId).attr('class','selected');
	$('#'+eleId).siblings(".selected").attr('class','');
}


Course.prototype.changeDateRange = function(idStart, idEnd){
	var pointer = this;
	var dateFrom = $('#'+idStart).children()[1].value;
	var dateTo = $('#'+idEnd).children()[1].value;

	if(dateFrom>=dateTo){
		$('#dateinfo').show();
		return false;
	}
	else{
		$('#dateinfo').hide();
	}
	for(i=0; i<this.chDatArr.length; i++){
		pointer.paintGraphFlash(chDatArr[i][1], 'typ'+pointer.unId+chDatArr[i][0], 'but'+pointer.unId+chDatArr[i][1], idStart, idEnd);
	}

}


Course.prototype.paintFlash = function(curId, url, idPar){
	url = escape(url);
//	alert(url);
//	alert(this.siteUrl);
	var defValUrl = this.siteUrl+'/tools/courses/defxml.php?curId='+curId;
	// Version check for the Flash Player that has the ability to start Player Product Install (6.0r65)
	var hasProductInstall = DetectFlashVer(6, 0, 65);

	// Version check based upon the values defined in globals
	var hasRequestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);

	if ( hasProductInstall && !hasRequestedVersion ) {
		// DO NOT MODIFY THE FOLLOWING FOUR LINES
		// Location visited after installation is complete if installation is required
		var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn";
		var MMredirectURL = window.location;
	    document.title = document.title.slice(0, 47) + " - Flash Player Installation";
	    var MMdoctitle = document.title;

		AC_FL_RunContent(
			"src", "playerProductInstall",
			"FlashVars", "MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+'&data='+url+'&defval='+defValUrl,
			"width", "578",
			"height", "300",
			"align", "middle",
			"id", "chartinvestadviser",
			"quality", "high",
			"bgcolor", "#ffffff",
			"name", "chartinvestadviser",
			"allowScriptAccess","sameDomain",
			"type", "application/x-shockwave-flash",
			"pluginspage", "http://www.adobe.com/go/getflashplayer",
			"idPar", idPar
		);
	} else if (hasRequestedVersion) {
		// if we've detected an acceptable version
		// embed the Flash Content SWF when all tests are passed
		AC_FL_RunContent(
				"src", this.siteUrl+"/graph/chartinvestadviser",
				"width", "578",
				"height", "300",
				"align", "middle",
				"id", "chartinvestadviser",
				"quality", "high",
				"bgcolor", "#ffffff",
				"name", "chartinvestadviser",
				"flashvars", 'data='+url+'&defval='+defValUrl,
				"allowScriptAccess","sameDomain",
				"type", "application/x-shockwave-flash",
				"pluginspage", "http://www.adobe.com/go/getflashplayer",
				"idPar", idPar
		);
	  } else {  // flash is too old or we can't detect the plugin
	    var alternateContent = 'Alternate HTML content should be placed here. '
	  	+ 'This content requires the Adobe Flash Player. '
	   	+ '<a href=http://www.adobe.com/go/getflash/>Get Flash</a>';
	    document.getElementById(idPar).innerHTML = alternateContent;  // insert non-flash content
	  }
}


