$(function()
{
    $("#callUsNumbers").hover(function(){
            $("#ContactNumbersList").fadeIn('slow');
        },function(){
            $("#ContactNumbersList").fadeOut('slow');
        });
});

//show/hide the off page pricing activities the 
//function show_hide_more_pricing(action)
//{
	//	if(action=="1")
		//{
				//show on page activities price list
		//		document.getElementById('more_link').style.display="none";
			//	document.getElementById('more_price').style.display="block";
		//}
		//else if(action=="0")
		//{
				//hide on page activities price list
			//	document.getElementById('more_price').style.display="none";
				//document.getElementById('more_link').style.display="block";
		//}

//}
function floatOnly1(myfield, e)
{
  var key;
  var keychar;
  if (window.event)
	key = window.event.keyCode;
  else if (e)
	key = e.which;
  else
	return true;
  
  keychar = String.fromCharCode(key);
  
  var str = myfield.value;
  var dec = str.indexOf(".");
  if (iscontrolkey(key))
	return true;
  if (dec >= 0)
  {
	//DECIMAL PRESENT
	//PREVENT ENTERING NUMBERS PAST X DECIMALS (depends on the currency in use)
  if ((str.length - dec > 2) && (getCursorPos(myfield) > str.length - 3))
	return false;
	//PREVENT ENTER TWO DECIMALS
  if (keychar == ".")
	return false;
  }
  else
  {
	//NO DECIMAL PRESENT
	//PREVENT ADDING THE DECIMAL IN THE WRONG PLACE
  if (keychar == "." && (getCursorPos(myfield) <= str.length - 3))
	return false;
  }
  if (("0123456789.").indexOf(keychar) > -1)
	return true;
  return false;
}


function numberOnly(myfield, e, errContainer, errMsg)
{
  //if the letter is not digit then display error and don't type anything
  if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57))
  {
    //display error message
    $("#"+errContainer).html(errMsg).show().fadeOut("slow");    //alert(errMsg);
    return false;
  }

}



function floatOnly(myfield, e, errContainer, errMsg)
{
  //if the letter is not digit then display error and don't type anything
  
  var key;
  var keychar;
  if (window.event)
    key = window.event.keyCode;
  else if (e)
    key = e.which;
  else
    return true;
  
  keychar = String.fromCharCode(key);
  
  var str = myfield.value;
  var dec = str.indexOf(".");
  if (iscontrolkey(key))
    return true;
  if (dec >= 0)
  {
    //DECIMAL PRESENT
    //PREVENT ENTERING NUMBERS PAST X DECIMALS (depends on the currency in use)
    if ((str.length - dec > 2) && (getCursorPos(myfield) > str.length - 3))
    {
     //display error message
      $("#"+errContainer).html(errMsg).show().fadeOut("slow");    //alert(errMsg);
      return false;
    }
    //PREVENT ENTER TWO DECIMALS
    if (keychar == ".")
    {
      //display error message
      $("#"+errContainer).html(errMsg).show().fadeOut("slow");    //alert(errMsg);
      return false;
    }
  }
  else
  {
    //NO DECIMAL PRESENT
    //PREVENT ADDING THE DECIMAL IN THE WRONG PLACE
    if (keychar == "." && (getCursorPos(myfield) <= str.length - 3))
    {
      //display error message
      $("#"+errContainer).html(errMsg).show().fadeOut("slow");    //alert(errMsg);
      return false;
    }
  }
  if (("0123456789.").indexOf(keychar) > -1)
    return true;
  
    //display error message
  $("#"+errContainer).html(errMsg).show().fadeOut("slow");    //alert(errMsg);
  return false;
  
}



function iscontrolkey(key)
{
  if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27) || (key==63232) || (key==63233) || (key==63234) || (key==63235) || (key==63272))
  return true;
}


function resetForm(formId) 
{	
	document.getElementById(formId).reset();
}

function blockEnter(evt)
{
  evt = (evt) ? evt : event;
  var charCode = (evt.charCode) ? evt.charCode : ((evt.which) ? evt.which : evt.keyCode);
  //alert(charCode);
  if (charCode == 13)
  {
    return false;
  }
  else
  {
    return true;
  }
}

function showLoader(msg)
{
	if(msg)
      $("#loader_text").html(msg);
      
    $.blockUI({message: $("#loader"),
		css: {
		top:'40%',
		left:'45%'
		}
	}); 
}

function hideLoader()
{
	$.unblockUI();
}

// capture Emails 
function captureEndUserDetails(name, email, subDomain)
{
	if(Validate.isEmail(email))
    {      
      var params = { 'function': 'captureEmail' };       
      params['EndUserName'] = name;
      params['EndUserEmail'] = email;
      params['SubDomain'] = subDomain;      
      
      $.post(CURRENT_ROOT_URL+'ajax/ajax.php', params, function(data){
          captureEndUserDetails_callback(data)
      });
    }
}

function captureEndUserDetails_callback(data)
{
    //alert(data);
}

//Function will validate website url of passed website
function validateUrl(value) 
{
	var url = value.toLowerCase();
	var urlReg = /^(https?:\/\/)?.+\..+$/i;
	return urlReg.test(url);
}



