//      16-1-2010 English JS 
//-------------------------------------------------------------------------------


//-------------------------------------------------------------------------------
//                           menu initialization 
//-------------------------------------------------------------------------------		
var urlBase= '/etisalat/templates/248';
ddsmoothmenu.init({
	    mainmenuid: "smoothmenu1", //menu DIV id
	    orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
	    classname: 'ddsmoothmenu', //class added to menu's outer DIV
	    //customtheme: ["#1c5a80", "#18374a"],
	    contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
    })
//-------------------------------------------------------------------------------
//                            menu focus setter	
//-------------------------------------------------------------------------------

function menu_selection(level_1)
{	


	//document.getElementById(level_1).style.background="url('+urlBase+'/topnav_active.gif)"
	//document.getElementById(level_1).style.repeat="url('+urlBase+'/topnav_active.gif)"
	if( document.getElementById(level_1) != null )
	{

	//	highlight menu selection - frist level
	
	//$(level_1).css('border', '1px #000 solid');
	$("#"+level_1+":first").find('a.pointer').addClass('selected_parent');
	//$(level_1).addClass('selected_parent');
	//document.getElementById(level_1).firstChild.className="pointer selected_parent";
	


//-------------------------------------------------------------------------------
//                           menu reset
//-------------------------------------------------------------------------------		
	
		$('#smoothmenu1').hover(
		function () {
		
			//	$("level_1").css('background', 'url('+urlBase+'/topnav_stretch.gif)')
			$("#"+level_1+":first").find('a.pointer').removeClass('selected_parent');
			//document.getElementById(level_1).firstChild.className="pointer";
		
		}, 
		function () {
		
				$("#"+level_1+":first").find('a.pointer').addClass('selected_parent');
		
		}
		);	
		
		}

}

