//jQuery.noConflict();

var textSearch = csSearchBoxDefStr;
var showAvSe = false;

//var bMainNoDataLost_g = false; //Global flag to indicate if input data may be lost at page change.

function searchIn(){
	if(jQuery("#searchField").val() == textSearch){
		jQuery("#searchField").val("");
		jQuery("#searchField").addClass("inputTextIn");
		jQuery("#searchField").removeClass("input");
	}
}

function searchOut(){
	if(jQuery("#searchField").val() == ""){
		jQuery("#searchField").addClass("input");
		jQuery("#searchField").removeClass("inputTextIn");
		jQuery("#searchField").val(textSearch);
	}
}

function searchAdvanceShow(){
	if(!showAvSe){
		
		
		jQuery("#sectionAdvencedSearch").slideDown("fast", function(){
			if(jQuery("#searchField").val() != textSearch){
				jQuery("#searchAdvancedField").val( jQuery("#searchField").val() );
			}
		});
		
		showAvSe = true;
	}else{
		jQuery("#sectionAdvencedSearch").slideUp("fast");
		showAvSe = false;
	}
}

function listSmallOver(i){   
	jQuery("#"+i).removeClass("itemScuupSmallList");
	jQuery("#"+i).addClass("itemScuupSmallListHover");
}
function listSmallOut(i){
	jQuery("#"+i).removeClass("itemScuupSmallListHover");
	jQuery("#"+i).addClass("itemScuupSmallList");
}

function listSmallSelect(i){
   if (jQuery("#"+i).hasClass(csSmallUnselCssClass)){   
      jQuery("#"+i).removeClass(csSmallUnselCssClass);
	   jQuery("#"+i).addClass(csSmallSelCssClass);
   }
   else{
      jQuery("#"+i).removeClass(csSmallSelCssClass);
	   jQuery("#"+i).addClass(csSmallUnselCssClass);      
   }
   
   /*   
   if (jQuery("#"+i).getClass() == "itemScuupSmallUnSel"){
   //if (jQuery("#"+i).ClassName.has(jQuery("#"+i).ClassName, "itemScuupSmallUnSel")){      
      jQuery("#"+i).removeClass("itemScuupSmallUnSel");
	   jQuery("#"+i).addClass("itemScuupSmallSel");
   }
   else{
      jQuery("#"+i).removeClass("itemScuupSmallSel");
	   jQuery("#"+i).addClass("itemScuupSmallUnSel");
   }
  */
   
   //jQuery("#"+i).toggleClass("itemScuupSmallUnSel itemScuupSmallSel", "boolean");
}

function stdJsLinkOver(sId){   
	jQuery("#"+sId).removeClass("stdJsLink");
	jQuery("#"+sId).addClass("stdJsLinkHover");
}
function stdJsLinkOut(sId){
	jQuery("#"+sId).removeClass("stdJsLinkHover");
	jQuery("#"+sId).addClass("stdJsLink");
}

/*
Desc.: Travel thru input string replace char matching ciTargetChar with ciSourceTarget
In:
   siIn:
   ciTargetChar:
   ciSourceTarget:
*/
function scSwapChar(siIn, ciTargetChar, ciSourceTarget){
   var sBuf = "";
   var cAppendChar = '';
   
   iLen = siIn.length;
   i = 0;
   for (i = 0; i < iLen; i++){
      if (ciTargetChar == siIn.charAt(i)){
         cAppendChar = ciSourceTarget;
      }
      else{
         cAppendChar = siIn.charAt(i);
      }
      sBuf = sBuf + cAppendChar;
   }
   return sBuf;
}

function isAlphaNumeric(sIn)
{
   var bResult = 1;
	var sBuf = sIn;
   
	for(var j=0; j<sBuf.length; j++){
     var alpha = sBuf.charAt(j);
     var iCharCode = alpha.charCodeAt(0);
     if((iCharCode > 47 && iCharCode<58) || (iCharCode > 64 && iCharCode<91) || (iCharCode > 96 && iCharCode<123))
     {
     }
     else	{
       bResult = 0;
       break;
     }
   }
   return bResult;
}

function isAlpha(sIn)
{
   var bResult = 1;
	var sBuf = sIn;
   
	for(var j=0; j<sBuf.length; j++){
     var alpha = sBuf.charAt(j);
     var iCharCode = alpha.charCodeAt(0);
     if((iCharCode > 64 && iCharCode<91) || (iCharCode > 96 && iCharCode<123)){
     }
     else{
       bResult = 0;
       break;
     }
   }
   return bResult;
}

function isValidName(sIn)
{
   var bResult = 1;
	var sBuf = sIn;
   var ciSpaceCharCode = 32;
   
	for(var j=0; j<sBuf.length; j++){
     var alpha = sBuf.charAt(j);
     var iCharCode = alpha.charCodeAt(0);
     //Must be alphabeth or space char.
   if((iCharCode > 64 && iCharCode<91) || (iCharCode > 96 && iCharCode<123) || (ciSpaceCharCode=iCharCode)){
     }
     else{
       bResult = 0;
       break;
     }
   }
   return bResult;
}

function isValidEmail(sIn){
   var bResult = 1
   var emailRegEx = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;
   if (sIn.search(emailRegEx) == -1){
      bResult = 0
   }
   return bResult;
}

function trim(stringToTrim) { return stringToTrim.replace(/^\s+|\s+$/g,""); }
