$(function(){
	/* Every Pages Start*/
	/*	Logo Set up - If you want to change Logo image 
		or someting about Logo section you can change here ^^
	*/
	$("#logo") //insert into logo image tag
		.html("<img id='logo_img' src='../images/logo.png' alt='King George International College Logo' />");
	$("#logo") //logo image click event go to main page
		.click(function(){
			location.href="../index.html";
		});

	/* add for moving menus tag*/
	/*$("#main") 
		.append("<div id='commonMenu'></div>");

	$("#commonMenu")
		.css("position","absolute");
	$("#commonMenu")
		.append("<div id='imgStartDate'><img id='simg' src='../images/startdate2.jpg' alt='KGIBC Start Dates' /></div><div id='subStartDate'></div>");
	$("#commonMenu")
		.append("<div class='Space'></div>");
	
	//$("#commonMenu")
	//	.append("<div id='imgGallery'><img src='../images/gallery2.jpg' alt='KGIBC Gallery' /></div><div id='subGallery'></div>");
	
	//$("#commonMenu")
	//	.append("<div id='imgSpeech'><img src='../images/Speech-Contest-Button.gif' alt='go to speech contest website'/></div>");

	new Floating(document.getElementById("commonMenu"),0,350,0,10); //call floating
	
	$(".Space")
		.css({
			"clear":"both",
			"height":"20px"
		});
	
	$("#simg").hover( //moving start dates menu image rollover
		function(){ 
			$("img[id='simg']")
				.attr({
					"src":"../images/startdate2_over.jpg",
					"alt":"KGIBC Start Dates"
				}); 
		},
		function(){ 
			$("img[id='simg']")
				.attr({
					"src":"../images/startdate2.jpg",
					"alt":"KGIBC Gallery"
				}); 	
		}
	);
	
	
	$("#imgStartDate")
		.css({
			"float":"left",
			"cursor":"pointer"
		});
	$("#subStartDate")
		.css({
			"float":"left",
			"width":"615px",
			"height":"80px"
		});
	
	var sdate = "Start dates for 2010 is now available.";
	sdate += " Please select from the options available to narrow your search";
	
	var sdateSelect = "";
	sdateSelect += "	<select name='campus'>";
	sdateSelect += "		<option value='CAMPUS'>CAMPUS</option>";	
	sdateSelect += "		<option value='VR'>Vancouver</option>";
	sdateSelect += "		<option value='TO'>Toronto</option>";
	sdateSelect += "		<option value='VA'>Victoria</option>";
	sdateSelect += "	</select><br/>";

	sdateSelect += "	<select name='course'>";
	sdateSelect += "		<option value='0'>COURSE</option>";	
	sdateSelect += "	</select><br/>";

	sdateSelect += "	<select name='year'>";
	sdateSelect += "		<option value='0'>YEAR</option>";	
	sdateSelect += "	</select><br/>";

	var eachCourseN = new Array();
	var eachCourseVA = new Array();
	var eachCourseTO = new Array();
	var eachCourseVI = new Array();

	eachCourseN[0] = "COURSE";

	eachCourseVA[0] = "BMDP";
	eachCourseVA[1] = "HMDP";
	eachCourseVA[2] = "IOMDP";
	eachCourseVA[3] = "ITDP";
	eachCourseVA[4] = "EPIT";
	eachCourseVA[5] = "PMM";
	eachCourseVA[6] = "TOEIC";
	eachCourseVA[7] = "TOEFL iBT";
	eachCourseVA[8] = "FCE";
	eachCourseVA[9] = "ABMDP";
	eachCourseVA[10] = "AHMDP";
	eachCourseVA[11] = "TESOL";
	eachCourseVA[12] = "TESOL-M";
	eachCourseVA[13] = "TESOL-C";
	eachCourseVA[14] = "TESOL-A";

	var eachCourseTO = new Array();
	eachCourseTO[0] = "BMDP";
	eachCourseTO[1] = "ITDP";
	eachCourseTO[2] = "PMM";
	eachCourseTO[3] = "IELTS";
	eachCourseTO[4] = "TOEFL";
	eachCourseTO[5] = "TESOL-A";
	eachCourseTO[6] = "TESOL-C";

	var eachCourseVI = new Array();
	eachCourseVI[0] = "PMM";
	eachCourseVI[1] = "TESOL";
	eachCourseVI[2] = "TESOL-I";

	$("#subStartDate").append("<div id='subTitleStartDate'>"+sdate+"</div>");
	$("#subStartDate").append("<div class='startdateSpace'></div>");	
	$("#subStartDate").append("<div id='subSelectStartDate'>"+sdateSelect+"</div>");
	$("#subStartDate").append("<div class='startdateSpace'></div>");	
	$("#subStartDate").append("<div id='submitStartDate'><img src='../images/search_btn.png' align='absmiddle' height='80'></div>");
	
	$("select[name='campus']")
		.change(function () {
			$("select[name='campus'] option:selected")
				.each(function() {
					var eachText;
					switch($(this).text())
					{
						case "CAMPUS":
							eachText = eachCourseN;
							break;
						case "Vancouver":
							eachText = eachCourseVA;
							break;
						case "Toronto":
							eachText = eachCourseTO;
							break;
						case "Victoria":
							eachText = eachCourseVI;
							break;
					}

					var courseSelect = $("select[name='course']");
					var optStr = "";
					for (var c = 0; c < eachText.length ; c++ )
					{
						optStr += "<option>"+eachText[c]+"</option>";
					}
					
					courseSelect.empty();
					courseSelect.append(optStr);
				});
	
		
		});
		
	
	
	var startYear = 2010;
	var endYear = 2010;
	var yearSelect = "";
	for (var i = startYear; i < endYear + 1 ;i++ )
	{
		yearSelect += "<option>"+i+"</option>";
	}
	$("select[name='year']").append(yearSelect);

	var subStartDateBgc = "#bdc9d7";
	var subStartDateH = "72px";

	$("#commonMenu")
		.css({
			"font-size":"12px",
			"color":"black"
		});
	$("#subStartDate select")
		.css({
			"width":"150px",
			"background-color":"#f1f4f7"
		});
	$("#subStartDate div")
		.css({
			"padding":"4px",
			"background-image":"url(../images/start_bg.png)"
		});
	$("#subTitleStartDate")
		.css({
			"font-style":"italic",
			"padding-left":"15px",
			"padding-top":"14px",
			"font-family":"Times New Roman",
			"float":"left",
			"height":"62px",
			"width":"300px",
			"background-color":subStartDateBgc,
			"text-align":"left",
			"font-size":"14px"
		});
	$(".startdateSpace")
		.css({
			"float":"left",
			"height":subStartDateH
		});
	$("#subSelectStartDate")
		.css({
			"float":"left",
			"height":subStartDateH,
			"width":"150px",
			"background-color":subStartDateBgc
		});
	$("#submitStartDate")
		.css({
			"float":"left",
			"width":"80px",
			"cursor":"pointer",
			"padding":"0px"
		});
	
	$("#submitStartDate")
		.click(function(){
			location.href = "../admissions/startdate.asp?Campus="+$("select[name='campus'] option:selected").val()+"&Course="+$("select[name='course'] option:selected").text()+"&Year="+$("select[name='year'] option:selected").text();
			$("#subStartDate")
				.toggle("slide",{},200);
		});
	
	
	$("#imgGallery")
		.css({
			"clear":"both",
			"float":"left"
		});
	$("#subGallery")
		.css({
			"float":"left",
			"background-color":"white",
			"width":"400px",
			"height":"66px"
		});
	
	$("#subStartDate").hide();
	$("#subGallery").hide();

	$("#imgStartDate")
		.bind("click", function(){
			$("#subStartDate")
				.toggle("slide",{},400);
		});
	$("#imgGallery")
		.click(function(){ 
			alert("Sorry, link under construction.");
		});

	$("#speech-contest-popup").click(function(){ location.href="./popup/speech-contest/";});
	/*	
		$("#imgGallery").bind("click", function(){
		$("#subGallery").toggle("slide",{},400);});
	*/

	$(".faq_more_line")
		.html("<img src='../images/co-op_more.png' alt='More' />");

	$("#text_box")
		.after("<div id='divgotop_s'><img id='gotop' src='../images/to_top.png' alt='go Top' /></div>")
	$("#enterance")
		.after("<div id='divgotop_f'><img id='gotop' src='../images/to_top.png' alt='go Top' /></div>")
	$("#fee")
		.after("<div id='divgotop_f'><img id='gotop' src='../images/to_top.png' alt='go Top' /></div>")
	$("#divgotop_s").css(
		{
			"margin-top":"20px",
			"cursor":"pointer",
			"margin-right":"2px",
			"text-align":"right"
		});
	$("#divgotop_f").css(
		{
			"margin-top":"20px",
			"cursor":"pointer",
			"margin-right":"30px",
			"text-align":"right"
		});
	
	$("#gotop").click(function(){
		location.href='#'; //to top image click event
	});



	$("#ex_menu") //insert sitemap & contact
		.html("<span id='sitemap'>sitemap</span> | <span id='contactus'>contact</span>");
	$("#sitemap")
		.css("cursor","pointer")
		.click(function(){ //sitemap click event
			location.href = "../information/sitemap.html";
		});
	$("#contactus")
		.css("cursor","pointer")
		.click(function(){ //contact click event
			location.href = "../information/contactus.html";
		});
	$("#ex_menu span").hover(
		function(){
			$(this).css("text-decoration","underline");
		},
		function(){
			$(this).css("text-decoration","none");
		}
	);
	$("#copyright_text") //insert copyright
		.text("© 2011 King George International Business College - Canada TESOL Centre. All Rights Reserved.");
	$("#copyright #copyright_link") //add more menu in copyright box
		.html("<span>site feedback</span> | <span>privacy policy</span>");
	$("#copyright #copyright_link span").css("cursor","pointer");
	$("#copyright #copyright_link span").hover(
		function()
		{
			$(this).css("color","#f27c34");
		},
		function()
		{	
			$(this).css("color","#80a3b6");
		}
	);
	
	$("#copyright_link span:eq(0)")
		.click(function(){ //site feedback click event
			location.href = "mailto:graphics@kgic.ca, barbara@kgic.ca";
		});
	$("#copyright_link span:eq(1)")
		.click(function(){ //privacy policy click event
			location.href = "../information/privancy-policy.html";
		});

	/* Every Pages End */

	/* http://kgibc.ca/admission/Register.html*/
	/* Admissions Start */
	/* Register Page Start */
	$("#fullParagraph_reg fieldset table tr:even")
		.css("background-color","#f3f4fc"); //in fieldset in table in tr even change bgcolor
	$("#fullParagraph_reg fieldset table tr:odd")
		.css("background-color","#ebedf5"); //in fieldset in table in tr odd change bgcolor
	/* Register Page End */
	
	/* http://kgibc.ca/admission/Fee.html*/
	/* Fee Page Start */
	$(".feeTop td:contains('v')").html("<img src='../images/v.gif' valign='absmiddle' alt='Check' />");
	
	$(".feeDetail th:eq(1)").css("width","90px");	
	$(".feeDetail th:eq(2)").css("width","90px");	
	$(".feeDetail th:eq(3)").css("width","90px");	
	$(".feeDetail th:eq(4)").css("width","90px");	
	/* Fee Page End */


	/* http://kgibc.ca/download/download.html */
	/* Download Page Start */
	$(".download td").
		css("text-align","center");
	$(".download th:even, .download tr:even td")
		.css("background-color","#f4f4f4");
	$(".download a div.pdf")
		.html("<img src='../images/pdf_s.gif' border=0 valign='absmiddle' alt='Pdf File' />");
	$(".download a div.word")
		.html("<img src='../images/word_s.gif' border=0 valign='absmiddle' alt='Word File' />");
	/* Download Page End */


});	


