
function CreateFlashControl(DivID,WIDTH, HEIGHT , URL)
{
  var d = document.getElementById(DivID);
 
  d.innerHTML =  '<OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ' +
  'CODEBASE="http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0" ' +
  'WIDTH='+ WIDTH  + 
  ' HEIGHT='+ HEIGHT + ' > ' +
  '<PARAM NAME="MOVIE" VALUE="'+ URL+'">'+
  '<PARAM NAME="QUALITY" VALUE="HIGH"><PARAM NAME="PLAY" VALUE="TRUE">'+
  '<PARAM NAME="LOOP" VALUE="TRUE">'+
  '<PARAM NAME="BGCOLOR" VALUE="#FFFFFF">'+
  '<EMBED SRC="' + URL +'" '+
  'QUALITY="HIGH" BGCOLOR="#FFFFFF"'+
  ' WIDTH="'+ WIDTH + '" '+
  'HEIGHT="'+ HEIGHT +'" '+
  'TYPE="application/x-shockwave-flash" '+
  'PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">'+
  '</EMBED></OBJECT>';
   
  
}

function playFireFox(url)
{
var d = document.getElementById('fireFoxPlay');
 
  d.innerHTML =   '<EMBED type="application/x-mplayer2"'+
                  'pluginspage="http://www.microsoft.com/Windows/'+
                  'MediaPlayer/" SRC="'+url+'"'+
                  'name="WinMedia"'+
                  'autostart="true" width=0 height=0 ShowStatusBar=true'+
                  'ShowControls=false></EMBED>';

}

function CreateTopFlashControl(DivID,WIDTH, HEIGHT , URL)
{
  var d = document.getElementById(DivID);
 
  d.innerHTML =   '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+
  ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"'+
  ' WIDTH="'+ WIDTH + '" '+
  'HEIGHT="'+ HEIGHT +'" '+
  '><param name="movie" '+
  'value="' + URL +'" '+
  '><param name="quality" value="high">'+
  '<embed src="' + URL +'" '+
  ' quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer"'+
  ' type="application/x-shockwave-flash"'+
  ' WIDTH="'+ WIDTH + '" '+
  'HEIGHT="'+ HEIGHT +'" '+
  '></embed></object>';
   
  
}

function CreatePlayTopFlashControl(DivID,WIDTH, HEIGHT , URL)
{
	
	
  var d = document.getElementById(DivID);
 
  d.innerHTML =   '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+
  ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"'+
  ' WIDTH="'+ WIDTH + '" '+
  'HEIGHT="'+ HEIGHT +'" '+
  '><param name="movie" '+
  'value="' + URL +'" '+
  '><param name="quality" value="high">'+
  '<embed src="' + URL +'" '+
  ' quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer"'+
  ' type="application/x-shockwave-flash"'+
  ' WIDTH="'+ WIDTH + '" '+
  'HEIGHT="'+ HEIGHT +'" '+
  '></embed></object>';
   
  
}


function change_area(city_options)
{

    var area_field=document.getElementById("area_field001");
    
    //alert("omer");
    
    if( area_field.options[area_field.selectedIndex].value == null )
    {
        return;
    }
        
    var area_id = area_field.options[area_field.selectedIndex].value;
    
    var city_array = city_options[area_id];
    
    
    var city_field=document.getElementById("city_field001");

    city_field.options.length = 1;
    
    
    var city_length = city_array.length;
    
    
    var i=1;
    for(m in city_array)
    {
       //alert(city_array[m]+" ,"+m);
       city_field.options[i] = new Option(city_array[m], m, false, false);
       i++; 
    }
                                                                              

      
}



function select_city(area_id)
{

    var field_operator_prefix=document.getElementById("area_"+area_id);
    
    //alert(field_operator_prefix);
    
    var operator_prefix = field_operator_prefix.options[field_operator_prefix.selectedIndex].value;

    document.getElementById("city_id").value=operator_prefix;
    
    alert(operator_prefix);   
}




