﻿function top_menu_select()
{
	//*
	var strReturn = "";
	var strHref = window.location.href;
	var array = strHref.split("/");
	var result = array[(array.length)-2];
	if(result == "www.asra3net.com" || result == "www.asra3net.com/index.php"){document.getElementById("top_menu_home").style.backgroundImage = "url(images/big_arrow.png)";}
	if(result == "MyAccount"){document.getElementById("top_menu_my_account").style.backgroundImage = "url(../images/big_arrow.png)";}
	if(result == "CardInfo"){document.getElementById("top_menu_CardInfo").style.backgroundImage = "url(../images/big_arrow.png)";}
	if(result == "Signup"){document.getElementById("top_menu_signup").style.backgroundImage = "url(../images/big_arrow.png)";}
	if(result == "Dealers"){document.getElementById("top_menu_dealers").style.backgroundImage = "url(../images/big_arrow.png)";}
	if(result == "Cards"){document.getElementById("top_menu_cards").style.backgroundImage = "url(../images/big_arrow.png)";}
	//*/
}

/* -------------- HOME PAGE BODY AJAX MENUS TITLE CELL BACKGROUND -------------- */
function ajax_cell_background(section)
{
	if(section == 1)
	{
		document.getElementById("body_ajax_1").style.backgroundImage    = "url(images/vipit_search_r.jpg)";
		document.getElementById("body_ajax_1").style.backgroundRepeat   = "repeat";
		document.getElementById("body_ajax_1").style.borderRight        = "0px";
		document.getElementById("body_ajax_2").style.backgroundImage    = "url(images/vipit_search.jpg)";
		document.getElementById("body_ajax_3").style.backgroundImage    = "url(images/asra3net_news.jpg)";
		document.getElementById("body_ajax_3").style.backgroundRepeat   = "repeat";
		document.getElementById("body_ajax_3").style.borderLeft         = "0px";
		document.getElementById("body_ajax_4").style.backgroundImage    = "url(images/asra3net_news_bg.jpg)";
		document.getElementById("body_ajax_5").style.backgroundImage    = "url(images/asra3net_news_bg.jpg)";
		document.getElementById("body_ajax_5").style.backgroundRepeat   = "repeat";
		document.getElementById("body_ajax_5").style.backgroundPosition = "right";
		document.getElementById("body_ajax_5").style.borderLeft         = "1px #6c6c6c solid";
		document.getElementById("body_ajax_6").style.backgroundImage    = "url(images/asra3net_news_bg.jpg)";
		document.getElementById("body_ajax_7").style.backgroundImage    = "url(images/asra3net_news_bg.jpg)";
		document.getElementById("body_ajax_7").style.borderLeft         = "1px #6c6c6c solid";

		document.getElementById("body_ajax_1_a").style.color            = "black";
		document.getElementById("body_ajax_2_a").style.color            = "white";
		document.getElementById("body_ajax_3_a").style.color            = "white";
	}
	if(section == 2)
	{
		document.getElementById("body_ajax_1").style.backgroundImage    = "url(images/asra3net_news_bg.jpg)";
		document.getElementById("body_ajax_1").style.backgroundRepeat   = "repeat";
		document.getElementById("body_ajax_1").style.borderRight        = "1px #6c6c6c solid";
		document.getElementById("body_ajax_2").style.backgroundImage    = "url(images/asra3net_news_bg.jpg)";
		document.getElementById("body_ajax_3").style.backgroundImage    = "url(images/vipit_search_r.jpg)";
		document.getElementById("body_ajax_3").style.backgroundRepeat   = "repeat";
		document.getElementById("body_ajax_3").style.borderLeft         = "0px";
		document.getElementById("body_ajax_4").style.backgroundImage    = "url(images/vipit_search.jpg)";
		document.getElementById("body_ajax_5").style.backgroundImage    = "url(images/asra3net_news.jpg)";
		document.getElementById("body_ajax_5").style.backgroundRepeat   = "no-repeat";
		document.getElementById("body_ajax_5").style.backgroundPosition = "right";
		document.getElementById("body_ajax_5").style.borderLeft         = "0px";
		document.getElementById("body_ajax_6").style.backgroundImage    = "url(images/asra3net_news_bg.jpg)";
		document.getElementById("body_ajax_7").style.backgroundImage    = "url(images/asra3net_news_bg.jpg)";
		document.getElementById("body_ajax_7").style.borderLeft         = "1px #6c6c6c solid";

		document.getElementById("body_ajax_1_a").style.color            = "white";
		document.getElementById("body_ajax_2_a").style.color            = "black";
		document.getElementById("body_ajax_3_a").style.color            = "white";
	}
	if(section == 3)
	{
		document.getElementById("body_ajax_1").style.backgroundImage    = "url(images/asra3net_news_bg.jpg)";
		document.getElementById("body_ajax_1").style.backgroundRepeat   = "repeat";
		document.getElementById("body_ajax_1").style.borderRight        = "1px #6c6c6c solid";
		document.getElementById("body_ajax_2").style.backgroundImage    = "url(images/asra3net_news_bg.jpg)";
		document.getElementById("body_ajax_3").style.backgroundImage    = "url(images/asra3net_news_bg.jpg)";
		document.getElementById("body_ajax_3").style.backgroundRepeat   = "repeat";
		document.getElementById("body_ajax_3").style.borderLeft         = "1px #6c6c6c solid";
		document.getElementById("body_ajax_4").style.backgroundImage    = "url(images/asra3net_news_bg.jpg)";
		document.getElementById("body_ajax_5").style.backgroundImage    = "url(images/vipit_search_r.jpg)";
		document.getElementById("body_ajax_5").style.backgroundRepeat   = "repeat";
		document.getElementById("body_ajax_5").style.backgroundPosition = "left";
		document.getElementById("body_ajax_5").style.borderLeft         = "0px";
		document.getElementById("body_ajax_6").style.backgroundImage    = "url(images/vipit_search.jpg)";
		document.getElementById("body_ajax_7").style.backgroundImage    = "url(images/asra3net_news.jpg)";
		document.getElementById("body_ajax_7").style.borderLeft         = "0px";

		document.getElementById("body_ajax_1_a").style.color            = "white";
		document.getElementById("body_ajax_2_a").style.color            = "white";
		document.getElementById("body_ajax_3_a").style.color            = "black";
	}
}

