﻿function ShowHideCtrl(ShowCtrl,HideCtrl){$('#' + HideCtrl).slideUp('slow');$('#' + ShowCtrl).slideDown('slow');}
function ShowHideFader(ShowCtrl,HideCtrl){$('#' + HideCtrl).fadeOut();$('#' + ShowCtrl).fadeIn();
$('#' + HideCtrl).css('display','none');
$('#' + ShowCtrl).css('display','');
}
 function DisableDropdownItem(drpCtrl,drpValue)
 {
    for(i=0;i<drpCtrl.length;i++)
    {
        if(parseInt(drpCtrl.options[i].value) == drpValue)
        {
            drpCtrl.options[i].disabled="disabled";
        }
    }
}

function ValidateDate(day,Month,year)
{   
    var monthfield=Month;
    var dayfield=day;
    var yearfield=year;
    var dayobj = new Date(yearfield, monthfield-1, dayfield)
    if ((dayobj.getMonth()+1!=monthfield)||(dayobj.getDate()!=dayfield)||(dayobj.getFullYear()!=yearfield))
        return false;
    return true;
}

function ChngMemCountwiseState(CtrlCountry,CtrlUs,CtrlAus,CtrlCA,CtrlInd,TxtOther,drpAllState)
{
    CtrlUs.style.display='none';
    CtrlAus.style.display='none';
    CtrlCA.style.display='none';
    CtrlInd.style.display='none';
    TxtOther.style.display='none';
    drpAllState.style.display='none';
    TxtOther.value='';    
    switch(parseInt(CtrlCountry.value))
    {
        case 226:
            CtrlUs.style.display='';
            break;
        case 14:
            CtrlAus.style.display='';
            break;
        case 37:
            CtrlCA.style.display='';
            break;
        case 103:
            CtrlInd.style.display='';
            break;
         case -1:
            drpAllState.style.display='';            
            break;
        default:
    
            TxtOther.style.display='';
            break;
    }
    
}

function ChangeCountrywiseState(CtrlCountry,CtrlUs,CtrlAus,CtrlCA,CtrlInd,TxtOther,LblTitle)
{
    $('#' + CtrlUs).hide();
    $('#' + CtrlAus).hide();
    $('#' + CtrlCA).hide();
    $('#' + CtrlInd).hide();
    $('#' + TxtOther).hide();
    $('#' + TxtOther).val('');    
    $('#' + LblTitle).html('State/provinece');
    switch(parseInt($('#' + CtrlCountry).val()))
    {
        case 226:
            $('#' + CtrlUs).show();
            break;
        case 14:
            $('#' + CtrlAus).show();
            break;
        case 37:
            $('#' + CtrlCA).show();
            break;
        case 103:
            $('#' + CtrlInd).show();
            break;       
        default:
            $('#' + TxtOther).show();
            $('#' + LblTitle).html('Other State');
            break;
    }    
}
function trim(strComp)
{	
	return jQuery.trim(strComp);
}

function ValidateControl(formObject, fieldDescription,lblObject) 
{
	var tempFormValue;
	var strError ="";	
	var iFocus =-1;	
	var ErrCount=1;
    
	for (var i =0; i < ValidateControl.arguments.length; i=i+3)
	{	   	   		
	    tempFormValue =trim($('#' + ValidateControl.arguments[i]).val());	   	   	    
	    if (tempFormValue.length == 0)
		{
		    if(strError!='')		    
		        strError = strError+  "<br/> - " + ValidateControl.arguments[i+1];
		    else
		        strError= " - " + ValidateControl.arguments[i+1];
		    ErrCount = ErrCount + 1;
		    $('#' + ValidateControl.arguments[i+2]).attr('class','alert');		    
		    if (iFocus == -1)
			    iFocus = i;
		}
		else
		{
		     $('#' + ValidateControl.arguments[i+2]).attr('class','');
		}
	}

	if (strError.length != 0)
	{				
		return strError;
	}
	else
		return strError;
}
    function isEmailAddress(emField){ //reference to email field passed as argument

    var fieldValue =emField // store field's entire value in variable

    // Begin Valid Email Address Tests

    //if field is not empty
    if(fieldValue != ""){
    var atSymbol = 0

    //loop through field value string
    for(var a = 0; a < fieldValue.length; a++){

    //look for @ symbol and for each @ found, increment atSymbol variable by 1
    if(fieldValue.charAt(a) == "@"){
    atSymbol++
    }

    }

    // if more than 1 @ symbol exists
    if(atSymbol > 1){
    // then cancel and don't submit form
    return false
    }

    // if 1 @ symbol was found, and it is not the 1st character in string
    if(atSymbol == 1 && fieldValue.charAt(0) != "@"){
    //look for period at 2nd character after @ symbol
    var period = fieldValue.indexOf(".",fieldValue.indexOf("@")+2)

    // "." immediately following 1st "." ?
    var twoPeriods = (fieldValue.charAt((period+1)) == ".") ? true : false

    //if period was not found OR 2 periods together OR field contains less than 5 characters OR period is in last position
    if(period == -1 || twoPeriods || fieldValue.length < period + 2 || fieldValue.charAt(fieldValue.length-1)=="."){
    // then cancel and don't submit form
    return false
    }

    }
    // no @ symbol exists or it is in position 0 (the first character of the field)
    else{
    // then cancel and don't submit form
    return false
    }
    }
    // if field is empty
    else{
    // then cancel and don't submit form
    return false
    }

    //all tests passed, submit form
    return true
    }