function changePhone( phone_id, phone_name, image_location ) {
		
		el = document.getElementById("phone_image");
		el.src = image_location;
		   
        currNameTag = document.getElementById("phone_name");
        newContent = document.createTextNode( phone_name );
        currNameTag.replaceChild(newContent,currNameTag.firstChild);
        
        document.getElementById("phone_id").value=phone_id;
        document.getElementById("phone_name").value=phone_name;
        document.getElementById("phone_location").value=image_location;
}


/**************reg select companey******************/

function mytrim(t) {
	
	a = t.replace(/^\s+/, '');
	return a.replace(/\s+$/, '');

};

function getDefultOperator()
{
	
	var field_operator_prefix=document.getElementById("msisdn_prefix_001");
    prefix = field_operator_prefix.options[field_operator_prefix.selectedIndex].text;
    
    return prefix;
	
}

var userMsisdn='';
var old_number='old_number';

function userMsisdnChange()
{
	//alert('userMsisdnChange');
	
	userMsisdn = getNumber();
	//alert(userMsisdn);
	
	
	if(userMsisdn.length==10) { // check only 10 dijit numbers
		
		if(old_number != userMsisdn){  // if not same as befor
			
			old_number = userMsisdn;
			//alert(userMsisdn);
			getNewOperator();
		  
		    
		}
		
	}
	
	 old_userMsisdn = userMsisdn;
}

function getNumber()
{
	var field_operator_prefix=document.getElementById("msisdn_prefix_001");
	
	//alert(field_operator_prefix);
	
    prefix = field_operator_prefix.options[field_operator_prefix.selectedIndex].text;
	
	userMsisdn = prefix + document.getElementById("msisdn_body").value;
	
	return userMsisdn;
}

function getNewOperator()
{
	// using ajax :
	
	//change_operator(getDefultCompany());

	get_operator_ajax(userMsisdn);
	
	// not useing ajax :
	
	//var field_operator_prefix=document.getElementById("msisdn_prefix_001");
    //var operator_prefix = field_operator_prefix.options[field_operator_prefix.selectedIndex].text;
    
    //change_operator(operator_prefix);
    
}
/**************reg select companey******************/
function change_operator(operator_prefix)
{
    
    var operator_id = 0;
    
    for(m in operators_array)
    {       
        document.getElementById("prefix_"+operators_array[m]).style.display='none';
        
        if( operator_prefix == operators_array[m] )
        {
            operator_id = m;
        }                                  
    } 
    
    document.getElementById("prefix_"+operator_prefix).style.display='block';
    
    var div_id = operator_id+"_"+selected_manufacturers_array[operator_id]; 
    
    var operator_manufacturers = eval("operator_"+operator_id+"_manufacturers"); 
            
    display_manufacturer(div_id, operator_manufacturers); 
        
    document.getElementById("operator_id").value=operator_id;
}


function display_manufacturer(manufacturer_id, manufacturers_array)
{
    
    for(m in manufacturers_array)
    {       
        document.getElementById("manufacturer_"+manufacturers_array[m]).style.display='none'; 
        document.getElementById("manufacturer_name_"+manufacturers_array[m]).className='reg_celltype';
        document.getElementById("manufacturer_href_"+manufacturers_array[m]).className='reg_celltype';                                   
    } 
    
    document.getElementById("manufacturer_"+manufacturer_id).style.display='block';
    document.getElementById("manufacturer_name_"+manufacturer_id).className='reg_celltype_selected';
    document.getElementById("manufacturer_href_"+manufacturer_id).className='reg_celltype_selected';  
   
}


function toggle(category_id)
{

    var div_to_toggle = document.getElementById("parent_"+category_id); 
       
    var divstyle = div_to_toggle.style;
   
    var opened;
       
		if (window.getComputedStyle) {
				opened = window.getComputedStyle(div_to_toggle,null).getPropertyValue("display") == "block";	
		}
		else if (div_to_toggle.currentStyle) {
				opened = div_to_toggle.currentStyle.display == "block";
		}
 
    
    if ( opened ) {

        divstyle.display = "none";
    } else {

        divstyle.display = "block";
    }
}

var selected_sound=0;