/* -------------- CHECK PASSWORD MATCH FOR CREAT ACCOUNT -------------- */

function check_password(val1, val2)
{
if(val1 != val2){alert("كلمة السر غير متطابقة"); return false}
else if(val1 == "" || val2 == ""){alert("لا يمكن ترك كلمة المرور فارغة"); return false}
else{return true;}
}

/* -------------- SUBMIT ON ENTER -------------- */

function do_submit(section)
{
	var site_url = location.href; 
	var sub_url  = site_url.split("/"); 
	if(sub_url.length>4){require_path = "../";}
	else{require_path = "./";}

	if(section == 1)
	{
		if ((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13))
		{
		    get_content("creat_account", document.getElementById("pro_user").value, document.getElementById("pro_pass").value, 1);
		    return false;
		} 
		else return true
	}
	
	if(section == 2)
	{
		if ((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13))
		{
		    get_content("signin",document.getElementById("pro_user").value,document.getElementById("pro_pass").value);
		    return false;
		} 
		else return true
	}
	
	if(section == 3)
	{
		if ((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13))
		{
		    get_content("card_info",document.getElementById("pro_user").value,document.getElementById("pro_pass").value);
		    return false;
		} 
		else return true
		
	}
	
	if(section == "search1")
	{
		if ((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13))
		{
		    location.href=require_path+"index.php?q=" + document.getElementById('q').value;
		    return false;
		} 
		else return true
		
	}

	if(section == "search2")
	{
		if ((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13))
		{
		    location.href="index.php?id=" + document.getElementById('id').value;
		    return false;
		} 
		else return true
		
	}
}

/* -------------- ADSL FUNCTIONS -------------- */