function ShowHideSlideCtrl(ShowCtrl,HideCtrl,Duration)
{
    $('#' + HideCtrl).slideUp();
    $('#' + ShowCtrl).slideDown();
    return false;
}
function ShowHideCtrl(ShowCtrl,HideCtrl)
{
    $('#' + HideCtrl).slideUp('slow');
    $('#' + ShowCtrl).slideDown('slow');    
}

function CharacterCount(obj, total,showdiv){
	if(total == null) total = 500;
	var len = obj.value.length;
	var newdiv;
	
	if(document.getElementById("note" + obj.id) == null){
		newdiv = document.createElement('div');
		newdiv.id = "note" + obj.id;
	    obj.parentNode.appendChild(newdiv);
	} else{
		newdiv = document.getElementById("note" + obj.id);
	}
	
	if(len == 0){
	    obj.parentNode.removeChild(newdiv);
    }
		
	if(len >= total){
		var temp = obj.value.substring(0, total)
		obj.value = temp;
		if(showdiv!=null && showdiv==0){
		    return false;
		}
		newdiv.innerHTML = "You have reached maximum character limit of <b>" + total + "</b>."
		return false;
	} 
	else{
	    if(showdiv==null || showdiv==1){
	    newdiv.innerHTML = "Your maximum character limit is: <b>" + total + "</b>. Current character count: <b>" + len + "</b>.";
	    return true;
	    }
		
	}
	 return true;
}
function WordCount(obj, total)
        {            
            if(total == null) total = 150;
            var strArray = new Array();
            var len = 0;
            
            strArray = obj.value.split(' ');
            for(var i=0;i<strArray.length;i++)
            {
                if(strArray[i] != ''){len = len + 1;}
            }
            var newdiv;
        	
            if(document.getElementById("note" + obj.id) == null){
	            newdiv = document.createElement('div');
	            newdiv.id = "note" + obj.id;
	            newdiv.className="";
                obj.parentNode.appendChild(newdiv);
            }
            else{
	            newdiv = document.getElementById("note" + obj.id);
            } 
                    	
            if(len == 0){
                obj.parentNode.removeChild(newdiv);
            }        	             	  	        	        		
            if(len >= total){
               
               if(obj.value.length > 3000){

	                var temp = obj.value.substring(0, 3000)
	                obj.value = temp;
	                
	                if(document.all)            
	                    newdiv.innerText = "You have reached maximum character limit of 3000.";
	                else
	                    newdiv.innerHTML = "You have reached maximum character limit of 3000.";
	            }
	           else{
	                if(document.all)            
	                    newdiv.innerText = "You have reached maximum word limit of " + total + ".";
	                else
	                    newdiv.innerHTML = "You have reached maximum word limit of " + total + ".";
	                    
	                    return false;
	             }
            }
            else{     
                  if(document.all)                   
	                newdiv.innerText = "Remaining word " + (total - len )+ ".";
	              else
	                newdiv.innerHTML = "Remaining word " + (total - len )+ ".";
            }
            return true;
        }