function doMoviePause() {
       
    
    try {
        // generate an error
         
        window.frames.movie_name.moviePause();          

    } catch (e) {
    }
}

function close_youtube_movie() {
           
    
    
    try {
        // generate an error
         
      close_youtube_display();

    } catch (e) {
    }
}

function Play_item(perview,pic_id)
{
	
	src =  perview.replace("mp3", "swf");
    //alert(document.getElementById(pic_id).src);
	if(selected_sound!=pic_id) // start 
	{
		close_youtube_movie();		
		
		if(selected_sound!=0) { // there is a diffrent one playing 
		    document.getElementById(selected_sound).src="/1/images/btn/item_listen_0.gif";
		    
		    
		     CreatePlayTopFlashControl('playme', "0", "0", '' );
		   /* if (document.all){
		        document.player_cellular.controls.stop();
            } else {
            // firefox
            }
            */
		}
		    
		selected_sound=pic_id;
		
		 CreatePlayTopFlashControl('playme', "0", "0", src );
		/*
		if (document.all){
		    document.player_cellular.url=perview;
		    document.player_cellular.controls.play();
	         } else {
	          // firefox
	          playFireFox(perview);
	         }	
	         */
		document.getElementById(pic_id).src="/1/images/btn/item_listen_1.gif";
	   }
	else    //  stop
	{
		selected_sound=0;
		/*
		if (document.all){
		document.player_cellular.controls.stop();
		} else {
		 // firefox
		}*/
		 CreatePlayTopFlashControl('playme', "0", "0", '' );
		document.getElementById(pic_id).src="/1/images/btn/item_listen_0.gif";
	
	}
}
function changeRingpic( elem_id, which_pic, what_state ) {

        if(elem_id==selected_sound) return; 
		el = document.getElementById(elem_id);
		el.className= 'pointer';
		el.src = "/1/images/btn/" + which_pic + "_" + ((what_state==0)?"d":(what_state-1)) + ".gif";
}

function changepic( elem_id, which_pic, what_state ) {
        
        
		el = document.getElementById(elem_id);
		el.className= 'pointer';
		
		el.src = "/1/images/btn/" + which_pic + "_" + ((what_state==0)?"d":(what_state-1)) + ".gif";
}

var selected_sound=0;

function stop_play()
{
    
	if (document.all){
	document.player_cellular.controls.stop();
	} else {
	 // firefox
	}
	document.getElementById(selected_sound).src="/2/images/btn/listen_0.gif";
	selected_sound=0;

}


function end_song()
{

    state = document.getElementById("player_cellular").playState;
    
    if ((state == 3) ||  (state == 6) || (state == 9)  ) {
           
          
           // still playing
            
           clearTimeout(timeout_id);
    	   timeout_id = window.setTimeout("end_song();","1000");
    
    } else {
            
          
            // preview ended
            
            no_mu(); // play main vid

            clearTimeout(timeout_id);
    }

}

function Play(perview,pic_id)
{
	 
	src =  perview.replace("mp3", "swf");
	 
	if(selected_sound!=pic_id) // start 
	{
		
		close_youtube_movie();
		
		if(selected_sound!=0) { // there is a diffrent one playing 
		    document.getElementById(selected_sound).src="/1/images/btn/listen_0.gif";
		    
		     CreatePlayTopFlashControl('playme', "0", "0", '' );
          
		}
		    
		selected_sound=pic_id;
		  CreatePlayTopFlashControl('playme', "0", "0", src );
		document.getElementById(pic_id).src="/1/images/btn/listen_1.gif";
	   }
	else    //  stop
	{
		selected_sound=0;
		 CreatePlayTopFlashControl('playme', "0", "0", '' ); // news
	
		document.getElementById(pic_id).src="/1/images/btn/listen_0.gif";
	
	}
}
function PlayMp3(perview,pic_id)
{
    //alert(document.getElementById(pic_id).src);
	if(selected_sound!=pic_id) // start 
	{
		
		close_youtube_movie();
		
		if(selected_sound!=0) { // there is a diffrent one playing 
		    document.getElementById(selected_sound).src="/1/images/btn/listen_0.gif";
		    
		    if (document.all){
		        document.player_cellular.controls.stop();
            } else {
            // firefox
            }
		}
		    
		selected_sound=pic_id;
		
		if (document.all){
		    document.player_cellular.url=perview;
		    document.player_cellular.controls.play();
	         } else {
	          // firefox
	          playFireFox(perview);
	         }	
		document.getElementById(pic_id).src="/1/images/btn/listen_1.gif";
	   }
	else    //  stop
	{
		selected_sound=0;
		if (document.all){
		document.player_cellular.controls.stop();
		} else {
		 // firefox
		}
		document.getElementById(pic_id).src="/1/images/btn/listen_0.gif";
	
	}
}
function changeRingpic( elem_id, which_pic, what_state ) {

        if(elem_id==selected_sound) return; 
		el = document.getElementById(elem_id);
		el.className= 'pointer';
		el.src = "/1/images/btn/" + which_pic + "_" + ((what_state==0)?"d":(what_state-1)) + ".gif";
}