//new Floating(Object , X-Margin , Y-Margin , Slide Speed: low number is faster than high number(basic 20), smooth: low number is smooth than high (basic:10)
function Floating(FloatingObj,MarginX,MarginY,Percentage,setTime) {
	this.FloatingObj = FloatingObj;
	this.MarginX = (MarginX) ? MarginX : 0;
	this.MarginY = (MarginY) ? MarginY : 0;
	this.Percentage = (Percentage) ? Percentage : 20;
	this.setTime = (setTime) ? setTime : 10;
	this.FloatingObj.style.position = "absolute";
	this.Body = null;
	this.setTimeOut = null;
	this.Run();
}

Floating.prototype.Run = function () {
	if ((document.documentElement.scrollLeft + document.documentElement.scrollTop) > (document.body.scrollLeft + document.body.scrollTop)) {
		this.Body = document.documentElement;
	} else {
		this.Body = document.body;
	}

	var This = this;
	var FloatingObjLeft = (this.FloatingObj.style.left) ? parseInt(this.FloatingObj.style.left,10) : this.FloatingObj.offsetLeft;
	var FloatingObjTop = (this.FloatingObj.style.top) ? parseInt(this.FloatingObj.style.top,10) : this.FloatingObj.offsetTop;
	var DocLeft = this.Body.scrollLeft + this.MarginX;
	var DocTop = this.Body.scrollTop + this.MarginY;

	var MoveX = Math.abs(FloatingObjLeft - DocLeft);
	MoveX = Math.ceil(MoveX / this.Percentage);
	var MoveY = Math.abs(FloatingObjTop - DocTop);
	MoveY = Math.ceil(MoveY / this.Percentage);

	if (FloatingObjLeft < DocLeft) {
		this.FloatingObj.style.left = FloatingObjLeft + MoveX + "px";
	} else {
		this.FloatingObj.style.left = FloatingObjLeft - MoveX + "px";
	}

	if (FloatingObjTop < DocTop) {
		this.FloatingObj.style.top = FloatingObjTop + MoveY + "px";
	} else {
		this.FloatingObj.style.top = FloatingObjTop - MoveY + "px";
	}

	window.clearTimeout(this.setTimeOut);
	this.setTimeOut = window.setTimeout(function () { This.Run(); },this.setTime);
}