$(document).ready(function(){
if($('.wahmyyya2 div').length > 0){                                                                                                
var level_3 =$('.wahmyyya2 div').text();                
//$( 'ul.product_menu_items li a:contains(' + level_3 + ')' ).parent().addClass('product_menu_selected');

$('ul.product_menu_items li a').filter( function (index) {    return $(this).text() == level_3 ;})
 .parent().addClass('product_menu_selected');


}
if($('.wahmyyya div').length > 0){
var level_2 =$('.wahmyyya div').text();  
try{
 $( 'ul.bcrumb li div:contains(' + level_2 + ')' ).parent().addClass('bcrumb_selected_item');
}catch(err){
 $('ul.bcrumb li div').filter( function (index) {    return $(this).text() == level_2 ;}) .parent().addClass('bcrumb_selected_item');
}


//$('ul.bcrumb li div').filter( function (index) {    return $(this).text() == level_2 ;}) .parent().addClass('bcrumb_selected_item');
}


 
//-------------------------------------------------------------------------------
//                           Home gallery
//-------------------------------------------------------------------------------								   	
if($('#images_container').is('.flash_content'))
{
$("#images_container #pikame").PikaChoose({show_captions:false, slide_enabled:true, show_prev_next:false,thumb_width:15, thumb_height:15,auto_play:true});
$("#images_container #pikame").fadeTo(0, 0.00);
$("#images_container #pikame").fadeTo(1000, 0.01);
$("#images_container #pikame").fadeTo(1000, 1);
$("#images_container .pika_play").fadeTo(0, 0.00);
$("#images_container .pika_play").fadeTo(1000, 0.01);
$("#images_container .pika_play").fadeTo(1000, 1);

$('#tooltip_no1,#tooltip_no2,#tooltip_no3,#tooltip_no4,#tooltip_no5,#tooltip_no6').hide();
$('#offer_no1').hover(function () {  $('#tooltip_no1').fadeIn("fast")}, function () { $('#tooltip_no1').fadeOut("fast");});
$('#offer_no2').hover(function () { $('#tooltip_no2').fadeIn("fast")}, function () { $('#tooltip_no2').fadeOut("fast");});
$('#offer_no3').hover(function () {  $('#tooltip_no3').fadeIn("fast")}, function () { $('#tooltip_no3').fadeOut("fast");});
$('#offer_no3').hover(function () { $('#tooltip_no3').fadeIn("fast")}, function () { $('#tooltip_no3').fadeOut("fast");});
$('#offer_no4').hover(function () { $('#tooltip_no4').fadeIn("fast")}, function () { $('#tooltip_no4').fadeOut("fast");});
$('#offer_no5').hover(function () { $('#tooltip_no5').fadeIn("fast")}, function () { $('#tooltip_no5').fadeOut("fast");});
$('#offer_no6').hover(function () {  $('#tooltip_no6').fadeIn("fast")}, function () { $('#tooltip_no6').fadeOut("fast");});
	
}
//-------------------------------------------------------------------------------
//                           Mobile gallery 
//-------------------------------------------------------------------------------	

if($('#mobile_phones').is('.mobile_slideshow'))
{

	$("#mobile_phones #pikame").PikaChoose({show_captions:false, slide_enabled:false, show_prev_next:true,thumb_width:61, thumb_height:61,auto_play:false});	
}
//-------------------------------------------------------------------------------
//                          Blackbery Carousel  gallery 
//-------------------------------------------------------------------------------	
if($('#carousel').is('.blackbery'))
{
var carousel = document.getElementById("carousel");	
var blackbery_items = carousel.getElementsByTagName("li");
var blackbery_num = blackbery_items.length;

if(blackbery_num>3){	
    $(".blackbery").jCarouselLite({
        btnNext: ".next1",
        btnPrev: ".prev1"
    });
	}
else{$(".next_prev_carousel").hide()}
}
//-------------------------------------------------------------------------------
//                          Brands Carousel  gallery 
//-------------------------------------------------------------------------------	
if($('#carousel2').is('.brands'))
{
var carousel2 = document.getElementById("carousel2");
items = carousel2.getElementsByTagName("li");
var li_num = items.length;
if(li_num>6){
    $(".brands").jCarouselLite({
        btnNext: ".next2",
        btnPrev: ".prev2",
		visible: 6
  });
}
else{$(".next_prev_carousel").hide()}
}	
//-------------------------------------------------------------------------------
//                           Medals and flags fade
//-------------------------------------------------------------------------------		
$('.opacity').fadeTo("fast", 0.4);

	$('.opacity').hover(
		function () {
		  $(this).fadeTo("fast", 0.99);
		}, 
		function () {
		  $(this).fadeTo("fast", 0.4);			
		}
	);		
//-------------------------------------------------------------------------------
//                            field text keeber 	
//-------------------------------------------------------------------------------											
	$('.field-clear').show();
	$('.field-field').hide();
	$('.field-clear').focus(function() {
		$(this).hide();
		$(this).next('.field-field').show();
		$(this).next('.field-field').focus();
	});
	$('.field-field').blur(function() {
		if($(this).val() == '') {
			$(this).hide();
			$(this).prev('.field-clear').show();
			
		}
	});
//-------------------------------------------------------------------------------
//                            field text keeber with popup 	
//-------------------------------------------------------------------------------		
	
	$("#looking_for_button_2").show();
	$("#looking_for_button").hide();
	$('#looking_for_input').blur(function() {
		var length = $("#looking_for_input").val().length; 
		if(length > 0)  {
		$("#looking_for_button").show();
			$("#looking_for_button_2").hide();
		}else{
	$("#looking_for_button_2").show();
	$("#looking_for_button").hide()	
		}
	});
//-------------------------------------------------------------------------------
//                            Tabs	
//-------------------------------------------------------------------------------									   			 
	var tabContainers = $('div.tabs > div');
	tabContainers.hide().filter(':first').show();			
	$('div.tabs ul.tabNavigation a').click(function () {
		tabContainers.hide();
		tabContainers.filter(this.hash).show();
		$('div.tabs ul.tabNavigation a').removeClass('selected');
		$(this).addClass('selected');
		return false;
	}).filter(':first').click();

//-------------------------------------------------------------------------------
//                            Trigger slide
//-------------------------------------------------------------------------------													
	$('#slideshow').slideshow({
		  timeout: 5000,
		  fadetime: 2000,
		  type: 'sequence',
		  pauselink: 'pause'
	});	   
	$(".toggle_container").hide();

	$(".trigger").toggle(function(){
		  $(this).contents(".plus_button").css('background', 'url('+urlBase+'/minus_button.gif)');
		  }, function () {
		  $(this).contents(".plus_button").css('background', 'url('+urlBase+'/plus_button.gif)');
	});			
	$(".trigger").click(function(){
		  $(this).parent().next(".toggle_container").slideToggle("slow");
	});

		
	
	$(".careers_toggle_container").hide();

	$(".careers_trigger").toggle(function(){
		  $(this).css('background', 'url('+urlBase+'/collapse1.jpg) right no-repeat');
		  }, function () {
		  $(this).css('background', 'url('+urlBase+'/expand1.jpg) right no-repeat');
	});			
	$(".careers_trigger").click(function(){
		  $(this).next(".careers_toggle_container").slideToggle("slow");
	});
	
	function career_personal(){
		$(".career_personal").click();
	}
	career_personal();
	
//-------------------------------------------------------------------------------
//                           features slide show
//-------------------------------------------------------------------------------	
	var feature=1;		
	$(".first_feature").hover(function(){ 
		if(feature==1)
 		{
	  	feature=0;
		$(this).parent().parent().next(".price_view").slideDown(250);
		$(this).parent().parent().next().next(".enroll_view").hide();
		$(this).parent().parent().next().next().next(".terms_view").hide();
		$(this).css('background', 'url('+urlBase+'/pointer.jpg) no-repeat center 20px');
		$(this).parent().parent().find(".second_feature").css('background', 'url('+urlBase+'/pointer_real.jpg) no-repeat center 20px');
		$(this).parent().parent().find(".third_feature").css('background', 'url('+urlBase+'/pointer_real.jpg) no-repeat center 20px');
		}
		else{
		$(this).parent().parent().next(".price_view").show();
		$(this).parent().parent().next().next(".enroll_view").hide();
		$(this).parent().parent().next().next().next(".terms_view").hide();	
	     $(this).css('background', 'url('+urlBase+'/pointer.jpg) no-repeat center 20px');
        $(this).parent().parent().find(".second_feature").css('background', 'url('+urlBase+'/pointer_real.jpg) no-repeat center 20px');
		$(this).parent().parent().find(".third_feature").css('background', 'url('+urlBase+'/pointer_real.jpg) no-repeat center 20px');
		}		
	});		   		
	$(".second_feature").hover(function(){
		 if(feature==1)
 		{
		feature=0;
		$(this).parent().next().next(".enroll_view").slideDown(250);
		$(this).parent().next(".price_view").hide();
		$(this).parent().next().next().next(".terms_view").hide();
		$(this).css('background', 'url('+urlBase+'/pointer.jpg) no-repeat center 20px');
		$(this).parent().find(".first_feature").css('background', 'url('+urlBase+'/pointer_real.jpg) no-repeat center 20px');
		$(this).parent().find(".third_feature").css('background', 'url('+urlBase+'/pointer_real.jpg) no-repeat center 20px');
		}
		else{
		$(this).parent().next().next(".enroll_view").show();
		$(this).parent().next(".price_view").hide();
		$(this).parent().next().next().next(".terms_view").hide();
				$(this).css('background', 'url('+urlBase+'/pointer.jpg) no-repeat center 20px');
		$(this).parent().find(".first_feature").css('background', 'url('+urlBase+'/pointer_real.jpg) no-repeat center 20px');
		$(this).parent().find(".third_feature").css('background', 'url('+urlBase+'/pointer_real.jpg) no-repeat center 20px');
			
		}
	});
	$(".third_feature").hover(function(){
		if(feature==1)
 		{
		feature=0;						 
		$(this).parent().next().next().next(".terms_view").slideDown(250);
		$(this).parent().next(".price_view").hide();
		$(this).parent().next().next(".enroll_view").hide();
		$(this).css('background', 'url('+urlBase+'/pointer.jpg) no-repeat center 20px');
		$(this).parent().find(".first_feature").css('background', 'url('+urlBase+'/pointer_real.jpg) no-repeat center 20px');
		$(this).parent().find(".second_feature").css('background', 'url('+urlBase+'/pointer_real.jpg) no-repeat center 20px');
		}
		else{
		$(this).parent().next().next().next(".terms_view").show();	
		$(this).parent().next(".price_view").hide();
		$(this).parent().next().next(".enroll_view").hide();
		$(this).css('background', 'url('+urlBase+'/pointer.jpg) no-repeat center 20px');
		$(this).parent().find(".first_feature").css('background', 'url('+urlBase+'/pointer_real.jpg) no-repeat center 20px');
		$(this).parent().find(".second_feature").css('background', 'url('+urlBase+'/pointer_real.jpg) no-repeat center 20px');		
		}
	});	
	
//-------------------------------------------------------------------------------
//                           Send success or fail
//-------------------------------------------------------------------------------							
   //var sent_success=2;
   $('.popup_form_container').show();
	$('.send_success').hide();
	$('.send_faild').hide();
	$('.loading').hide();
	
	//$(".send_form_data").click(function(){
//		
//		if(sent_success==0)
//		{
//	    $('.popup_form_container').hide();
//		$('.send_faild').hide();
//		$('.send_success').hide();
//		$('.loading').fadeIn("slow");
//		}								
//		if(sent_success==1)
//		{
//	    $('.popup_form_container').hide();
//		$('.send_faild').hide();
//		$('.loading').hide();
//		$('.send_success').fadeIn("slow");
//		}								
//		if(sent_success==2)
//		{
//	    $('.popup_form_container').hide();
//		$('.send_success').hide();
//		$('.loading').hide();
//		$('.send_faild').fadeIn("slow");
//		}								
//    });
	
		$(".reset_popup").click(function(){
		$('.send_success').hide();
		$('.send_faild').hide();
		$('.loading').hide();		
		$('.popup_form_container').show();
		$('#form_holder .field-clear').show();
		$('#form_holder .field-field').hide();
		$('#form_holder .field-field').val("");
    });

//-------------------------------------------------------------------------------
//                           Font setter
//-------------------------------------------------------------------------------							
var x = $.cookie('fontsize');
var fontsize=x;
if(fontsize==1){resetFont()}						   
if(fontsize==2){Increase_Font_Size_2X()}
if(fontsize==3){Increase_Font_Size_4X()}

     function resetFont()
	{	
$('.main_product div,.main_product td,.main_product span,.main_product li,.main_product th,.main_product td').css('font-size', '12px');
$('.main_product div,.main_product td,.main_product span,.main_product li,.main_product th,.main_product td').css('line-height', '18px');
$('.offers_area div,.offers_area td,.offers_area span,.offers_area li,.offers_area th,.offers_area td').css('font-size', '12px');
$('.offers_area div,.offers_area td,.offers_area span,.offers_area li,.offers_area th,.offers_area td').css('line-height', '18px');		
$('.site_map div,.site_map td,.site_map span,.site_map li,.site_map th,.site_map td').css('font-size', '12px');
$('.site_map div,.site_map td,.site_map span,.site_map li,.site_map th,.site_map td').css('line-height', '18px'); 
$('.bottom_section div,.bottom_section td,.bottom_section span,.bottom_section li,.bottom_section th,.bottom_section td').css('font-size', '12px');
$('.bottom_section div,.bottom_section td,.bottom_section span,.bottom_section li,.bottom_section th,.bottom_section td').css('line-height', '18px'); 
$('#cForm div,#cForm td,#cForm span,#cForm li,#cForm th,#cForm td').css('font-size', '12px');
$('#cForm div,#cForm td,#cForm span,#cForm li,#cForm th,#cForm td').css('line-height', '18px');	
$('.site_map_title').css('font-size', '28px');
$('.site_map .category_level_1').css('font-size', '14px');
$('.small_button').css('font-size', '5px');
$('.font_11').css('font-size', '11px');
$('.product_title').css('font-size', '13px');
$('.main_product_tilte').css('font-size', '15px');
$('.message_title').css('font-size', '16px');
$('.attention_title').css('font-size', '16px');
$('.spopup_header').css('font-size', '17px');
$('.main_product .spopup_header').css('font-size', '17px');
$('.big_title').css('font-size', '18px');
$('.product_title').css('line-height', '18px');
$('.main_product .product_menu li').css('font-size', '12px');
$('.main_product .product_menu li').css('line-height', '18px');
$('.main_product .product_menu').css('font-size', '12px');
$('.main_product .product_menu').css('line-height', '18px');
$('.gray_title').css('font-size', '20px');
$('.tabNavigation').css('font-size', '12px');
$('.tabNavigation').css('line-height', '18px');
$('.tabNavigation li').css('font-size', '12px');
$('.tabNavigation li').css('line-height', '18px');
$('.TV_index').css('font-size', '12px');
$('.TV_index').css('line-height', '18px');
$('.TV_index span').css('font-size', '12px');
$('.TV_index span').css('line-height', '18px');
$('#register_link a.font_11').css('font-size', '11px');



		$('.offers_area').height(250);
		$('.offers_area').css('background', 'url('+urlBase+'/offer_slice.jpg)');
		$('.resetFont').attr('src', urlBase+'/text_size_3_selected.gif');
		$('.increaseFont').attr('src', urlBase+'/text_size_2.gif');
		$('.increaseFont2').attr('src', urlBase+'/text_size_1.gif');
		$.cookie('fontsize', '1');
	} 
	
	    function Increase_Font_Size_2X()
	{
		
		
		
$('.main_product div,.main_product td,.main_product span,.main_product li,.main_product th,.main_product td').css('font-size', '15px');
$('.main_product div,.main_product td,.main_product span,.main_product li,.main_product th,.main_product td').css('line-height', '20px');
$('.offers_area div,.offers_area td,.offers_area span,.offers_area li,.offers_area th,.offers_area td').css('font-size', '15px');
$('.offers_area div,.offers_area td,.offers_area span,.offers_area li,.offers_area th,.offers_area td').css('line-height', '20px');	
$('.site_map div,.site_map td,.site_map span,.site_map li,.site_map th,.site_map td').css('font-size', '15px');
$('.site_map div,.site_map td,.site_map span,.site_map li,.site_map th,.site_map td').css('line-height', '20px'); 
$('#cForm div,#cForm td,#cForm span,#cForm li,#cForm th,#cForm td').css('font-size', '12px');
$('#cForm div,#cForm td,#cForm span,#cForm li,#cForm th,#cForm td').css('line-height', '18px');	
$('.bottom_section div,.bottom_section td,.bottom_section span,.bottom_section li,.bottom_section th,.bottom_section td').css('font-size', '15px');
$('.bottom_section div,.bottom_section td,.bottom_section span,.bottom_section li,.bottom_section th,.bottom_section td').css('line-height', '20px'); 
$('.site_map_title').css('font-size', '29px');
$('.site_map .category_level_1').css('font-size', '17px');
$('.small_button').css('font-size', '5px');
$('.font_11').css('font-size', '12px');
$('.product_title').css('font-size', '16px');
$('.main_product_tilte').css('font-size', '17px');
$('.message_title').css('font-size', '18px');
$('.attention_title').css('font-size', '18px');
$('.spopup_header').css('font-size', '18px');
$('.spopup_header').css('font-size', '18px');
$('.big_title').css('font-size', '20px');
$('.product_title').css('line-height', '18px');
$('.main_product .product_menu li').css('font-size', '12px');
$('.main_product .product_menu li').css('line-height', '18px');
$('.main_product .product_menu').css('font-size', '12px');
$('.main_product .product_menu').css('line-height', '18px');
$('.gray_title').css('font-size', '22px');
$('.tabNavigation').css('font-size', '12px');
$('.tabNavigation').css('line-height', '18px');
$('.tabNavigation li').css('font-size', '12px');
$('.tabNavigation li').css('line-height', '18px');
$('.TV_index').css('font-size', '12px');
$('.TV_index').css('line-height', '18px');
$('.TV_index span').css('font-size', '12px');
$('.TV_index span').css('line-height', '18px');
$('.popup_header span').css('font-size', '17px');
$('#register_link a.font_11').css('font-size', '11px');
	
		$('.offers_area').height(310);
		$('.offers_area').css('background', 'url('+urlBase+'/offer_slice2.jpg)');
		$('.resetFont').attr('src', urlBase+'/text_size_3.gif');
		$('.increaseFont').attr('src', urlBase+'/text_size_2_selected.gif');
		$('.increaseFont2').attr('src', urlBase+'/text_size_1.gif');
		$.cookie('fontsize', '2');
		return false;
	}
	
    function Increase_Font_Size_4X()
	{
	
$('.main_product div,.main_product td,.main_product span,.main_product li,.main_product th,.main_product td').css('font-size', '17px');
$('.main_product div,.main_product td,.main_product span,.main_product li,.main_product th,.main_product td').css('line-height', '22px');
$('.offers_area div,.offers_area td,.offers_area span,.offers_area li,.offers_area th,.offers_area td').css('font-size', '17px');
$('.offers_area div,.offers_area td,.offers_area span,.offers_area li,.offers_area th,.offers_area td').css('line-height', '22px');		
$('.site_map div,.site_map td,.site_map span,.site_map li,.site_map th,.site_map td').css('font-size', '17px');
$('.site_map div,.site_map td,.site_map span,.site_map li,.site_map th,.site_map td').css('line-height', '22px'); 
$('#cForm div,#cForm td,#cForm span,#cForm li,#cForm th,#cForm td').css('font-size', '12px');
$('#cForm div,#cForm td,#cForm span,#cForm li,#cForm th,#cForm td').css('line-height', '18px');	
$('.bottom_section div,.bottom_section td,.bottom_section span,.bottom_section li,.bottom_section th,.bottom_section td').css('font-size', '17px');
$('.bottom_section div,.bottom_section td,.bottom_section span,.bottom_section li,.bottom_section th,.bottom_section td').css('line-height', '22px'); 
$('.site_map_title').css('font-size', '30px');
$('.site_map .category_level_1').css('font-size', '20px');
$('.small_button').css('font-size', '5px');
$('.font_11').css('font-size', '13px');
$('.product_title').css('font-size', '18px');
$('.main_product_tilte').css('font-size', '20px');
$('.message_title').css('font-size', '20px');
$('.attention_title').css('font-size', '20px');
$('.spopup_header').css('font-size', '20px');
$('.spopup_header').css('font-size', '20px');
$('.big_title').css('font-size', '21px');
$('.product_title').css('line-height', '18px');
$('.main_product .product_menu li').css('font-size', '12px');
$('.main_product .product_menu li').css('line-height', '18px');
$('.main_product .product_menu').css('font-size', '12px');
$('.main_product .product_menu').css('line-height', '18px');
$('.gray_title').css('font-size', '24px');
$('.tabNavigation').css('font-size', '12px');
$('.tabNavigation').css('line-height', '18px');
$('.tabNavigation li').css('font-size', '12px');
$('.tabNavigation li').css('line-height', '18px');
$('.TV_index').css('font-size', '12px');
$('.TV_index').css('line-height', '18px');
$('.TV_index span').css('font-size', '12px');
$('.TV_index span').css('line-height', '18px');	
$('#register_link a.font_11').css('font-size', '11px');

		$('.offers_area').height(400);	
		$('.offers_area').css('background', 'url('+urlBase+'/offer_slice2.jpg)');	
		$('.resetFont').attr('src', urlBase+'/text_size_3.gif');
		$('.increaseFont').attr('src', urlBase+'/text_size_2.gif');
		$('.increaseFont2').attr('src', urlBase+'/text_size_1_selected.gif');
		$.cookie('fontsize', '3');
		return false;
	}
	// Reset Font Size
    var originalFontSize = $('#content').css('font-size');
    $(".resetFont").click(function(){
		resetFont();
    });
	
  	// Increase Font Size 2X
    $(".increaseFont").click(function(){
	Increase_Font_Size_2X();
    });
	
 	 // Increase Font Size 4X
    $(".increaseFont2").click(function(){
	Increase_Font_Size_4X();
    }); 
	//	onload functions goes here **********************************************	
		try
		{
			loadLoginCookie();	// load the login coockie if exists
		}
		catch(e)
		{
			//	load login cookie failed
		}
		
		try
		{
			load_relatedContent();	// load the related content JSP
			
		/*	alert("call");
		menu_selection('Tariffs');
		alert("1")
		postpaidAjaxFunctionCallings();
		alert("2")
		alert("end")*/
		/*bodyElem = document.getElementsByTagName("body")[0];
		onload = bodyElem.getAttribute("onload");
		alert(onload);
		eval(onload);*/
		}
		catch(e)
		{
			// the page does not have the related content area
			//alert("Error");
		}
		
	/*	bodyElem = document.getElementsByTagName("body")[0];
		onload = bodyElem.getAttribute("onload");
		alert(onload);*/
		//eval(onload);
//	*************************************************************************
});
 