function changepic( elem_id, which_pic, what_state ) {
        
        
		el = document.getElementById(elem_id);
		el.className= 'pointer';
		
		el.src = "/1/images/btn/" + which_pic + "_" + ((what_state==0)?"d":(what_state-1)) + ".gif";
}

function changepic_verify( elem_id, which_pic, what_state ) {
        
        
		el = document.getElementById(elem_id);
		el.className= 'verify_submit pointer';
		el.src = "/1/images/btn/" + which_pic + "_" + ((what_state==0)?"d":(what_state-1)) + ".gif";
}


function changepicIcon( elem_id, which_pic, what_state ) {
		el = document.getElementById(elem_id);
		el.src = "/1/images/icons/" + which_pic + "_" + ((what_state==0)?"d":(what_state-1)) + ".gif";
}

function changepicImage( elem_id, which_pic, what_state ) {
		el = document.getElementById(elem_id);
		el.src = "/1/images/" + which_pic + "_" + ((what_state==0)?"d":(what_state-1)) + ".gif";
}
/*************************/

var object_place = new Array();

function move_items_next_prev( object_id,flag,object_item_array ) {

 
    var object = document.getElementById("object_"+object_id); 
    var num_items = object.num_items;
    var page_size = object.page_size;
    
    object_place[object_id] = ( flag == 'prev' ) ?
    object_place[object_id] -= page_size*1 : 
    object_place[object_id] += page_size*1
    
       object_place[object_id] = object_place[object_id] < 0 ? 
     num_items - page_size :  object_place[object_id];   ; // sical 
    //   0 :  object_place[object_id]; 
   
   
   // object_place[object_id] = object_place[object_id]  +  page_size*1 > num_items*1 ? 
   //     num_items - page_size : object_place[object_id]; 
    
   object_place[object_id] = object_place[object_id]  >= num_items*1 ? 
        0 : object_place[object_id];  // sical    
    
    var place = object_place[object_id] ;
    
    var i = 1;
    
    
    for(e in object_item_array)
    {
        document.getElementById("item_"+e).style.display='none'; 
                
        if( (i > place) && (i <= place + page_size*1 ) ) {
            
            
            document.getElementById("item_"+e).style.display=''; 
             
        }   
             
            
     i++;
    
    } 
    
}



/*************************/

var object_place = new Array();

function move_text_service_next_prev( object_id,flag,object_item_array ) {

 
    var object = document.getElementById("object_"+object_id); 
    var num_items = object.num_items;
    var page_size = object.page_size;
    
    object_place[object_id] = ( flag == 'prev' ) ?
    object_place[object_id] -= page_size*1 : 
    object_place[object_id] += page_size*1
    
     // object_place[object_id] = object_place[object_id] < 0 ? 
   //     0 : object_place[object_id];
   
    object_place[object_id] = object_place[object_id] < 0 ? 
     num_items - page_size :  object_place[object_id];   ; // sical 
     
   
  //  object_place[object_id] = object_place[object_id]  +  page_size*1 > num_items*1 ? 
  //      num_items - page_size :  object_place[object_id];
  
     object_place[object_id] = object_place[object_id]  >= num_items*1 ? 
        0 : object_place[object_id];  // sical
    
    var place = object_place[object_id] ;
    
    var i = 1;
    
    
    for(e in object_item_array)
    {
          // alert(e); 
           document.getElementById("text_service_name_"+e).style.display='none'; 
           document.getElementById("text_service_text_"+e).style.display='none'; 
           document.getElementById("text_service_down_"+e).style.display='none';  
                
        if( (i > place) && (i <= place + page_size*1 ) ) {
            
            document.getElementById("text_service_name_"+e).style.display=''; 
            document.getElementById("text_service_text_"+e).style.display=''; 
            document.getElementById("text_service_down_"+e).style.display=''; 
             
        }   
             
            
     i++;
    
    } 
    
}