function Disab(v)
{
	if(v==1){document.getElementById("m8mb").disabled="disabled";document.getElementById("m4mb").disabled="disabled";document.getElementById("comp").disabled="disabled";}
	else{document.getElementById("m8mb").disabled=false;document.getElementById("m4mb").disabled=false;document.getElementById("comp").disabled=false;}
}
//*
var telportsarray = new Array();
telportsarray[-1] = new Array();
telportsarray['حلب'] = new Array();
telportsarray['حلب'][0] = "الأشرفية";
telportsarray['حلب'][1] = "جسر الحاج";
telportsarray['حلب'][2] = "الحمدانية";
telportsarray['حلب'][3] = "سانا محيدلية";
telportsarray['حلب'][4] = "سليمانية";
telportsarray['حلب'][5] = "السبيل";
telportsarray['حلب'][6] = "الأنصاري";
telportsarray['حلب'][7] = "حلب الجديدة";
telportsarray['حلب'][8] = "خان الوزير";
telportsarray['حلب'][9] = "جميلية";
telportsarray['دمشق و ريفها'] = new Array();
telportsarray['دمشق و ريفها'][0] = "صيدنايا";
telportsarray['دمشق و ريفها'][1] = "ببيلا";
telportsarray['دمشق و ريفها'][2] = "مليحة";
telportsarray['دمشق و ريفها'][3] = "يبرود";
telportsarray['دمشق و ريفها'][4] = "زبداني";
telportsarray['دمشق و ريفها'][5] = "بلودان";
telportsarray['دمشق و ريفها'][6] = "معضمية";
telportsarray['دمشق و ريفها'][7] = "عين الفيجة";
telportsarray['دمشق و ريفها'][8] = "التل";
telportsarray['دمشق و ريفها'][9] = "ديرعطية";
telportsarray['دمشق و ريفها'][10] = "حوش بلاس";
telportsarray['دمشق و ريفها'][11] = "سبينة";
telportsarray['دمشق و ريفها'][12] = "داريا";
telportsarray['دمشق و ريفها'][13] = "قطنا";
telportsarray['دمشق و ريفها'][14] = "صحنايا";
telportsarray['دمشق و ريفها'][15] = "بحوث";
telportsarray['دمشق و ريفها'][16] = "يعفور";
telportsarray['دمشق و ريفها'][17] = "زملكا";
telportsarray['دمشق و ريفها'][18] = "دوما";
telportsarray['دمشق و ريفها'][19] = "ضاحية حرستا";
telportsarray['دمشق و ريفها'][20] = "أبن العميد";
telportsarray['دمشق و ريفها'][21] = "القدم";
telportsarray['دمشق و ريفها'][22] = "ضاحية قدسيا";
telportsarray['دمشق و ريفها'][23] = "جوبر";
telportsarray['دمشق و ريفها'][24] = "قابون";
telportsarray['دمشق و ريفها'][25] = "السيدة زينب";
telportsarray['دمشق و ريفها'][26] = "دويلعة";
telportsarray['دمشق و ريفها'][27] = "جرمانا";
telportsarray['دمشق و ريفها'][28] = "بغداد";
telportsarray['دمشق و ريفها'][29] = "الثورة";
telportsarray['دمشق و ريفها'][30] = "النصر";
telportsarray['دمشق و ريفها'][31] = "الميدان";
telportsarray['دمشق و ريفها'][32] = "المهاجرين";
telportsarray['دمشق و ريفها'][33] = "الجلاء";
telportsarray['دمشق و ريفها'][34] = "المزة d2";
telportsarray['دمشق و ريفها'][35] = "كفرسوسة";
telportsarray['دمشق و ريفها'][36] = "المزة d3";
telportsarray['دمشق و ريفها'][37] = "دمر";
telportsarray['درعا'] = new Array();
telportsarray['درعا'][0] = "جباب";
telportsarray['درعا'][1] = "غباغب";
telportsarray['درعا'][2] = "درعا c2";
telportsarray['دير الزور'] = new Array();
telportsarray['دير الزور'][0] = "ميادين";
telportsarray['دير الزور'][1] = "دير الزور A1";
telportsarray['دير الزور'][2] = "دير الزور B1";
telportsarray['دير الزور'][3] = "دير الزور C1";
telportsarray['حماه'] = new Array();
telportsarray['حماه'][0] = "سقيلبية";
telportsarray['حماه'][1] = "تل الصاحب";
telportsarray['حماه'][2] = "بسيرين";
telportsarray['حماه'][3] = "هيلفايا";
telportsarray['حماه'][4] = "سوران";
telportsarray['حماه'][5] = "كم هاني";
telportsarray['حماه'][6] = "وادي العيون";
telportsarray['حماه'][7] = "دير ماما";
telportsarray['حماه'][8] = "مصياف";
telportsarray['حماه'][9] = "حي القصور";
telportsarray['حماه'][10] = "مهاتا/حضر";
telportsarray['حماه'][11] = "السلمية";
telportsarray['حماه'][12] = "أبي الفداء";
telportsarray['حماه'][13] = "ضاحية البعث";
telportsarray['حماه'][14] = "المحردة";
telportsarray['حماه'][15] = "القوتلي";
telportsarray['الحسكة'] = new Array();
telportsarray['الحسكة'][0] = "تل تامر";
telportsarray['الحسكة'][1] = "الشدادي";
telportsarray['الحسكة'][2] = "الحسكة c";
telportsarray['الحسكة'][3] = "القامشلي A1A2";
telportsarray['الحسكة'][4] = "الحسكة A1B1";
telportsarray['الحسكة'][5] = "القامشلي B1";
telportsarray['حمص'] = new Array();
telportsarray['حمص'][0] = "حسيا الصناعية";
telportsarray['حمص'][1] = "الرستن";
telportsarray['حمص'][2] = "تدمر";
telportsarray['حمص'][3] = "الناصرة";
telportsarray['حمص'][4] = "هواش";
telportsarray['حمص'][5] = "قطينة";
telportsarray['حمص'][6] = "وعر";
telportsarray['حمص'][7] = "بيادا";
telportsarray['حمص'][8] = "الزهراء";
telportsarray['حمص'][9] = "وادي الدهب";
telportsarray['حمص'][10] = "قوتلي";
telportsarray['إدلب'] = new Array();
telportsarray['إدلب'][0] = "جسر الشغور";
telportsarray['إدلب'][1] = "إدلب C";
telportsarray['إدلب'][2] = "معرة النعمان";
telportsarray['اللاذقية'] = new Array();
telportsarray['اللاذقية'][0] = "المدينة الصناعية";
telportsarray['اللاذقية'][1] = "كسب";
telportsarray['اللاذقية'][2] = "ضاحية الأسد";
telportsarray['اللاذقية'][3] = "جبلة";
telportsarray['اللاذقية'][4] = "ساحة اليمان";
telportsarray['اللاذقية'][5] = "تشرين";
telportsarray['الرقة'] = new Array();
telportsarray['الرقة'][0] = "الرقة";
telportsarray['السويداء'] = new Array();
telportsarray['السويداء'][0] = "السويداء";
telportsarray['السويداء'][1] = "صلخد";
telportsarray['السويداء'][2] = "السويداء C";
telportsarray['طرطوس'] = new Array();
telportsarray['طرطوس'][0] = "دريكيش";
telportsarray['طرطوس'][1] = "ريمال الزبيدية";
telportsarray['طرطوس'][2] = "بانياس";
telportsarray['طرطوس'][3] = "طرطوس C";
telportsarray['طرطوس'][4] = "طرطوس AB";
//*/