//Function will validate uploaded file extension
function validateFileExtension(fileName, arrAllowExt, id, message, focus) 
{
  var element = $(id);  
  for(i=0; i<arrAllowExt.length;i++)
  {
  	 allowedEx=arrAllowExt[i].toUpperCase();  	 
  	 message = message + allowedEx+', ';
  }
  
  message = message.substring(0, message.length-2); 
  message = message+').'; 
  fileName = jQuery.trim(fileName);
  if(fileName != '')
  {
  	var ext = fileName.split('.').pop().toLowerCase();
    
    if(jQuery.inArray(ext, arrAllowExt) == -1)
    {
      element.addClass('error');
      if(focus)
        setFocus(element);
      $(id+'_errMsg').show();
      $(id+'_errMsg').html(message);  
      return false
    }
    else
    {
      element.removeClass('error');
      $(id+'_errMsg').html('');
      $(id+'_errMsg').hide();
      return true;
    }
  }
  else
  {
    
    //element.addClass('error');
    if(focus)
      setFocus(element);
    $(id+'_errMsg').show();
    $(id+'_errMsg').html(message);
    return false;    
  }
  
}



function setFocus(element) {
	try {
		element.focus();
	}
	catch(e) {}
}


function setFormFocus(formId) 
{
	$('#'+formId+' input:visible:first').focus();
}



function showPopUp(id)
{
  //alert(id);
  $.blockUI({message: $("#"+id),
		css: {
		top:'10%',
		left:'33%',
        cursor:'default',
		opacity:'1',
		background:'#000'
		}
	}); 
}


function hidePopUp()
{
	$.unblockUI();
}




function range( low, high, step )
{
  // Create an array containing the range of integers or characters from low to high (inclusive)  
  // 
  // version: 909.322
  // discuss at: http://phpjs.org/functions/range    // +   original by: Waldo Malqui Silva
  // *     example 1: range ( 0, 12 );
  // *     returns 1: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
  // *     example 2: range( 0, 100, 10 );
  // *     returns 2: [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]    // *     example 3: range( 'a', 'i' );
  // *     returns 3: ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i']
  // *     example 4: range( 'c', 'a' );
  // *     returns 4: ['c', 'b', 'a']
  
  var matrix = [];
  var inival, endval, plus;
  var walker = step || 1;
  var chars  = false;
  
  if ( !isNaN( low ) && !isNaN( high ) )
  {
    inival = low;
    endval = high;
  }
  else if ( isNaN( low ) && isNaN( high ) )
  {
    chars = true;
    inival = low.charCodeAt( 0 );        endval = high.charCodeAt( 0 );
  }
  else
  {
    inival = ( isNaN( low ) ? 0 : low );
    endval = ( isNaN( high ) ? 0 : high );
  } 
  plus = ( ( inival > endval ) ? false : true );
  if ( plus )
  {
    while ( inival <= endval )
    {
      matrix.push( ( ( chars ) ? String.fromCharCode( inival ) : inival ) );            inival += walker;
    }
  }
  else
  {
    while ( inival >= endval )
    {
      matrix.push( ( ( chars ) ? String.fromCharCode( inival ) : inival ) );            inival -= walker;
    }
  }
  
  return matrix;

}


// Returns a random number  
function rand (min, max)
{
  // discuss at: http://phpjs.org/functions/rand    // +   original by: Leslie Hoare
  // +   bugfixed by: Onno Marsman
  // %          note 1: See the commented out code below for a version which will work with our experimental (though probably unnecessary) srand() function)
  // *     example 1: rand(1, 1);
  // *     returns 1: 1    
  var argc = arguments.length;
  if (argc === 0)
  {
    min = 0;
    max = 2147483647;
  }
  else if (argc === 1)
  {
    throw new Error('Warning: rand() expects exactly 2 parameters, 1 given');
  }
  return Math.floor(Math.random() * (max - min + 1)) + min;
}




function in_array (needle, haystack, argStrict)
{
    // Checks if the given value exists in the array  
    // 
    // version: 911.718
    // discuss at: http://phpjs.org/functions/in_array    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: vlado houba
    // +   input by: Billy
    // +   bugfixed by: Brett Zamir (http://brett-zamir.me)
    // *     example 1: in_array('van', ['Kevin', 'van', 'Zonneveld']);    // *     returns 1: true
    // *     example 2: in_array('vlado', {0: 'Kevin', vlado: 'van', 1: 'Zonneveld'});
    // *     returns 2: false
    // *     example 3: in_array(1, ['1', '2', '3']);
    // *     returns 3: true    // *     example 3: in_array(1, ['1', '2', '3'], false);
    // *     returns 3: true
    // *     example 4: in_array(1, ['1', '2', '3'], true);
    // *     returns 4: false
    
    
    var key = '', strict = !!argStrict; 
    if (strict)
    {
        for (key in haystack) {
            if (haystack[key] === needle) {
                return true;            }
        }
    } else {
        for (key in haystack) {
            if (haystack[key] == needle) {                return true;
            }
        }
    }
     return false;
}




//Function to show submenus in header section
function showSubMenu(val) 
{
	
		
}




document.onclick=check; 
function check(e)
{ 	
	
}



$(function() {
	$('a[rel*=external]').click( function() {
		window.open(this.href);
		return false;
	});
});