function DisplayMessage(ctrl,clsName,Msg)
{
    $('#' + ctrl).show();
    $('#' + ctrl).attr('class',clsName +' clear');
    $('#' + ctrl).html(Msg);       
    setTimeout('$(\'#'+ctrl+'\').hide();',10000);
}
function DisplMsg(Ctrl,ErrMsg,Msgclass)
{    
    $('#'+ Ctrl).show();
    $('#'+ Ctrl).html(ErrMsg);
    $('#'+ Ctrl).attr('class',Msgclass);
}

//--to show the error message of required valiation--//
function ValidateControlAdmin(formObject, fieldDescription,lblObject)
{
    var tempFormValue;
	var strError ="";	
	var iFocus =-1;	
	var ErrCount=1;
	for (var i =0; i < ValidateControlAdmin.arguments.length; i=i+3)
	{
	    if(typeof(ValidateControlAdmin.arguments[i]) == 'undefined')
		{		    
		    return 'Error';
		}	
		tempFormValue = jQuery.trim(ValidateControlAdmin.arguments[i].val());
		
		 if (tempFormValue.length < 15)
	        {deleteLoop = tempFormValue.length}
	     else
	        {deleteLoop = 15}
	        
	     for (var j = 0; j < deleteLoop; j++) 
		{
		    tempFormValue = tempFormValue.replace(/ / , "");
		}   
		
		if (tempFormValue.length == 0)
		{
		    if(strError!='')		    
		        strError = strError+  "<br/> - " +ValidateControlAdmin.arguments[i+1];
		    else
		        strError= " - " + ValidateControlAdmin.arguments[i+1];
		    ErrCount = ErrCount + 1;
		    ValidateControlAdmin.arguments[i+2].addClass('alert');
		    if (iFocus == -1)
			    iFocus = i;
		}
		else
		{
		     ValidateControlAdmin.arguments[i+2].addClass('');
		}
	}
	if (strError.length != 0)
	{				
		return strError;
	}
	else
		return strError;
} 

 
function DirValCtrl(){
   var lbl;var inctrl;var ErrMsg='';var IsFirst=0;
   $('span[class="red"]').each(function(){
        lbl=$(this).siblings();                
        if($(this).siblings().length>0){                          
            inctrl=$(lbl).attr('for');
            if(inctrl.length >0 && $(lbl).attr('for').length>0){    
//                alert(inctrl);
//                alert($('#' + inctrl).attr('type'));      
                switch($('#' + inctrl).attr('type')){
                    case "text":
                    case "file":
                    case "password":
                        if($('#' + inctrl).val()=='' && $('#' + inctrl).is(':visible')){
                            $('#' + inctrl).attr('style','border:solid 1px #ff0000 !important');
                            ErrMsg=ErrMsg + '<br/> - ' + $(lbl).html();
                            if(IsFirst==0){$('#' + inctrl).focus();}
                            IsFirst=1;
                        }
                        else{$('#' + inctrl).attr('style','');}
                        break;
                    case "select":
                        if($('#' + inctrl).val()=='') ErrMsg=ErrMsg + '<br/> - ' + $(lbl).html();
                        break;
                    case "select-one":
                        if($('#' + inctrl).val()=='0' || $('#' + inctrl).val()==''){
                            ErrMsg=ErrMsg + '<br/> - ' + $(lbl).html();
                            $('#' + inctrl).attr('style','border:solid 1px #ff0000 !important');
                        }
                        else $('#' + inctrl).attr('style','');
                        break;
                    case "select-multiple":
                        var selopt  = '';
                        $('#' + inctrl + ' > option').each(function(i, selected) {
                           if(this.selected){selopt = '';return false;}
                           else{selopt = ErrMsg + '<br/> - ' + $(lbl).html();}
                        });
                        if(selopt.length!=0){
                          ErrMsg=ErrMsg + '<br/> - ' + $(lbl).html();
                          $('#' + inctrl).attr('style','border:solid 1px #ff0000 !important;width:207px;size:5;');
                        }
                        break;
                    case "textarea":
                        if($('#' + inctrl).val()==''){
                           ErrMsg=ErrMsg + '<br/> - ' + $(lbl).html();
                           $('#' + inctrl).attr('style','border:solid 1px #ff0000 !important');
                        }
                        else{$('#' + inctrl).attr('style','');}
                        break;
                }
            }
        }
   });
   return ErrMsg;
}
function isValidURL(url){
    var RegExp = /^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/;
    if(RegExp.test(url)){
        return true;
    }else{
        return false;
    }
} 

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 findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }
function EncodeText(UrlText)
{
    UrlText= UrlText.replace(/%/g,'-per-');
    UrlText = UrlText.replace(/&/g,'-and-');
    UrlText = UrlText.replace(/\?/g,'-que-');
    UrlText = replaceCharacters(UrlText,'/','-sla-');
    return UrlText;
}
function replaceCharacters(MainStr,ScanChar,RepChar) { 
  var newString = MainStr.split(ScanChar);
  newString = newString.join(RepChar);
  return newString;
}
function CreateTag(TagName,TagProp,TagValue)
{
    var ctrl = document.createElement(TagName);    
    for(var i=0;i<CreateTag.arguments.length-1;i++)
    {        
        if(document.all)
        {            
            if(CreateTag.arguments[i+1]=='style')
            {
                var tmpStyle = CreateTag.arguments[i+2].split(':');
                switch(tmpStyle[0])
                {                    
                    case "display":
                        ctrl.style.display=tmpStyle[1];                        
                        break;
                }                
            }
            else if(CreateTag.arguments[i+1]=='class')
                ctrl.setAttribute('className',CreateTag.arguments[i+2]); 
            else
                ctrl.setAttribute(CreateTag.arguments[i+1],CreateTag.arguments[i+2]);        
        }
        else
        {
            ctrl.setAttribute(CreateTag.arguments[i+1],CreateTag.arguments[i+2]);
        }
        i=i+1;
    }    
    return ctrl;
}
function textChanger(obj, text) {
    if (text == null) { text = '' }
    if (obj.value == '')
        obj.value = text;
    else if (obj.value.toLowerCase() == text.toLowerCase())
        obj.value = '';
    else if (obj.value != text)
        return;
} 
function FlashContent(fullpath){
    document.write("<script type=\"text/javascript\">AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','411','height','375','src','ladimer','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','ladimer' ); //end AC code</script><noscript><object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0\" width=\"411\" height=\"375\"><param name=\"movie\" value=\""+fullpath+"\" /><param name=\"quality\" value=\"high\" /><embed src=\""+fullpath+"\" quality=\"high\" pluginspage=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" width=\"411\" height=\"375\"></embed></object></noscript>");
}
function BindLabels()
{
    $('.dataentry tr td:odd label').each(function(){
        //if($(this).is('td:odd'))
        //alert($(this).html());
        $(this).attr('for',$('.bindcontrol').attr('id'));
        //alert($(this).children().find('label').html());
        
        //$(this).children(function(){
          // alert($(this).html());
        //});
        
        
    });
}
function formatPhone(source, style){
    var realNumber = '';var pFormat = '';
	for(var i = 0; i < source.value.length; i++){
		if(isNaN(source.value.charAt(i)) == false && source.value.charAt(i) != ' '){realNumber += source.value.charAt(i);}
	}
	if(style == null) style = 'US';
	if(style == 'US'){
		for(var i = 0; i < realNumber.length; i++){
			switch (i){
				case 0:
					pFormat += "(" + realNumber.charAt(i); break;
				case 3:
					pFormat += ") " + realNumber.charAt(i); break;
				case 6:
					pFormat += "-" + realNumber.charAt(i); break;
				case 10:
					pFormat += "-" + realNumber.charAt(i); break;
				case 15:
					pFormat = pFormat; break;
				default:
					if(i < 15)
						pFormat += realNumber.charAt(i); 
					break;
			}
		}
		if(arguments.length == 3 && arguments[2] == true && source.value.length > 14){
		    pFormat = pFormat.substring(0,14) + ' Ext.' + pFormat.substring(15)
		}
	}
	else{
		for(var i = 0; i < realNumber.length; i++){
			switch (i){
				case 0:
					pFormat += "+" + realNumber.charAt(i); break;
				case 3:
					pFormat += "-" + realNumber.charAt(i); break;
				case 6:
					pFormat += "-" + realNumber.charAt(i); break;
				case 9:
					pFormat += "-" + realNumber.charAt(i); break;
				case 13:
					pFormat += "-(" + realNumber.charAt(i); break;
				case 17:
					pFormat += realNumber.charAt(i) + ")"; break;
				//case 18:
				//	pFormat = pFormat; break;
				default:
					if(i < 18){pFormat += realNumber.charAt(i);}
					break;
			}
		}
	}
	source.value = pFormat;
}
function isImage(obj){
    if (obj.value.length > 4){    
        var tmpExt= obj.value.split('.');
        var ext = tmpExt[tmpExt.length-1].toLowerCase();        
        if (ext == 'jpg' || ext =='bmp'  || ext =='tif' || ext =='tiff' || ext == 'jpeg' || ext == 'gif' || ext == 'png'){return true;}
    }
    return false;
}
function isPdf(obj){	    	    
    if (obj.value.length > 4){
        var tmpExt= obj.value.split('.');
        var ext = tmpExt[tmpExt.length-1].toLowerCase();
        if (ext == 'pdf'){
            return true;
        }
    }
    return false;
}
function showhidePanel(objDiv)
{
   var divsearch  = document.getElementById(objDiv).style;
	if(divsearch.display == "none")
		divsearch.display = "block";
	else
		divsearch.display = "none";
		
	return false;
}
 