//-------------------------------------------------------------------------------
//                           Home products show
//-------------------------------------------------------------------------------	
function show_product1()
{	
	document.getElementById("product1").className="control_area_selected";
	document.getElementById("product2").className="control_area";
	document.getElementById("product3").className="control_area control_area_3_row";
	document.getElementById("offfer_3").style.zIndex="-3";
	document.getElementById("offfer_2").style.zIndex="-2";
	document.getElementById("offfer_1").style.zIndex="1";$("#offfer_1").fadeIn("slow");
	$("#offfer_2").fadeOut("normal");
	$("#offfer_3").fadeOut("normal");
}
function show_product2()
{	
	document.getElementById("product2").className="control_area_selected";
	document.getElementById("product1").className="control_area";
	document.getElementById("product3").className="control_area control_area_3_row";
	document.getElementById("offfer_1").style.zIndex="-3";
	document.getElementById("offfer_3").style.zIndex="-2";
	document.getElementById("offfer_2").style.zIndex="1";$("#offfer_2").fadeIn("slow");
	$("#offfer_1").fadeOut("normal");
	$("#offfer_3").fadeOut("normal");
}
function show_product3()
{	
	document.getElementById("product3").className="control_area_selected control_area_3_row";
	document.getElementById("product1").className="control_area";
	document.getElementById("product2").className="control_area ";
	document.getElementById("offfer_1").style.zIndex="-3";
	document.getElementById("offfer_2").style.zIndex="-2";
	document.getElementById("offfer_3").style.zIndex="1";$("#offfer_3").fadeIn("slow");
	$("#offfer_2").fadeOut("normal");
	$("#offfer_1").fadeOut("normal");
}
//-------------------------------------------------------------------------------
//                           add to bookmark
//-------------------------------------------------------------------------------	
function bookmarksite(title,url)
{
	if (window.sidebar) // firefox
		window.sidebar.addPanel(title, url, "");
	else if(window.opera && window.print)
	{ // opera
		var elem = document.createElement('a');
		elem.setAttribute('href',url);
		elem.setAttribute('title',title);
		elem.setAttribute('rel','sidebar');
		elem.click();
	} 
	else if(document.all)// ie
		window.external.AddFavorite(url, title);
}
//-------------------------------------------------------------------------------
//                           Textbox limiter
//-------------------------------------------------------------------------------	
 
	function limitbox(textboxId,outputId,max){
	  this.textboxId = textboxId;
	  this.outputId = outputId;
	  this.max = max;
	  this.remainingText = "";
	  this.init();
	}
	 
	limitbox.prototype = {
	
	  init : function(){
	 
		var elem = document.getElementById(this.textboxId);
		var ref = this;
	 
		elem.onkeyup = function(){ref.keypress();}  
		elem.onkeydown = function(){ref.keypress();}  
		elem.onkeypress = function(){ref.keypress();}  
		elem.onchange = function(){ref.keypress();}  //catches paste events
	 
		this.keypress();
		elem = null;
	  },
	
	  keypress : function(){
		var elem = document.getElementById(this.textboxId);
		if(elem.value.length >= this.max) elem.value = elem.value.substr(0,this.max);
		document.getElementById(this.outputId).innerHTML = this.remainingText + (this.max - elem.value.length);    
		elem = null;
	  }
	}
	
	
	
