var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();

function addOption(selectbox, value, text )
{
	var optn = document.createElement("OPTION");
	optn.text = text;
	optn.value = value;
	if(BrowserDetect.OS=="Mac"){
	selectbox.add(optn);
	}else{
	selectbox.options.add(optn);
	}
}

function removeAllOptions(selectbox)
{
	var i;
	for(i=selectbox.options.length-1;i>=0;i--)
	{
		//selectbox.options.remove(i);
		selectbox.remove(i);
	}
}

function fillCities(){
 // this function is used to fill the city list on load
addOption(document.myForm.sc_city_id, "", "اختار المدينة");
addOption(document.myForm.sc_city_id, "1", "العاشر من رمضان");
addOption(document.myForm.sc_city_id, "2", "15 مايو");
addOption(document.myForm.sc_city_id, "3", "السادس من أكتوبر");
addOption(document.myForm.sc_city_id, "4", "العين السخنة");
addOption(document.myForm.sc_city_id, "5", "الإسكندرية");
addOption(document.myForm.sc_city_id, "7", "العريش");
addOption(document.myForm.sc_city_id, "8", "أسيوط");
addOption(document.myForm.sc_city_id, "9", "أسوان");
addOption(document.myForm.sc_city_id, "10", "مدينة بدر");
addOption(document.myForm.sc_city_id, "11", "بلطيم");
addOption(document.myForm.sc_city_id, "12", "بنها");
addOption(document.myForm.sc_city_id, "13", "البحيرة");
addOption(document.myForm.sc_city_id, "14", "القاهرة و الجيزة");
addOption(document.myForm.sc_city_id, "58", "القاهرة الجديدة");
addOption(document.myForm.sc_city_id, "15", "الطريق الصحراوي");
addOption(document.myForm.sc_city_id, "16", "طريق القاهرة الإسماعيلية");
addOption(document.myForm.sc_city_id, "17", "طريق القاهرة الدائرى");
addOption(document.myForm.sc_city_id, "18", "ذهب");
addOption(document.myForm.sc_city_id, "19", "الدقهلية");
addOption(document.myForm.sc_city_id, "20", "دمنهور");
addOption(document.myForm.sc_city_id, "21", "دمياط");
addOption(document.myForm.sc_city_id, "22", "دريم لاند");
addOption(document.myForm.sc_city_id, "23", "الجونة");
addOption(document.myForm.sc_city_id, "24", "مدينة الرحاب");
addOption(document.myForm.sc_city_id, "25", "فايد");
addOption(document.myForm.sc_city_id, "26", "الفيوم");
addOption(document.myForm.sc_city_id, "27", "جمصة");
//addOption(document.myForm.sc_city_id, "28", "الجيزة");
addOption(document.myForm.sc_city_id, "29", "الغردقة");
addOption(document.myForm.sc_city_id, "30", "الاسماعيلية");
addOption(document.myForm.sc_city_id, "31", "قليوب");
addOption(document.myForm.sc_city_id, "32", "الأقصر");
addOption(document.myForm.sc_city_id, "33", "المنصورة");
addOption(document.myForm.sc_city_id, "34", "مارينا");
addOption(document.myForm.sc_city_id, "35", "مرسى علم");
addOption(document.myForm.sc_city_id, "36", "مرسى مطروح");
addOption(document.myForm.sc_city_id, "37", "المنيا");
addOption(document.myForm.sc_city_id, "38", "الساحل الشمالى");
addOption(document.myForm.sc_city_id, "49", "نويبع");
addOption(document.myForm.sc_city_id, "40", "مدينة العبور");
addOption(document.myForm.sc_city_id, "41", "بورفؤاد");
addOption(document.myForm.sc_city_id, "42", "بورسعيد");
addOption(document.myForm.sc_city_id, "43", "القصير");
addOption(document.myForm.sc_city_id, "44", "رأس الحكمة");
addOption(document.myForm.sc_city_id, "45", "رأس سدر");
addOption(document.myForm.sc_city_id, "46", "مدينة السادات");
addOption(document.myForm.sc_city_id, "47", "سفاجا");
addOption(document.myForm.sc_city_id, "48", "شرم الشيخ");
addOption(document.myForm.sc_city_id, "49", "مدينة الشيخ زايد");
addOption(document.myForm.sc_city_id, "50", "مدينة الشروق");
addOption(document.myForm.sc_city_id, "51", "سيدى عبد الرحمن");
addOption(document.myForm.sc_city_id, "52", "خليج سوما");
addOption(document.myForm.sc_city_id, "53", "السويس");
addOption(document.myForm.sc_city_id, "54", "طابا");
addOption(document.myForm.sc_city_id, "55", "طنطا");
addOption(document.myForm.sc_city_id, "56", "الزقازيق");
addOption(document.myForm.sc_city_id, "59", "المحلة");
addOption(document.myForm.sc_city_id, "60", "شبين الكوم");
addOption(document.myForm.sc_city_id, "61", "كفر الشيخ");
addOption(document.myForm.sc_city_id, "62", "طريق وادي النطرون - العلمين");
}