function changeTelports(value)
{	
	var telports = document.getElementById('telports');	
	//alert(telports);
	telports.options.length = 0;
	//alert(telports.options.length);
	var citiesLength = telportsarray[value].length;	
	//alert(citiesLength);
	telports.options[0] = new Option(" اختر", " اختر");
	//alert(telports);
	for(i=0; i < citiesLength; i++){telports.options[i] = new Option(telportsarray[value][i], i);}	
}

/* -------------- SEARCH -------------- */
function search_reset(text)
{
	if(text.value == "اكتب هنا الكلمة التي تريد البحث عنها .."){text.value = "";}
}

function search_default(text)
{
	if(text.value == ""){text.value = "اكتب هنا الكلمة التي تريد البحث عنها ..";}
}

/* -------------- ARRAY SEARCH -------------- */
function array_search (array,val)
{
	for (var i = 0; i < array.length; i++)
	{
		if (array[i] == val){return true;}
	}
	return false;
}

/* -------------- ADD CARD -------------- */
function add_cards_panel()
{
	var check;
	var Cerror;
	var count;
	count = parseInt(document.getElementById("cards_count").innerHTML) - 1 ;
	var label; 
	label = "card_user" + count;
	var label2; 
	label2 = "card_password" + count;
	var pass_list = new Array();
	var base;
	var start; start = 0;
	for(var i = count; i > 0;i--)
	{
	base = "card_password" + i ;
	if(array_search( pass_list, document.getElementById(base).value)){alert("لا يمكن تكرار البطاقة يرجى استخدام بطاقة أخرى"); return;}
	else{pass_list[start] = document.getElementById(base).value;start = start + 1;}
	}
	get_content("check_card",document.getElementById(label).value,document.getElementById(label2).value,pass_list);
}

