﻿// بسم الله

//site sections
var DefaultGroup = "G1";
var c = 0;
var x = "</a> | ";
var m1S = "<a href='http://www2.code-times.net/ar/home/";
var m1Subs = m1S + "Default.aspx'>نظرة أولى" + x +
						m1S + "whyus.aspx'>لماذا نحن</a>";

var m2S = "<a href='http://www2.code-times.net/ar/technologies/";
var m2Subs = m2S + "Default.aspx'>نظرة أولى" + x +
						m2S + "dotnet.aspx'>MS .net technology" + x +
						m2S + "sqlserver.aspx'>SQL Server DB" + x +
						m2S + "php.aspx'>PHP" + x +
						m2S + "ajax.aspx'>AJAX" + x +
						m2S + "web2.aspx'>Web2 Concepts</a>";

var m3S = "<a href='http://www2.code-times.net/ar/solutions/";
var m3Subs = m3S + "Default.aspx'>نظرة أولى" + x +
						m3S + "websites.aspx'>خدمات ويب" + x +
						m3S + "windows_apps.aspx'>برمجيات ويندوز" + x +
						m3S + "database.aspx'>حلول قواعد البيانات</a>";

var m4S = "<a href='http://www2.code-times.net/ar/portfolio/";
var m4Subs = m4S + "Default.aspx'>اعمال سابقة</a>";

var m5S = "<a href='http://www2.code-times.net/ar/contacts/";
var m5Subs = m5S + "aboutus.aspx'>من نحن" + x +
						m5S + "faq.aspx'>الأسئلة الشائعة" + x +
						m5S + "contact.aspx'>اتصل بنا</a>";

function showSubs(MID) {
	if (c == 1) { return; }
	$('#SubMenuItems').hide();
	switch (MID) {
		case "G1":
			document.getElementById("SubMenuItems").innerHTML = m1Subs;
			break;
		case "G2":
			document.getElementById("SubMenuItems").innerHTML = m2Subs;
			break;
		case "G3":
			document.getElementById("SubMenuItems").innerHTML = m3Subs;
			break;
		case "G4":
			document.getElementById("SubMenuItems").innerHTML = m4Subs;
			break;
		case "G5":
			document.getElementById("SubMenuItems").innerHTML = m5Subs;
			break;
		default:
			document.getElementById("SubMenuItems").innerHTML = "";
	}
	$("#SubMenuItems").fadeIn("slow");
}


$(document).ready(function () {
//body expressions
	$("#MBody").hide();
	$("#MBody").ready(function() {
		$("#MBody").fadeIn(1500);
	});
//flyer expressions
	$("#flyer .rp").attr("href", "../contacts");
	if (navigator.userAgent.toLowerCase().indexOf('chrome') > -1) {
		$('#flyer').css('right', "50px");
	};
//restore font size
	UsFtSze()
});




function D(N) {
	try {
		t10 = new Tween(N.style, 'width', Tween.elasticEaseOut, 27, 140, 2, 'px');
		t10.start();
	}
	catch (e) {}
}
function E() {
	try {
		t10.rewind();
	}
	catch (e) {}
}

//user font size and cookie
function getCookie(c_name) {
	if (document.cookie.length > 0) {
		c_start = document.cookie.indexOf(c_name + "=");
		if (c_start != -1) {
			c_start = c_start + c_name.length + 1;
			c_end = document.cookie.indexOf(";", c_start);
			if (c_end == -1) c_end = document.cookie.length;
			return unescape(document.cookie.substring(c_start, c_end));
		}
	}
	return "";
}
function setCookie(c_name, value, expiredays) {
	var exdate = new Date();
	exdate.setDate(exdate.getDate() + expiredays);
	document.cookie = c_name + "=" + escape(value) + ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString());
}

function UsFtSze() {	/*Restoring user font size setting*/
	try {
		var FontS = getCookie("FontSize");
		if (FontS) {
			S = parseInt(FontS);
			CHFontOp(parseInt(FontS) * 2);
		};
	} catch (e) {}
}

var S = 0;
function ChFont(Action) {
	var Op;
	switch (Action) {
		case "+":
			if (S < 7) { S += 1, Op = 2 } else { return; };
			break;
		case "-":
			if (S >= 1) { S -= 1, Op = -2 } else { return; };
			break;
		default: return;
	}
	CHFontOp(Op);
	setCookie("FontSize", parseInt(S), 365);
}

function CHFontOp(Op) {
	$('#RightBody p').css('font-size', parseInt($('#RightBody p').css('font-size')) + Op);
	$('#RightBody h1').css('font-size', parseInt($('#RightBody h1').css('font-size')) + Op);
	$('#RightBody h2').css('font-size', parseInt($('#RightBody h2').css('font-size')) + Op);
	$('#RightBody h3').css('font-size', parseInt($('#RightBody h3').css('font-size')) + Op);
	$('#RightBody h4').css('font-size', parseInt($('#RightBody h4').css('font-size')) + Op);
	$('#RightBody h5').css('font-size', parseInt($('#RightBody h5').css('font-size')) + Op);
	$('#RightBody h6').css('font-size', parseInt($('#RightBody h6').css('font-size')) + Op);
	$('#RightBody ul').css('font-size', parseInt($('#RightBody ul').css('font-size')) + Op);
}

//language sections (on top)
var X2 = 0;
function ShowLang() {
	try {
		var LangConS = document.getElementById("LangCon").style
		var LangWraS = document.getElementById("LangWra").style
		if (X2 == 1) {
			t20.rewind();
			LangConS.display = "none"
			LangWraS.display = "none"
			X2 = 2;
			return;
		}
		if (X2 == 2) {
			LangWraS.display = ""
			t20.start();
			X2 = 1;
			return;
		}
		X2 = 1;
		LangConS.display = "none"
		LangWraS.display = ""
		t20 = new Tween(LangWraS, 'height', Tween.backEaseOut, 0, 200, 1, 'px');
		t20.start();
		t20.onMotionFinished = function() { LangConS.display = "" };

		var txtFile = new XMLHttpRequest();
		txtFile.open("GET", "../../res/LangScript.t", true);
		txtFile.onreadystatechange = function() {
			if (txtFile.readyState == 4) {
				if (txtFile.status == 200) {
					document.getElementById("LangCon").innerHTML = txtFile.responseText;
				}
			}
		}
		txtFile.send(null);
	}
	catch (e) { }
}
