function ConfirmAct()
{
	return confirm("Are you sure?");
}

function ChangeLanguageSession(countryCode, currentPageId, currentPageType){
	jQuery.ajax({
   		type: "POST",
   		async: false,   		
   		url: window.location.protocol+'//'+window.location.host+siteRoot+'ajax_tasks.php', 
   		data: "task=ChangeLanguageSession&code="+countryCode+"&currentPageId="+currentPageId+"&currentPageType="+currentPageType,
   		success: 
   		function(res) { 
			window.location.href=res;
		}
 	});
}

function SaveLenseCookie(lensId){
	jQuery.ajax({
   		type: "POST",
   		async: false,   		
   		url: window.location.protocol+'//'+window.location.host+siteRoot+'ajax_tasks.php', 
   		data: "task=SaveLenseCookie&lensId="+lensId,
   		success: 
   		function(res) { 
   			//alert(res);
		}
 	});
}

function RemoveLenseCookie(){
	jQuery.ajax({
   		type: "POST",
   		async: false,   		
   		url: window.location.protocol+'//'+window.location.host+siteRoot+'ajax_tasks.php', 
   		data: "task=RemoveLenseCookie",
   		success: 
   		function(res) { 
   			alert(res);
   			window.location.reload(true);
		}
 	});
}

function validateNumericField(field){
	if(!IsNumeric(field.value)) 
		field.value = field.value.substring(0, field.value.length-1);
}

function IsNumeric(strString){
	//var strValidChars = "0123456789.-";
	var strValidChars = "0123456789.";
	var strChar;
	var blnResult = true;
	if (strString.length == 0) return false;
	//  test strString consists of valid characters listed above
	for (i = 0; i < strString.length && blnResult == true; i++){
	  strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1){
         blnResult = false;
      }
	}
	return blnResult;
}



function populateSelect(elId, items) {
	el = document.getElementById(elId);
    el.options.length = 0;
    $.each( items, function(index, item){
    	el.options[el.options.length] = new Option(item, item);
	});	
}

function selectOption(select_id, option_val) {
    $('#'+select_id+' option:selected').removeAttr('selected');
    $('#'+select_id+' option[value='+option_val+']').attr('selected','selected');       
}

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function removeItems(array, item) {
	var i = 0;
	while (i < array.length) {
		if (array[i] == item) {
			array.splice(i, 1);
		} else {
			i++;
		}
	}
	return array;
}


