var browserType;

if (document.layers) {browserType = "nn4"}
if (document.all) {browserType = "ie"}
if (window.navigator.userAgent.toLowerCase().match("gecko")) {
   browserType= "gecko"
}

function over_client(num) {
  if(document.images) {
	document.images[num].src = document.images[num].src.replace("_off", "_on");
	document.images[num+3].style.display='';
  }
}

function out_client(num) {
  if(document.images) {
    document.images[num].src = document.images[num].src.replace("_on", "_off");
    document.images[num+3].style.display='none';
  }
}

function over(num) {
  if(document.images) {
    document.images[num].src = document.images[num].src.replace("_off", "_on");
  }
}

function out(num) {
  if(document.images) {
    document.images[num].src = document.images[num].src.replace("_on", "_off");
  }
}

function set_language( lang_id ) {

  var get_string = "action=set&type="+lang_id; 
  
  // Send the request and update website 
  $.ajax({ 
      type: "GET", 
      data: get_string, 
      dataType: "json", 
      cache: false, 
      url: '/ajax/lang.php', 
      timeout: 2000, 
      error: function() {
        $.jnotifica('Error defining default language',{
          position  : 'bottom',
          width     : 300,
          height    : 100,
          effect    : 'fade',
          timeout   : 1500,
          clickClose: false,
          close     : false,
          msgCss    : {
            textAlign: 'center'
          },
          background: 'grey',
          opacity   : 0.5,
          margin    : 30,
          classes   : 'rounded_corners'
        }); 
      }, 
      success: function(data) { 

          // Fill sub category select 
          $.each(data, function(i, j){ 
        	  if ( j.code == "yes") {
        		  $.jnotifica(j.msg,{
        	          position  : 'bottom',
        	          width     : 300,
        	          height    : 100,
        	          effect    : 'fade',
        	          timeout   : 1500,
        	          clickClose: false,
        	          close     : false,
        	          msgCss    : {
        	            textAlign: 'center'
        	          },
        	          background: 'grey',
        	          opacity   : 0.5,
        	          margin    : 30,
        	          onClose   : window.location.reload( true ),
        	          classes   : 'rounded_corners'
        	        }); 
        	  }
          }); 
      } 
  }); 

}

$(document).ready(function()
{
  /* Login code */
  $("#members").submit(function()
  {
          //remove all the class add the messagebox classes and start fading
          $("#msgbox").removeClass().addClass('messagebox').text('Confirmar....').fadeIn(1000);
          //check the username exists or not from ajax
          $.post("members.php",{ user:$('#user').val(),pass:$('#pass').val(),rand:Math.random(),action:$('#action').val() } ,function(data)
          {
            if(data=='yes') //if correct login detail
            {
                  $("#msgbox").fadeTo(200,0.1,function()  //start fading the messagebox
                  {
                    //add message and change the class of the box and start fading
                    $(this).html('Sucesso.....').addClass('messageboxok').fadeTo(900,1,
                    function()
                    {
                       //redirect to secure page
                       $("#member_area").load('members.php?action=methods');
                    });
                  });
            }
            else
            {
                  $("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
                  {
                    //add message and change the class of the box and start fading
                    $(this).html('Erro ...').addClass('messageboxerror').fadeTo(900,1);
                  });
            }
         });
         return false;//not to post the  form physically
  });
  
    $("select#quick_district").change(function(){ 
        // Post string 
        var get_string = "action=drop_active_list&type=city&parent=" + $(this).val(); 
 
        // Send the request and update sub category dropdown 
        $.ajax({ 
            type: "GET", 
            data: get_string, 
            dataType: "json", 
            cache: false, 
            url: '/ajax/members.php', 
            timeout: 2000, 
            error: function() { 
                alert("Falha de actualizacao"); 
            }, 
            success: function(data) {  
                // Clear all options from sub category select 
                $("select#quick_city option").remove(); 
 
                // Fill sub category select 
                $.each(data, function(i, j){ 
                    var row = "<option value=\"" + j.id + "\">" + j.desc + "</option>"; 
                    $(row).appendTo("select#quick_city"); 
                }); 
            } 
        }); 
    });       

    $("select#district").change(function(){ 
        // Post string 
        var get_string = "action=drop_active_list&type=city&parent=" + $(this).val(); 
 
        // Send the request and update sub category dropdown 
        $.ajax({ 
            type: "GET", 
            data: get_string, 
            dataType: "json", 
            cache: false, 
            url: '/ajax/members.php', 
            timeout: 2000, 
            error: function() { 
                alert("Falha de actualizacao"); 
            }, 
            success: function(data) {  
                // Clear all options from sub category select 
                $("select#city option").remove(); 
 
                // Fill sub category select 
                $.each(data, function(i, j){ 
                    var row = "<option value=\"" + j.id + "\">" + j.desc + "</option>"; 
                    $(row).appendTo("select#city"); 
                }); 
            } 
        }); 
    });       
  
    $("select#country").change(function(){ 
        // Post string 
        var get_string = "action=drop_active_list&type=city&parent=" + $(this).val(); 
 
        // Send the request and update sub category dropdown 
        $.ajax({ 
            type: "GET", 
            data: get_string, 
            dataType: "json", 
            cache: false, 
            url: '/ajax/members.php', 
            timeout: 2000, 
            error: function() { 
                alert("Falha de actualizacao"); 
            }, 
            success: function(data) {  
                // Clear all options from sub category select 
                $("select#district option").remove(); 
 
                // Fill sub category select 
                $.each(data, function(i, j){ 
                    var row = "<option value=\"" + j.id + "\">" + j.desc + "</option>"; 
                    $(row).appendTo("select#district"); 
                }); 
            } 
        }); 
    });     
      
});  