//------------------------------------------------------------------------------------------------------------------------------------------------------
// implementation scripts

	function ajaxpage(url, containerid){
	    var page_request = false;
	    if (window.XMLHttpRequest) // if Mozilla, Safari etc
	            page_request = new XMLHttpRequest();
	    else if (window.ActiveXObject){ // if IE
			try {
				page_request = new ActiveXObject("Msxml2.XMLHTTP");
			} 
			catch (e){
				try{
					page_request = new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (e){}
			}
		}
		else
			return false;
	    
	    document.getElementById(containerid).innerHTML = "<p align='center'><br/><br/><img src='/webapp/jtags/jsps/18-1.gif' /><br /><b> Please wait </b><br><b>&#1575;&#1604;&#1585;&#1580;&#1575;&#1569; &#1575;&#1604;&#1575;&#1606;&#1578;&#1592;&#1575;&#1585; </b></p>";
	    page_request.onreadystatechange=function(){
			loadpage(page_request, containerid);
	    }
	    page_request.open('GET', url, true);
	    page_request.send(null);
	}
	
	function loadpage(page_request, containerid){
		if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)){
			 document.getElementById(containerid).innerHTML=page_request.responseText;
		}
	}

	function getPageMetaData(){
		var metaTags = document.getElementsByTagName('meta');
		var metaData = "";
		for(i=0;i<metaTags.length;i++){
		if( metaTags[i].name == 'metaData')
			metaData = metaTags[i].content;
		}
		return metaData;
	}
	
	function load_relatedContent(){
		var metaData = getPageMetaData();
		var url="/webapp/jtags/jsps/sub_related_content.jsp?metaData=" + metaData;
		ajaxpage(url, 'relatedContentDiv');
        if( document.getElementById('relatedContentDiv') != null )
			document.getElementById('relatedContentDiv').style.display='none';
	}
	
	function loadLoginCookie()
	{
		var username = $.cookie('etisalat_username');
		var password = $.cookie('etisalat_password');
		
		if( username != null  && username.length > 0 )
		{
			document.getElementById('ssousername1').value = username;
			document.getElementById('ssousername1').style.display="block";
			document.getElementById('txt_username_clear').style.display="none";
			
			document.getElementById('chk_rememberme').checked = true;
		}
		
		if( password != null && password.length > 0 )
		{
			document.getElementById('password1').value = password;
			document.getElementById('password1').style.display="block";
			document.getElementById('txt_password_clear').style.display="none";
			
			document.getElementById('chk_rememberme').checked = true;
		}
	}
	
	function onLogin()
	{
		if( document.getElementById('chk_rememberme').checked )
		{
			var username = document.getElementById('ssousername1').value;
			var password = document.getElementById('password1').value;
			
			if( username != null  && password != null && username.length > 0 && password.length > 0 )
			{		
				$.cookie('etisalat_username', username);
				$.cookie('etisalat_password', password);
			}
			else
			{
				//alert("please enter valid username/password for login!");
			}
		}
		else
		{
			$.cookie('etisalat_username', null);
			$.cookie('etisalat_password', null);
		}
	}
	
	function DecodeURL(inputString) { 
		if(inputString!=null && inputString!=""){
			while(inputString.indexOf("%2B")>=0) { inputString=inputString.replace("%2B","+"); } 
			while(inputString.indexOf("%21")>=0) { inputString=inputString.replace("%21","!"); } 
			while(inputString.indexOf('%22')>=0) { inputString=inputString.replace("%22",'"'); } 
			while(inputString.indexOf("%23")>=0) { inputString=inputString.replace("%23","#"); } 
			while(inputString.indexOf("%24")>=0) { inputString=inputString.replace("%24","$"); } 
			while(inputString.indexOf("%26")>=0) { inputString=inputString.replace("%26","&"); } 
			while(inputString.indexOf("%27")>=0) { inputString=inputString.replace("%27","'"); } 
			while(inputString.indexOf("%28")>=0) { inputString=inputString.replace("%28","("); } 
			while(inputString.indexOf("%29")>=0) { inputString=inputString.replace("%29",")"); } 
			while(inputString.indexOf("%2C")>=0) { inputString=inputString.replace("%2C",","); } 
			while(inputString.indexOf("%3A")>=0) { inputString=inputString.replace("%3A",":"); } 
			while(inputString.indexOf("%3B")>=0) { inputString=inputString.replace("%3B",";"); } 
			while(inputString.indexOf("%3C")>=0) { inputString=inputString.replace("%3C","<"); } 
			while(inputString.indexOf("%3D")>=0) { inputString=inputString.replace("%3D","="); } 
			while(inputString.indexOf("%3E")>=0) { inputString=inputString.replace("%3E",">"); } 
			while(inputString.indexOf("%3F")>=0) { inputString=inputString.replace("%3F","?"); } 
			while(inputString.indexOf("%5B")>=0) { inputString=inputString.replace("%5B","["); } 
			while(inputString.indexOf('%5C')>=0) { inputString=inputString.replace('%5C','\\');} 
			while(inputString.indexOf("%5D")>=0) { inputString=inputString.replace("%5D","]"); } 
			while(inputString.indexOf("%5E")>=0) { inputString=inputString.replace("%5E","^"); } 
			while(inputString.indexOf("%7B")>=0) { inputString=inputString.replace("%7B","{"); } 
			while(inputString.indexOf("%7C")>=0) { inputString=inputString.replace("%7C","|"); } 
			while(inputString.indexOf("%7D")>=0) { inputString=inputString.replace("%7D","}"); } 
			while(inputString.indexOf("%7E")>=0) { inputString=inputString.replace("%7E","~"); } 
			while(inputString.indexOf("%40")>=0) { inputString=inputString.replace("%40","@"); }
			while(inputString.indexOf("%")>=0) { inputString=inputString.replace("%"," "); }
		}
		return inputString; 
	}
	
	function EncodeURL(inputString){
		while(inputString.indexOf("+")>=0){inputString=inputString.replace("+","%2B");}
		while(inputString.indexOf("!")>=0){inputString=inputString.replace("!","%21");}
		while(inputString.indexOf('"')>=0){inputString=inputString.replace('"',"%22");}
		while(inputString.indexOf("#")>=0){inputString=inputString.replace("#","%23");}
		while(inputString.indexOf("$")>=0){inputString=inputString.replace("$","%24");}
		while(inputString.indexOf("&")>=0){inputString=inputString.replace("&","%26");}
		while(inputString.indexOf("'")>=0){inputString=inputString.replace("'","%27");}
		while(inputString.indexOf("(")>=0){inputString=inputString.replace("(","%28");}
		while(inputString.indexOf(")")>=0){inputString=inputString.replace(")","%29");}
		while(inputString.indexOf(",")>=0){inputString=inputString.replace(",","%2C");}
		while(inputString.indexOf(":")>=0){inputString=inputString.replace(":","%3A");}
		while(inputString.indexOf(";")>=0){inputString=inputString.replace(";","%3B");}
		while(inputString.indexOf("<")>=0){inputString=inputString.replace("<","%3C");}
		while(inputString.indexOf("=")>=0){inputString=inputString.replace("=","%3D");}
		while(inputString.indexOf(">")>=0){inputString=inputString.replace(">","%3E");}
		while(inputString.indexOf("?")>=0){inputString=inputString.replace("?","%3F");}
		while(inputString.indexOf("[")>=0){inputString=inputString.replace("[","%5B");}
		while(inputString.indexOf('\\')>=0){inputString=inputString.replace('\\',"%5C");}
		while(inputString.indexOf("]")>=0){inputString=inputString.replace("]","%5D");}
		while(inputString.indexOf("^")>=0){inputString=inputString.replace("^","%5E");}
		while(inputString.indexOf("{")>=0){inputString=inputString.replace("{","%7B");}
		while(inputString.indexOf("|")>=0){inputString=inputString.replace("|","%7C");}
		while(inputString.indexOf("}")>=0){inputString=inputString.replace("}","%7D");}
		while(inputString.indexOf("~")>=0){inputString=inputString.replace("~","%7E");}
		return inputString;
	}
	


   // public method for url encoding
	function encode(string) {
		return escape(this._utf8_encode(string));
	}

	// public method for url decoding
	function decode(string) {
		return this._utf8_decode(unescape(string));
	}

	// private method for UTF-8 encoding
	function  _utf8_encode(string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";

		for (var n = 0; n < string.length; n++) {

			var c = string.charCodeAt(n);

			if (c < 128) {
			utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
			utftext += String.fromCharCode((c >> 6) | 192);
			utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
			utftext += String.fromCharCode((c >> 12) | 224);
			utftext += String.fromCharCode(((c >> 6) & 63) | 128);
			utftext += String.fromCharCode((c & 63) | 128);
			}
		}

		return utftext;
	}

	// private method for UTF-8 decoding
	function  _utf8_decode(utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;

		while ( i < utftext.length ) {

			c = utftext.charCodeAt(i);

			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}
		}
		return string;
	}

	// public method for url encoding
	function encode(string) {
		return escape(this._utf8_encode(string));
	}
	// public method for url decoding
	function decode(string) {
		return this._utf8_decode(unescape(string));
	}
	// private method for UTF-8 encoding
	function  _utf8_encode(string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";
		for (var n = 0; n < string.length; n++) {
			var c = string.charCodeAt(n);
			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}
		}
		return utftext;
	}

	// private method for UTF-8 decoding
	function  _utf8_decode(utftext){
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;
		while ( i < utftext.length ){
			c = utftext.charCodeAt(i);
			if (c < 128){
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)){
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else{
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}
		}
		return string;
	}
	
	function postpaidAjaxFunctionCallings(){
	}
	function prepaidAjaxFunctionCallings(){
	}
	function randomizeimages(){
	}
	

	
	