//to highlight the left links menu when selected like "my profile","highest rated"
function HighlightBookListType()
{
    var i = 0;
    $('.american').each(function(){
       
       if(window.location.href == $(this).children().attr('href')){
             $(this).attr('class','highlightlinkleft');
             i = 1;
             }
    });
    
}
function CheckBoxListCheck(ClassName,type,limit)
{
   
    var k = 0;
    var ChkBoxError = '';
    
        $("." + ClassName).each(function(){
                if(type == 'audience')
                {
                   if ($(this).children().attr('checked')){
                        ChkBoxError = '';
                        k = k + 1;
                    }
                }
                else
                {
                    if ($(this).attr('checked')){
                        ChkBoxError = '';
                        k = k + 1;
                    }
                }
            if(k > limit)
            { 
                ChkBoxError = '<br/> - You can only choose one or two '+ type +' and not more than that'; 
                return false;
            }
            else if (k == 0)
                {ChkBoxError = '<br/> - Select atleast one ' + type;}
        });
    
    return ChkBoxError;
}
function IsEmail(email) {
        var regex = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
        if (regex.test(email)) return true;
        else return false;
}
function IsValidPassword(Password) {
        var regex = /^.[^\']{5,20}$/;
        if (regex.test(Password)) return true;
        else return false;
}
function IsValidZip(ZipValue) {
        var regex = /^[\d]{5}$/;
        if (regex.test(ZipValue)) return true;
        else return false;
}  
// Validating Payment Field at Pro Method of Payment.

<!--
function mod10( cardNumber ) 
{ 
	// LUHN Formula for validation of credit card numbers.
	var ar = new Array( cardNumber.length );
	var i = 0,sum = 0;

   	for( i = 0; i < cardNumber.length; ++i ) 
	{
    	ar[i] = parseInt(cardNumber.charAt(i));
    }
    
	for( i = ar.length -2; i >= 0; i-=2 ) 
	{ 
		// you have to start from the right, and work back.
    	ar[i] *= 2;		// every second digit starting with the right most (check digit)
   		if( ar[i] > 9 ) ar[i]-=9;	// will be doubled, and summed with the skipped digits.
   	}	// if the double digit is > 9, ADD those individual digits together 

   	for( i = 0; i < ar.length; ++i ) 
	{
    	sum += ar[i];	// if the sum is divisible by 10 mod10 succeeds
   	}
   	return (((sum%10)==0)?true:false);	 	
}

function expired( month, year ) 
{
   	var now = new Date();	// this function is designed to be Y2K compliant.
   	var expiresIn = new Date(year,month,0,0,0);		// create an expired on date object with valid thru expiration date
   	expiresIn.setMonth(expiresIn.getMonth()+1);		// adjust the month, to first day, hour, minute & second
                                                    //	of expired month
   	if(now.getTime() < expiresIn.getTime()) 
   	{
   	    return false;
   	}
    return true;	// then we get the miliseconds, and do a long integer comparison
}

function validateCreditCard(cardNumber,cardType,cardMonth,cardYear,cardCode){
    if(cardType.length == 0){ return "Please select credit card type.";	}
	
	if(cardNumber != null){
  	    if( cardNumber.length == 0 ){ return "Please enter valid card number."; }
    }
    if( cardCode.length == 0 ){ return "Please enter valid card code."; }
    
    if(cardNumber != null){
        for( var i = 0; i < cardNumber.length; ++i ){	
		    // make sure the number is all digits.. (by design)
            var c = cardNumber.charAt(i);

   		    if( c < '0' || c > '9' ){
        	    return "Please enter valid card number. Use only digits. do not use Spaces or Hyphens.";        	    
            }
        }
    }
    
	if(cardNumber != null){
	    var length = cardNumber.length;		//perform card specific length and prefix tests
    	
   	    switch( cardType ){
    	    case 'a':
			    if( length != 15 ){ return "Please enter valid American Express card number."; }
                var prefix = parseInt( cardNumber.substring(0,2));
   			    if( prefix != 34 && prefix != 37 ){ return "Please enter valid American Express card number."; }
            break;
            case 'd':
			    if( length != 16 ){ return "Please enter valid Discover card number."; }
                var prefix = parseInt( cardNumber.substring(0,4));
			    if( prefix != 6011 ){ return "Please enter valid Discover card number."; }
            break;
            case 'm':
			    if( length != 16 ){ return "Please enter valid MasterCard number."; }
                var prefix = parseInt( cardNumber.substring(0,2));
			    if( prefix < 51 || prefix > 55){ return "Please enter valid MasterCard number."; }
            break;
            case 'v':
			    if( length != 16 && length != 13 ){ return "Please enter valid Visa card number."; }
                var prefix = parseInt( cardNumber.substring(0,1));
			    if( prefix != 4 ){ return "Please enter valid Visa card number."; }
            break;
        }
        
	    if(!mod10(cardNumber)){ 	
		    // run the check digit algorithm
            return "Sorry! This is not a valid credit card number.";            
        }
    }
    
    if(cardMonth == ''){ return "Please select expiration month."; }
    if(cardYear == ''){ return "Please select expiration year."; }
    
    if(expired(cardMonth, cardYear)){
		// check if entered date is already expired.
        return "Sorry! The expiration date you have entered would make this card invalid.";
    }
    if (cardCode != ""){
		 for( var i = 0; i < cardCode.length; ++i ){
			var c = cardCode.charAt(i);
			if( c < '0' || c > '9' ){ return "Please enter valid card code. Use only digits."; }
		}
	}
	return "";	// at this point card has not been proven to be invalid
}
function EditorCheck(ctrl)
        {
            // This is for Fck Editor checking
            for ( var name in FCKeditorAPI.Instances)
            {
                var oEditor = FCKeditorAPI.Instances[ name ] ;
                if ( oEditor.GetParentForm && oEditor.GetParentForm() == ctrl )
                oEditor.UpdateLinkedField() ;
            }
            // end here
        } 
        
        
/* Generate header menu */
$(function(){
    $("ul.dropdown li").hover(function(){
        $(this).addClass("hover");
        $('ul:first',this).css('visibility', 'visible');
    }, function(){
        $(this).removeClass("hover");
        $('ul:first',this).css('visibility', 'hidden');
    });
    $("ul.dropdown li ul li:has(ul)").find("a:first").append(" &raquo;");
});

 function EncodeSearchText(strSearchText){
            var aryCharacters = ["%",".","#","&","*",":","<",">","?"," "];
            var aryEncodedCharacters = ["x25","x2E", "x23", "x26", "x2A", "x3A", "x3C", "x3E", "x3F","x20"]; 
            for(var index = 0;index<aryCharacters.length;index++)
            {
                var intIndexOfMatch = strSearchText.indexOf(aryCharacters[index]);
                while (intIndexOfMatch != -1){
	                strSearchText = strSearchText.replace(aryCharacters[index], aryEncodedCharacters[index] )
	                intIndexOfMatch = strSearchText.indexOf(aryCharacters[index]); 
                }
            }
           return strSearchText;
        }
 