function add_cards_panel2()
{
	divId=parseInt(document.getElementById('cards_count').innerHTML);
	//*
	//MAKING PASSWORDS AND USERS ARRAY 
	var pass_list = new Array();
	var user_list = new Array();
	var start = 0;
	for(var i = parseInt(divId)-1; i > 0;i--){
		pass_list[start] = document.getElementById("card_password" + i).value
		user_list[start++] = document.getElementById("card_user" + i).value;
	}
	document.getElementById("cards_panel").innerHTML += '<table style="text-align:right; border-collapse:collapse" cellpadding="0" cellspacing="1" border="0" dir="rtl"><tr><td style="width:12px" rowspan="2"><div id="cardImage'+divId+'"></div></td><td style="background-color:silver; padding-right:5px; color:black">تسجيل دخول</td><td style="width:140px"><input type="text" id="card_user'+divId+'" /></td><td style="text-align:right"><div id="check_wait'+divId+'"></div></td></tr><tr><td style="background-color:silver; padding-right:5px; color:black">كلمة مرور</td><td><input type="password" id="card_password'+divId+'" onblur="ajax_check_card('+ divId +')" /></td><td width="30px"><div id="addCardDiv'+divId+'"><input type="button" value="+" onclick="add_cards_panel2()" /></div></td></tr></table><span style="font-size:3px">&nbsp;</span><br/>';
	document.getElementById("addCardDiv"+(divId-1)).innerHTML = "&nbsp;";
	//RETURN PASSWORDS
	var start= 0;
	for(var i = divId-1; i > 0;i--){
		document.getElementById("card_password" + i).value = pass_list[start];
		document.getElementById("card_user" + i).value = user_list[start++]; 
	}

	//ADD CARD TO COUNT
	document.getElementById("cards_count").innerHTML = parseInt(document.getElementById("cards_count").innerHTML) + 1;
	
	//*/
}


function creat_account_step3()
{
	if(parseInt(document.getElementById("cards_sum").innerHTML) < parseInt(document.getElementById("e").innerHTML)){alert("الرصيد لايكفي .. يرجى إدخال بطاقة أخرى");return;}

	var users ;
	var passw ;
	
	users = new Array();
	passw = new Array();
	//alert(parseInt(document.getElementById("cards_count").innerHTML));
	for(i = (parseInt(document.getElementById("cards_count").innerHTML)-1); i>0;i--)
	{
		users[i-1] = document.getElementById("card_user" + i).value ;
		passw[i-1] = document.getElementById("card_password" + i).value ;
		//alert(users[i-1]);
		//alert(passw[i-1]);
	}
	//alert('get_content("creat_account_new",'+document.getElementById("b").innerHTML+',"3",'+users+','+passw+','+document.getElementById("username").value+','+document.getElementById("value3").value+','+document.getElementById("value4").value+','+document.getElementById("value5").value+','+document.getElementById("value6").value+','+document.getElementById("value7").value+','+document.getElementById("value8").value+','+document.getElementById("value9").value+','+document.getElementById("value10").value+','+document.getElementById("d").innerHTML+','+document.getElementById("e").innerHTML+')');
	get_content("creat_account_new",document.getElementById("b").innerHTML,"3",users,passw,document.getElementById("username").value,document.getElementById("value3").value,document.getElementById("value4").value,document.getElementById("value5").value,document.getElementById("value6").value,document.getElementById("value7").value,document.getElementById("value8").value,document.getElementById("value9").value,document.getElementById("value10").value,document.getElementById("d").innerHTML,document.getElementById("e").innerHTML);
}


/* -------------- AJAX CHECK CARD -------------- */
function ajax_check_card(divId)
{
	var label; 
	label = "card_user" + divId;
	var label2; 
	label2 = "card_password" + divId;

	var base;
	var start; start = 0;
	var pass_list = new Array();
	for(var i = divId; i > 0;i--)
	{
	base = "card_password" + i ;
	if(array_search( pass_list, document.getElementById(base).value)){alert("لا يمكن تكرار البطاقة يرجى استخدام بطاقة أخرى"); return;}
	else{pass_list[start] = document.getElementById(base).value;start = start + 1;}
	}

	var users ;
	var passw ;
	users = document.getElementById(label).value ;
	passw = document.getElementById(label2).value ;
	
	get_content("ajax_check_card", users, passw, divId);

}


/* -------------- AJAX CHECK ARABIC LETTERS -------------- */
function avoid_arabic_lettres(field)
{
	if (window.event.keyCode < 1569 || window.event.keyCode > 1610) {return true;}
	else{alert("لا يمكن استخدام أحرف عربية يرجى الكتابة باللغة الانكليزية حصراً");return false;}
}