/*************************/

/*************************/


var manufacturers_place = new Array();

function move_manufacturers( object_id,operator_manufacturers_array ) {

 
    var flag = 'next';    
    var num_items = operator_manufacturers_array.length;    
    var page_size = 4;
    
    //alert("place1:"+manufacturers_place[object_id]);
    
    manufacturers_place[object_id] = ( flag == 'prev' ) ?
    manufacturers_place[object_id] -= page_size : 
    manufacturers_place[object_id] += page_size
    
    //alert("place2:"+manufacturers_place[object_id]);
    
    manufacturers_place[object_id] = manufacturers_place[object_id]  >= num_items ? 
        0 : 
        manufacturers_place[object_id];
   
        
    //alert("place3:"+manufacturers_place[object_id]);
    
    var place = manufacturers_place[object_id] ;
    
    
    var i = 1;
    
    //var j = 0;
    var display_first_div = false;
    var display_first_div_name = "";
    var display_first_div_key = "";
    for(e in operator_manufacturers_array)
    {
        document.getElementById("manufacturer_name_"+operator_manufacturers_array[e]).style.display='none'; 
        
        document.getElementById("manufacturer_"+operator_manufacturers_array[e]).style.display='none'; 
                
        if( (i > place) && (i <= place + page_size*1 ) ) {
            
            if( !display_first_div ) {
                
                display_first_div = true;
                display_first_div_name = "manufacturer_"+operator_manufacturers_array[e];
                display_first_div_key = operator_manufacturers_array[e];
                     
            }
            
            //j++;
            document.getElementById("manufacturer_name_"+operator_manufacturers_array[e]).style.display=''; 
             
        } 
                                   
     i++;
    
    }
    
    //alert(display_first_div_name);
    
    //document.getElementById(display_first_div_name).style.display=''; 
    
    display_manufacturer(display_first_div_key,operator_manufacturers_array);
    
    
}

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}


function findPosX(obj) {
    var curleft = 0;
    if (obj.offsetParent) {
        while (1) {
            curleft+=obj.offsetLeft;
            if (!obj.offsetParent) {
                break;
            }
            obj=obj.offsetParent;
        }
    } else if (obj.x) {
        curleft+=obj.x;
    }
    return curleft;
}

function floatMail(iX,iY,id){
   var L=dD.getElementById?dD.getElementById(id):dD.all?dD.all[id]:dD.layers[id];		
   this[id+'O']=L;if(dD.layers)L.style=L;L.nX=L.iX=iX;L.nY=L.iY=iY;
   L.P=function(x,y){this.style.left=x+px;this.style.top=y+px;};
   L.Fm=function(){
      var pX, pY;	
      pX=(this.iX >=0)?0:nn?innerWidth:nn&&dH.clientWidth?dH.clientWidth:dB.clientWidth;	
      pY=nn?pageYOffset:nn&&dH.scrollTop?dH.scrollTop:dB.scrollTop;	
      if(this.iY<0)
         pY+=nn?innerHeight:nn&&dH.clientHeight?dH.clientHeight:dB.clientHeight;	
      this.nX+=.1*(pX+this.iX-this.nX);
      this.nY+=.1*(pY+this.iY-this.nY);this.P(this.nX,this.nY);
      setTimeout(this.id+'O.Fm()',33);
   };
   return L;
}


/*************************/